/*------------------------------------------------------------------------- * get_GameParameters() *------------------------------------------------------------------------- */ STDMETHODIMP CAdminGame::get_GameParameters(IAGCGameParameters** ppParams) // overrides IAGCGameImpl { // Perform default processing RETURN_FAILED(IAGCGameImplBase::get_GameParameters(ppParams)); assert(*ppParams); // Get the IGC pointer ImissionIGC * pIGCMission = GetIGC(); assert(pIGCMission); // Populate the team names for (SideLinkIGC* psl = pIGCMission->GetSides()->first(); (psl != NULL); psl = psl->next()) { IsideIGC* pside = psl->data(); if (pside) { CComBSTR bstrTemp(pside->GetName()); RETURN_FAILED((*ppParams)->put_TeamName(pside->GetObjectID(), bstrTemp)); } } // Get the CFSMission pointer CFSMission* pFSMission = GetHostIGC(); // Set the StoryText property CComBSTR bstrStoryText(pFSMission->GetStoryText()); RETURN_FAILED((*ppParams)->put_StoryText(bstrStoryText)); // Set the starting tech bits if (pFSMission->m_pttbmAltered && pFSMission->m_pttbmNewSetting) { // Loop through the techbit masks for each team for (int iSide = 0; iSide < c_cSidesMax; ++iSide) { // Loop through each techbit for (short iBit = 0; iBit < c_ttbMax; ++iBit) { if (pFSMission->m_pttbmAltered[iSide].GetBit(iBit)) { bool bBit = pFSMission->m_pttbmNewSetting[iSide].GetBit(iBit); (*ppParams)->put_OverriddenTechBit(iSide, iBit, VARBOOL(bBit)); } } } } // Indicate success return S_OK; }
STDMETHODIMP CSimple::myMethod(BSTR bstrIn, BSTR *pbstrOut) { if (bstrIn == NULL || pbstrOut == NULL) return E_POINTER; // Create a temporary CComBSTR CComBSTR bstrTemp(bstrIn); if (!bstrTemp) return E_OUTOFMEMORY; // Make string uppercase wcsupr(bstrTemp); // Return m_str member of bstrTemp *pbstrOut = bstrTemp.Detach(); return S_OK; }
CString CIVConnection::Login() { CString strQuery; CString strURL; if(-1 == m_opts.m_strURL.Find(_T("http"))) { strURL = _T("http://"); strURL += m_opts.m_strURL; } else strURL = m_opts.m_strURL; strQuery.Format (_T("%s/auth.asp?name=%s"), (LPCTSTR) strURL, (LPCTSTR) m_opts.m_strAccount); CString strResult; if(!m_opts.m_strAccount.GetLength()) { CString strError; AfxFormatString1 (strError, ERR_IDS_IV_CANNOT_LOGIN, _T("")); SetError (strError); AfxThrowUserException(); } GetHTTPData(strQuery, strResult); if (strResult.IsEmpty() || strResult.GetLength()<6 || *(LPCSTR)strResult < '0' || *(LPCSTR)strResult >'9') { CString strError; AfxFormatString1 (strError, ERR_IDS_IV_CANNOT_LOGIN, m_opts.m_strAccount); SetError (strError); AfxThrowUserException(); } if (m_spIMD5 == NULL) { HRESULT hr = m_spIMD5.CreateInstance (__uuidof(IC::MD5)); if (FAILED (hr)) { SetError (ERR_IDS_IV_MD5); AfxThrowUserException(); } } CString strSID; try { CString strInput = strResult; strInput += m_opts.m_strPassword; BSTR bstrInput = strInput.AllocSysString(); _bstr_t bstrTemp (bstrInput, false); strSID = (BSTR) m_spIMD5->GetMDString (&bstrInput); } catch (_com_error & ) { CString strErr ( (LPCSTR) ERR_IDS_UNEXPECTED ) ; AfxThrowUserException(); } return strSID; }