Changeset View
Changeset View
Standalone View
Standalone View
source/ps/GameSetup/GameSetup.cpp
Show First 20 Lines • Show All 893 Lines • ▼ Show 20 Lines | bool Init(const CmdLineArgs& args, int flags) | ||||
// Using a global object for the runtime is a workaround until Simulation and AI use | // Using a global object for the runtime is a workaround until Simulation and AI use | ||||
// their own threads and also their own runtimes. | // their own threads and also their own runtimes. | ||||
const int runtimeSize = 384 * 1024 * 1024; | const int runtimeSize = 384 * 1024 * 1024; | ||||
const int heapGrowthBytesGCTrigger = 20 * 1024 * 1024; | const int heapGrowthBytesGCTrigger = 20 * 1024 * 1024; | ||||
g_ScriptRuntime = ScriptInterface::CreateRuntime(shared_ptr<ScriptRuntime>(), runtimeSize, heapGrowthBytesGCTrigger); | g_ScriptRuntime = ScriptInterface::CreateRuntime(shared_ptr<ScriptRuntime>(), runtimeSize, heapGrowthBytesGCTrigger); | ||||
Mod::CacheEnabledModVersions(g_ScriptRuntime); | Mod::CacheEnabledModVersions(g_ScriptRuntime); | ||||
// Special command-line mode to dump the entity schemas instead of running the game. | |||||
// (This must be done after loading VFS etc, but should be done before wasting time | |||||
// on anything else.) | |||||
if (args.Has("dumpSchema")) | |||||
{ | |||||
CSimulation2 sim(NULL, g_ScriptRuntime, NULL); | |||||
sim.LoadDefaultScripts(); | |||||
std::ofstream f("entity.rng", std::ios_base::out | std::ios_base::trunc); | |||||
f << sim.GenerateSchema(); | |||||
std::cout << "Generated entity.rng\n"; | |||||
exit(0); | |||||
} | |||||
CNetHost::Initialize(); | |||||
#if CONFIG2_AUDIO | |||||
if (!args.Has("autostart-nonvisual")) | |||||
ISoundManager::CreateSoundManager(); | |||||
#endif | |||||
// Check if there are mods specified on the command line, | // Check if there are mods specified on the command line, | ||||
// or if we already set the mods (~INIT_MODS), | // or if we already set the mods (~INIT_MODS), | ||||
// else check if there are mods that should be loaded specified | // else check if there are mods that should be loaded specified | ||||
// in the config and load those (by aborting init and restarting | // in the config and load those (by aborting init and restarting | ||||
// the engine). | // the engine). | ||||
if (!args.Has("mod") && (flags & INIT_MODS) == INIT_MODS) | if (!args.Has("mod") && (flags & INIT_MODS) == INIT_MODS) | ||||
{ | { | ||||
CStr modstring; | CStr modstring; | ||||
CFG_GET_VAL("mod.enabledmods", modstring); | CFG_GET_VAL("mod.enabledmods", modstring); | ||||
if (!modstring.empty()) | if (!modstring.empty()) | ||||
{ | { | ||||
std::vector<CStr> mods; | std::vector<CStr> mods; | ||||
boost::split(mods, modstring, boost::is_any_of(" "), boost::token_compress_on); | boost::split(mods, modstring, boost::is_any_of(" "), boost::token_compress_on); | ||||
std::swap(g_modsLoaded, mods); | std::swap(g_modsLoaded, mods); | ||||
// Abort init and restart | // Abort init and restart | ||||
RestartEngine(); | RestartEngine(); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
// Special command-line mode to dump the entity schemas instead of running the game. | |||||
// (This must be done after loading VFS etc, but should be done before wasting time | |||||
// on anything else.) | |||||
if (args.Has("dumpSchema")) | |||||
{ | |||||
CSimulation2 sim(NULL, g_ScriptRuntime, NULL); | |||||
sim.LoadDefaultScripts(); | |||||
std::ofstream f("entity.rng", std::ios_base::out | std::ios_base::trunc); | |||||
f << sim.GenerateSchema(); | |||||
std::cout << "Generated entity.rng\n"; | |||||
exit(0); | |||||
} | |||||
CNetHost::Initialize(); | |||||
#if CONFIG2_AUDIO | |||||
if (!args.Has("autostart-nonvisual")) | |||||
ISoundManager::CreateSoundManager(); | |||||
#endif | |||||
new L10n; | new L10n; | ||||
// Optionally start profiler HTTP output automatically | // Optionally start profiler HTTP output automatically | ||||
// (By default it's only enabled by a hotkey, for security/performance) | // (By default it's only enabled by a hotkey, for security/performance) | ||||
bool profilerHTTPEnable = false; | bool profilerHTTPEnable = false; | ||||
CFG_GET_VAL("profiler2.autoenable", profilerHTTPEnable); | CFG_GET_VAL("profiler2.autoenable", profilerHTTPEnable); | ||||
if (profilerHTTPEnable) | if (profilerHTTPEnable) | ||||
g_Profiler2.EnableHTTP(); | g_Profiler2.EnableHTTP(); | ||||
▲ Show 20 Lines • Show All 688 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator