Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/ps/GameSetup/GameSetup.cpp
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | |||||
#include "ps/VisualReplay.h" | #include "ps/VisualReplay.h" | ||||
#include "ps/World.h" | #include "ps/World.h" | ||||
#include "renderer/Renderer.h" | #include "renderer/Renderer.h" | ||||
#include "renderer/VertexBufferManager.h" | #include "renderer/VertexBufferManager.h" | ||||
#include "renderer/ModelRenderer.h" | #include "renderer/ModelRenderer.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
#include "scriptinterface/ScriptStats.h" | #include "scriptinterface/ScriptStats.h" | ||||
#include "scriptinterface/ScriptContext.h" | |||||
#include "scriptinterface/ScriptConversions.h" | #include "scriptinterface/ScriptConversions.h" | ||||
#include "scriptinterface/ScriptRuntime.h" | |||||
#include "simulation2/Simulation2.h" | #include "simulation2/Simulation2.h" | ||||
#include "lobby/IXmppClient.h" | #include "lobby/IXmppClient.h" | ||||
#include "soundmanager/scripting/JSInterface_Sound.h" | #include "soundmanager/scripting/JSInterface_Sound.h" | ||||
#include "soundmanager/ISoundManager.h" | #include "soundmanager/ISoundManager.h" | ||||
#include "tools/atlas/GameInterface/GameLoop.h" | #include "tools/atlas/GameInterface/GameLoop.h" | ||||
#include "tools/atlas/GameInterface/View.h" | #include "tools/atlas/GameInterface/View.h" | ||||
#if !(OS_WIN || OS_MACOSX || OS_ANDROID) // assume all other platforms use X11 for wxWidgets | #if !(OS_WIN || OS_MACOSX || OS_ANDROID) // assume all other platforms use X11 for wxWidgets | ||||
Show All 14 Lines | |||||
ERROR_TYPE(System, SDLInitFailed); | ERROR_TYPE(System, SDLInitFailed); | ||||
ERROR_TYPE(System, VmodeFailed); | ERROR_TYPE(System, VmodeFailed); | ||||
ERROR_TYPE(System, RequiredExtensionsMissing); | ERROR_TYPE(System, RequiredExtensionsMissing); | ||||
bool g_DoRenderGui = true; | bool g_DoRenderGui = true; | ||||
bool g_DoRenderLogger = true; | bool g_DoRenderLogger = true; | ||||
bool g_DoRenderCursor = true; | bool g_DoRenderCursor = true; | ||||
thread_local shared_ptr<ScriptRuntime> g_ScriptRuntime; | thread_local shared_ptr<ScriptContext> g_ScriptContext; | ||||
static const int SANE_TEX_QUALITY_DEFAULT = 5; // keep in sync with code | static const int SANE_TEX_QUALITY_DEFAULT = 5; // keep in sync with code | ||||
static const CStr g_EventNameGameLoadProgress = "GameLoadProgress"; | static const CStr g_EventNameGameLoadProgress = "GameLoadProgress"; | ||||
bool g_InDevelopmentCopy; | bool g_InDevelopmentCopy; | ||||
bool g_CheckedIfInDevelopmentCopy = false; | bool g_CheckedIfInDevelopmentCopy = false; | ||||
▲ Show 20 Lines • Show All 599 Lines • ▼ Show 20 Lines | from_config: | ||||
TIMER_BEGIN(L"shutdown ConfigDB"); | TIMER_BEGIN(L"shutdown ConfigDB"); | ||||
delete &g_ConfigDB; | delete &g_ConfigDB; | ||||
TIMER_END(L"shutdown ConfigDB"); | TIMER_END(L"shutdown ConfigDB"); | ||||
SAFE_DELETE(g_Console); | SAFE_DELETE(g_Console); | ||||
// This is needed to ensure that no callbacks from the JSAPI try to use | // This is needed to ensure that no callbacks from the JSAPI try to use | ||||
// the profiler when it's already destructed | // the profiler when it's already destructed | ||||
g_ScriptRuntime.reset(); | g_ScriptContext.reset(); | ||||
// resource | // resource | ||||
// first shut down all resource owners, and then the handle manager. | // first shut down all resource owners, and then the handle manager. | ||||
TIMER_BEGIN(L"resource modules"); | TIMER_BEGIN(L"resource modules"); | ||||
ISoundManager::SetEnabled(false); | ISoundManager::SetEnabled(false); | ||||
g_VFS.reset(); | g_VFS.reset(); | ||||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | bool Init(const CmdLineArgs& args, int flags) | ||||
// Set up the console early, so that debugging | // Set up the console early, so that debugging | ||||
// messages can be logged to it. (The console's size | // messages can be logged to it. (The console's size | ||||
// and fonts are set later in InitPs()) | // and fonts are set later in InitPs()) | ||||
g_Console = new CConsole(); | g_Console = new CConsole(); | ||||
// g_ConfigDB, command line args, globals | // g_ConfigDB, command line args, globals | ||||
CONFIG_Init(args); | CONFIG_Init(args); | ||||
// Using a global object for the runtime is a workaround until Simulation and AI use | // Using a global object for the context is a workaround until Simulation and AI use | ||||
// their own threads and also their own runtimes. | // their own threads and also their own contexts. | ||||
const int runtimeSize = 384 * 1024 * 1024; | const int contextSize = 384 * 1024 * 1024; | ||||
const int heapGrowthBytesGCTrigger = 20 * 1024 * 1024; | const int heapGrowthBytesGCTrigger = 20 * 1024 * 1024; | ||||
g_ScriptRuntime = ScriptRuntime::CreateRuntime(runtimeSize, heapGrowthBytesGCTrigger); | g_ScriptContext = ScriptContext::CreateContext(contextSize, heapGrowthBytesGCTrigger); | ||||
Mod::CacheEnabledModVersions(g_ScriptRuntime); | Mod::CacheEnabledModVersions(g_ScriptContext); | ||||
// Special command-line mode to dump the entity schemas instead of running the game. | // 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 | // (This must be done after loading VFS etc, but should be done before wasting time | ||||
// on anything else.) | // on anything else.) | ||||
if (args.Has("dumpSchema")) | if (args.Has("dumpSchema")) | ||||
{ | { | ||||
CSimulation2 sim(NULL, g_ScriptRuntime, NULL); | CSimulation2 sim(NULL, g_ScriptContext, NULL); | ||||
sim.LoadDefaultScripts(); | sim.LoadDefaultScripts(); | ||||
std::ofstream f("entity.rng", std::ios_base::out | std::ios_base::trunc); | std::ofstream f("entity.rng", std::ios_base::out | std::ios_base::trunc); | ||||
f << sim.GenerateSchema(); | f << sim.GenerateSchema(); | ||||
std::cout << "Generated entity.rng\n"; | std::cout << "Generated entity.rng\n"; | ||||
exit(0); | exit(0); | ||||
} | } | ||||
CNetHost::Initialize(); | CNetHost::Initialize(); | ||||
▲ Show 20 Lines • Show All 723 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator