HRESULT CServiceModule::InitAGC() { // Initialize AGC HRESULT hr; ZSucceeded(hr = _AGCModule.Init()); RETURN_FAILED(hr); _AGCModule.SetDebugBreakOnErrors(g.fWantInt3); #ifdef _DEBUG _AGCModule.GetAGCGlobal()->SetDebugHook(&g_DebugHook); #endif // _DEBUG // Create the set of available AGCEventID ranges CComPtr<IAGCEventIDRanges> spRanges; ZSucceeded(hr = spRanges.CoCreateInstance(L"AGC.EventIDRanges")); RETURN_FAILED(hr); // Add our ranges to it ZSucceeded(spRanges->AddByValues(EventID_AGC_LowerBound, EventID_AGC_UpperBound)); ZSucceeded(spRanges->AddByValues(AllsrvEventID_Allsrv_LowerBound, AllsrvEventID_Allsrv_UpperBound)); ZSucceeded(spRanges->AddByValues(EventID_Admin_LowerBound, EventID_Admin_UpperBound)); // Set the ranges of available events GetAGCGlobal()->SetAvailableEventIDRanges(spRanges); // Create the event logger object ZSucceeded(hr = m_spEventLogger.CreateInstance("AGC.EventLogger")); RETURN_FAILED(hr); // Initialize the event logger object CComBSTR bstrEventSource(__MODULE__); CComBSTR bstrRegKey("HKLM\\" HKLM_FedSrvA); IAGCEventLoggerPrivatePtr spPrivate(m_spEventLogger); hr = spPrivate->Initialize(bstrEventSource, bstrRegKey); ZSucceeded(hr); RETURN_FAILED(hr); // Hook the event logger for DB event logging ZSucceeded(hr = spPrivate->put_HookForDBLogging(&g_DBLoggingHook)); // Indicate success return S_OK; }
void CServiceModule::TermAGC() { // Shutdown the event logger object if (NULL != m_spEventLogger) { IAGCEventLoggerPrivatePtr spPrivate(m_spEventLogger); assert(NULL != spPrivate); // Terminate the event logger ZSucceeded(spPrivate->Terminate()); // Unhook the event logger for DB event logging { ZSucceeded(spPrivate->put_HookForDBLogging(NULL)); } // Release the event logger spPrivate = NULL; m_spEventLogger = NULL; } // Terminate AGC _AGCModule.Term(); }
HRESULT CPigEngine::Construct() { // Get the path name of the module TCHAR szModule[_MAX_PATH]; _VERIFYE(GetModuleFileName(_Module.GetModuleInstance(), szModule, sizeofArray(szModule))); // Break the path name of the module into pieces TCHAR szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szName[_MAX_FNAME]; _tsplitpath(szModule, szDrive, szDir, szName, NULL); // Open the registry key of the AppID CRegKey key; RETURN_FAILED(_Module.OpenAppIDRegKey(key, KEY_READ)); // Create the event logger object RETURN_FAILED(m_spEventLogger.CreateInstance("AGC.EventLogger")); // Initialize the event logger object CComBSTR bstrEventSource(L"PigSrv"); CComBSTR bstrRegKey(L"HKCR\\AppID\\{F132B4E3-C6EF-11D2-85C9-00C04F68DEB0}"); IAGCEventLoggerPrivatePtr spPrivate(m_spEventLogger); RETURN_FAILED(spPrivate->Initialize(bstrEventSource, bstrRegKey)); // Load the MissionServer registry value LoadRegString(key, TEXT("MissionServer"), m_bstrMissionServer); // Load the AccountServer registry value LoadRegString(key, TEXT("AccountServer"), m_bstrAccountServer); // Load the ZoneAuthServer registry value LoadRegString(key, TEXT("ZoneAuthServer"), m_bstrZoneAuthServer); // Load the ZoneAuthTimeout registry value DWORD dwZoneAuthTimeout; if (ERROR_SUCCESS == key.QueryValue(dwZoneAuthTimeout, TEXT("ZoneAuthTimeout"))) m_nZoneAuthTimeout = static_cast<long>(dwZoneAuthTimeout); // Load the LobbyMode registry value DWORD dwLobbyMode; if (ERROR_SUCCESS == key.QueryValue(dwLobbyMode, TEXT("LobbyMode"))) m_eLobbyMode = (PigLobbyMode_Club <= dwLobbyMode && dwLobbyMode <= PigLobbyMode_Free) ? static_cast<PigLobbyMode>(dwLobbyMode) : PigLobbyMode_Club; // Attempt to read the ScriptDir value from the registry ZString strScriptDir; LoadRegString(key, TEXT("ScriptDir"), strScriptDir); // Create a directory name from the root directory, by default if (strScriptDir.IsEmpty()) { TCHAR szScriptDir[_MAX_PATH + 1]; _tmakepath(szScriptDir, szDrive, szDir, TEXT("Scripts"), NULL); strScriptDir = szScriptDir; } // Ensure that m_bstrScriptDir ends with a whack int nLastChar = strScriptDir.GetLength() - 1; if (TEXT('\\') != strScriptDir[nLastChar]) strScriptDir += ZString("\\"); // Save the directory name m_bstrScriptDir = strScriptDir; // Create the pigs collection object with a ref count assert(!m_pPigs); CComObject<CPigs>* pPigs = NULL; RETURN_FAILED(pPigs->CreateInstance(&pPigs)); (m_pPigs = pPigs)->AddRef(); // Indicate success return S_OK; }
/*------------------------------------------------------------------------- * CAdminGames::Add() *------------------------------------------------------------------------- * Purpose: * Add to the collection of Games * * Parameters: * pGameParameters: a pointer to a CGameParameters interface. * This houses the mission params. * */ STDMETHODIMP CAdminGames::Add(IAGCGameParameters* pGameParameters) { if (!pGameParameters) return Error("Creation Parameters was Null"); // Cannot create a game on a paused server if (!g.strLobbyServer.IsEmpty() && !g.fmLobby.IsConnected()) return Error(IDS_E_GAME_SERVER_PAUSED, IID_IAdminGames); IAGCPrivatePtr spPrivate(pGameParameters); assert(NULL != spPrivate); CGameParamData * pMissionParams = (CGameParamData *)spPrivate->GetIGCVoid(); assert(pMissionParams); #if defined(ALLSRV_STANDALONE) // Standalone server only supports a single game const ListFSMission * plistMission = CFSMission::GetMissions(); if (plistMission->n()) return Error(IDS_E_ONE_GAME_PER_SERVER, IID_IAdminGames); // Standalone server only support a maximum of c_cMaxPlayersPerGame players total if (pMissionParams->nTotalMaxPlayersPerGame > c_cMaxPlayersPerGame) pMissionParams->nTotalMaxPlayersPerGame = c_cMaxPlayersPerGame; // Standalone games always have a min players per team of 1 and max // players per team of maxPlayerPerGame / nTeams. // XXX Note that the training mission #7 uses the server with a // XXX nTotalMaxPlayers setting of 1, and we need to handle that. pMissionParams->nMinPlayersPerTeam = 1; if (pMissionParams->nTotalMaxPlayersPerGame == 1) pMissionParams->nMaxPlayersPerTeam = 1; else pMissionParams->nMaxPlayersPerTeam = pMissionParams->nTotalMaxPlayersPerGame / pMissionParams->nTeams; #else // The maximum players per side must be no more than max per game / nTeams if (pMissionParams->nMaxPlayersPerTeam > pMissionParams->nTotalMaxPlayersPerGame / pMissionParams->nTeams) pMissionParams->nMaxPlayersPerTeam = pMissionParams->nTotalMaxPlayersPerGame / pMissionParams->nTeams; if (pMissionParams->nMinPlayersPerTeam > pMissionParams->nMaxPlayersPerTeam) pMissionParams->nMinPlayersPerTeam = pMissionParams->nMaxPlayersPerTeam; #endif // defined(ALLSRV_STANDALONE) // make sure params are valid, if not tell user why const char * szInvalid = pMissionParams->Invalid(); if (szInvalid) return Error(szInvalid); // Creation through this method always indicates object model created // KGJV : hack fix for AllSrvUI created game // since bObjectModelCreated isnt exposed thru the AGC interface we use bAllowEmptyTeams // so if bAllowEmptyTeams, game will be like a player created game pMissionParams->bObjectModelCreated = !pMissionParams->bAllowEmptyTeams; // Get the story text of the specified AGCGameParameters object CComBSTR bstrStoryText; RETURN_FAILED(pGameParameters->get_StoryText(&bstrStoryText)); USES_CONVERSION; const char* pszStoryText = bstrStoryText.Length() ? OLE2CA(bstrStoryText) : NULL; // // Create a new mission first // FedSrvSite * psiteFedSrv = new FedSrvSite(); CFSMission * pfsMissionNew = new CFSMission(*pMissionParams, NULL, // NULL means use description in the params psiteFedSrv, psiteFedSrv, pMissionParams, pszStoryText); if (g.fmLobby.IsConnected()) { BEGIN_PFM_CREATE(g.fmLobby, pfmNewMission, S, NEW_MISSION) END_PFM_CREATE pfmNewMission->dwIGCMissionID = pfsMissionNew->GetIGCMission()->GetMissionID(); g.fmLobby.SendMessages(g.fmLobby.GetServerConnection(), FM_GUARANTEED, FM_FLUSH); } return S_OK; }