IGameRef CGameStartup::Init(SSystemInitParams &startupParams) { if (!InitFramework(startupParams)) { return nullptr; } startupParams.pSystem = GetISystem(); IGameRef pOut = Reset(); if (!m_pFramework->CompleteInit()) { pOut->Shutdown(); return nullptr; } if (startupParams.bExecuteCommandLine) GetISystem()->ExecuteCommandLine(); GetISystem()->GetISystemEventDispatcher()->RegisterListener(this); GetISystem()->RegisterErrorObserver(&m_errorObsever); #if defined(CRY_UNIT_TESTING) #if defined(_LIB) CryUnitTest::Test *pTest = CryUnitTest::Test::m_pFirst; for (; pTest != 0; pTest = pTest->m_pNext) { CryUnitTest::IUnitTestManager *pTestManager = GetISystem()->GetITestSystem()->GetIUnitTestManager(); if (pTestManager) { pTest->m_unitTestInfo.module = "StaticBinary"; pTestManager->CreateTest( pTest->m_unitTestInfo ); } } #endif CryUnitTest::IUnitTestManager *pTestManager = GetISystem()->GetITestSystem()->GetIUnitTestManager(); if (pTestManager) { const ICmdLineArg* pSkipUnitTest = GetISystem()->GetICmdLine()->FindArg(eCLAT_Pre, "skip_unit_tests"); if (!pSkipUnitTest) { const ICmdLineArg* pUseUnitTestExcelReporter = GetISystem()->GetICmdLine()->FindArg(eCLAT_Pre, "use_unit_test_excel_reporter"); if (pUseUnitTestExcelReporter) { GetISystem()->GetITestSystem()->GetIUnitTestManager()->RunAllTests(CryUnitTest::ExcelReporter); } else { GetISystem()->GetITestSystem()->GetIUnitTestManager()->RunAllTests(CryUnitTest::MinimalReporter); } } } #endif return pOut; }
IGameRef CGameStartup::Init(SSystemInitParams &startupParams) { MEMSTAT_CONTEXT(EMemStatContextTypes::MSC_Other, 0, "Game startup initialisation"); #if defined(CVARS_WHITELIST) startupParams.pCVarsWhitelist = &g_CVarsWhiteList; #endif // defined(CVARS_WHITELIST) startupParams.pGameStartup = this; if (!InitFramework(startupParams)) { return 0; } InlineInitializationProcessing("CGameStartup::Init"); LOADING_TIME_PROFILE_SECTION(m_pFramework->GetISystem()); ISystem* pSystem = m_pFramework->GetISystem(); startupParams.pSystem = pSystem; const ICmdLineArg* pSvBind = gEnv->pSystem->GetICmdLine()->FindArg(eCLAT_Pre, "sv_bind"); IConsole* pConsole = pSystem->GetIConsole(); if ((pSvBind != NULL) && (pConsole != NULL)) { string command = pSvBind->GetName() + string(" ") + pSvBind->GetValue(); pConsole->ExecuteString(command.c_str(), true, false); } #if defined(ENABLE_STATS_AGENT) const ICmdLineArg *pPipeArg = pSystem->GetICmdLine()->FindArg(eCLAT_Pre,"lt_pipename"); CStatsAgent::CreatePipe( pPipeArg ); #endif REGISTER_COMMAND("g_loadMod", CGameStartupStatic::RequestLoadMod,VF_NULL,""); REGISTER_COMMAND("g_unloadMod", CGameStartupStatic::RequestUnloadMod, VF_NULL, ""); // load the appropriate game/mod #if !defined(_RELEASE) const ICmdLineArg *pModArg = pSystem->GetICmdLine()->FindArg(eCLAT_Pre,"MOD"); #else const ICmdLineArg *pModArg = NULL; #endif // !defined(_RELEASE) InlineInitializationProcessing("CGameStartup::Init LoadLocalizationData"); IGameRef pOut; if (pModArg && (*pModArg->GetValue() != 0) && (pSystem->IsMODValid(pModArg->GetValue()))) { const char* pModName = pModArg->GetValue(); assert(pModName); pOut = Reset(pModName); } else { pOut = Reset(GAME_NAME); } if (!m_pFramework->CompleteInit()) { pOut->Shutdown(); return 0; } InlineInitializationProcessing("CGameStartup::Init FrameworkCompleteInit"); // should be after init game (should be executed even if there is no game) if(startupParams.bExecuteCommandLine) pSystem->ExecuteCommandLine(); pSystem->GetISystemEventDispatcher()->RegisterListener(this); // Creates and starts the realtime update system listener. if (pSystem->IsDevMode()) { CGameRealtimeRemoteUpdateListener::GetGameRealtimeRemoteUpdateListener().Enable(true); } GCOV_FLUSH; if (ISystem *pSystem = gEnv ? GetISystem() : NULL) { pSystem->RegisterErrorObserver(&m_errorObsever); pSystem->RegisterWindowMessageHandler(this); } else { CryLogAlways("failed to find ISystem to register error observer"); assert(0); } InlineInitializationProcessing("CGameStartup::Init End"); #if defined(CRY_UNIT_TESTING) // Register All unit tests of this module. #if defined(_LIB) if(gEnv->pSystem) { CryUnitTest::Test *pTest = CryUnitTest::Test::m_pFirst; for (; pTest != 0; pTest = pTest->m_pNext) { CryUnitTest::IUnitTestManager *pTestManager = gEnv->pSystem->GetITestSystem()->GetIUnitTestManager(); if (pTestManager) { pTest->m_unitTestInfo.module = "StaticBinary"; pTestManager->CreateTest( pTest->m_unitTestInfo ); } } } #endif // run unit tests CryUnitTest::IUnitTestManager *pTestManager = (gEnv && gEnv->pSystem) ? gEnv->pSystem->GetITestSystem()->GetIUnitTestManager() : NULL; if (pTestManager) { const ICmdLineArg* pSkipUnitTest = gEnv->pSystem->GetICmdLine()->FindArg(eCLAT_Pre, "skip_unit_tests"); if(pSkipUnitTest == NULL) { const ICmdLineArg* pUseUnitTestExcelReporter = gEnv->pSystem->GetICmdLine()->FindArg(eCLAT_Pre, "use_unit_test_excel_reporter"); if(pUseUnitTestExcelReporter) { gEnv->pSystem->GetITestSystem()->GetIUnitTestManager()->RunAllTests(CryUnitTest::ExcelReporter); } else // default is the minimal reporter { gEnv->pSystem->GetITestSystem()->GetIUnitTestManager()->RunAllTests(CryUnitTest::MinimalReporter); } } } #endif // CRY_UNIT_TESTING assert(gEnv); PREFAST_ASSUME(gEnv); GetISystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_RANDOM_SEED, (UINT_PTR)gEnv->pTimer->GetAsyncTime().GetMicroSecondsAsInt64(), 0); return pOut; }