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; }
/* * Allocator for IO::Trace * * Wraps an io_trace_t struct, opens a dtrace framework handle and initializes an empty * aggregation buffer */ static VALUE rb_io_trace_alloc(VALUE obj) { VALUE trace; int err; io_trace_t* ts; trace = Data_Make_Struct(obj, io_trace_t, rb_io_trace_mark, rb_io_trace_free, ts); ts->stream = Qnil; ts->formatter = Qnil; ts->strategy = Qnil; ts->aggregations = Qnil; ts->closed = 1; InitFramework(ts); ts->aggregations = rb_ary_new(); return trace; }
void CSimulator::Init() { /* General configuration */ InitFramework(GetNode(m_tConfigurationRoot, "framework")); /* Initialize controllers */ InitControllers(GetNode(m_tConfigurationRoot, "controllers")); /* Create loop functions */ if(NodeExists(m_tConfigurationRoot, "loop_functions")) { /* User specified a loop_functions section in the XML */ InitLoopFunctions(GetNode(m_tConfigurationRoot, "loop_functions")); } else { /* No loop_functions in the XML */ m_pcLoopFunctions = new CLoopFunctions; } /* Physics engines */ InitPhysics(GetNode(m_tConfigurationRoot, "physics_engines")); /* Media */ InitMedia(GetNode(m_tConfigurationRoot, "media")); /* Space */ InitSpace(GetNode(m_tConfigurationRoot, "arena")); /* Call user init function */ if(NodeExists(m_tConfigurationRoot, "loop_functions")) { m_pcLoopFunctions->Init(GetNode(m_tConfigurationRoot, "loop_functions")); } /* Physics engines */ InitPhysics2(); /* Media */ InitMedia2(); /* Initialise visualization */ TConfigurationNodeIterator itVisualization; if(NodeExists(m_tConfigurationRoot, "visualization") && ((itVisualization = itVisualization.begin(&GetNode(m_tConfigurationRoot, "visualization"))) != itVisualization.end())) { InitVisualization(GetNode(m_tConfigurationRoot, "visualization")); } else { LOG << "[INFO] No visualization selected." << std::endl; m_pcVisualization = new CDefaultVisualization(); } /* Start profiling, if needed */ if(IsProfiling()) { m_pcProfiler->Start(); } }
int main (int argc, char *argv[]) { InitFramework (&argc, argv); return 0; }
IGameRef CGameStartup::Init(SSystemInitParams &startupParams) { MEMSTAT_CONTEXT(EMemStatContextTypes::MSC_Other, 0, "Game startup initialization"); LOADING("game_startup"); if (!InitFramework(startupParams)) { return 0; } // Configuration for this game ICVar *pCVar = gEnv->pConsole->GetCVar("ai_CompatibilityMode"); if (pCVar) pCVar->Set("crysis"); LOADING_TIME_PROFILE_SECTION(m_pFramework->GetISystem()); ISystem* pSystem = m_pFramework->GetISystem(); IConsole* pConsole = gEnv->pConsole; startupParams.pSystem = pSystem; #if defined(ENABLE_STATS_AGENT) const ICmdLineArg *pPipeArg = pSystem->GetICmdLine()->FindArg(eCLAT_Pre,"lt_pipename"); CStatsAgent::CreatePipe( pPipeArg ); #endif PluginManager::InitPluginManager(startupParams); PluginManager::InitPluginsBeforeFramework(); REGISTER_COMMAND("g_loadMod", RequestLoadMod,VF_NULL,""); // load the appropriate game/mod const ICmdLineArg *pModArg = pSystem->GetICmdLine()->FindArg(eCLAT_Pre,"MOD"); 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); } // Load all localized strings. LoadLocalizationData(); if (!m_pFramework->CompleteInit()) { pOut->Shutdown(); return 0; } LOADING_DONE; // should be after init game (should be executed even if there is no game) if(startupParams.bExecuteCommandLine) pSystem->ExecuteCommandLine(); pSystem->GetISystemEventDispatcher()->RegisterListener( &g_system_event_listener_game ); // Creates and starts the realtime update system listener. if (pSystem->IsDevMode()) { CGameRealtimeRemoteUpdateListener::GetGameRealtimeRemoteUpdateListener().Enable(true); } GCOV_FLUSH; if (gEnv && GetISystem()) { } else { CryLogAlways("failed to find ISystem to register error observer"); assert(0); } PluginManager::InitPluginsLast(); 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; }