mainLoop.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "app/mainLoop.h"
  23. #include "app/game.h"
  24. #include "platform/platformTimer.h"
  25. #include "platform/platformRedBook.h"
  26. #include "platform/platformVolume.h"
  27. #include "platform/platformMemory.h"
  28. #include "platform/platformTimer.h"
  29. #include "platform/platformNet.h"
  30. #include "platform/nativeDialogs/fileDialog.h"
  31. #include "platform/threads/thread.h"
  32. #include "core/module.h"
  33. #include "core/threadStatic.h"
  34. #include "core/iTickable.h"
  35. #include "core/stream/fileStream.h"
  36. #include "windowManager/platformWindowMgr.h"
  37. #include "core/util/journal/process.h"
  38. #include "util/fpsTracker.h"
  39. #include "console/debugOutputConsumer.h"
  40. #include "console/consoleTypes.h"
  41. #include "console/engineAPI.h"
  42. #include "gfx/bitmap/gBitmap.h"
  43. #include "gfx/gFont.h"
  44. #include "gfx/video/videoCapture.h"
  45. #include "gfx/gfxTextureManager.h"
  46. #include "sim/netStringTable.h"
  47. #include "sim/actionMap.h"
  48. #include "sim/netInterface.h"
  49. #include "util/sampler.h"
  50. #include "platform/threads/threadPool.h"
  51. // For the TickMs define... fix this for T2D...
  52. #include "T3D/gameBase/processList.h"
  53. #include "cinterface/cinterface.h"
  54. #ifdef TORQUE_ENABLE_VFS
  55. #include "platform/platformVFS.h"
  56. #endif
  57. #ifndef _MODULE_MANAGER_H
  58. #include "module/moduleManager.h"
  59. #endif
  60. #ifndef _ASSET_MANAGER_H_
  61. #include "assets/assetManager.h"
  62. #endif
  63. DITTS( F32, gTimeScale, 1.0 );
  64. DITTS( U32, gTimeAdvance, 0 );
  65. DITTS( U32, gFrameSkip, 0 );
  66. extern S32 sgBackgroundProcessSleepTime;
  67. extern S32 sgTimeManagerProcessInterval;
  68. extern FPSTracker gFPS;
  69. TimeManager* tm = NULL;
  70. static bool gRequiresRestart = false;
  71. #ifdef TORQUE_DEBUG
  72. /// Temporary timer used to time startup times.
  73. static PlatformTimer* gStartupTimer;
  74. #endif
  75. #if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
  76. StringTableEntry gMiniDumpDir;
  77. StringTableEntry gMiniDumpExec;
  78. StringTableEntry gMiniDumpParams;
  79. StringTableEntry gMiniDumpExecDir;
  80. #endif
  81. namespace engineAPI
  82. {
  83. // This is the magic switch for deciding which interop the engine
  84. // should use. It will go away when we drop the console system
  85. // entirely but for now it is necessary for several behaviors that
  86. // differ between the interops to decide what to do.
  87. bool gUseConsoleInterop = true;
  88. bool gIsInitialized = false;
  89. }
  90. // The following are some tricks to make the memory leak checker run after global
  91. // dtors have executed by placing some code in the termination segments.
  92. #if defined( TORQUE_DEBUG ) && !defined( TORQUE_DISABLE_MEMORY_MANAGER )
  93. #ifdef TORQUE_COMPILER_VISUALC
  94. # pragma data_seg( ".CRT$XTU" )
  95. static void* sCheckMemBeforeTermination = &Memory::ensureAllFreed;
  96. # pragma data_seg()
  97. #elif defined( TORQUE_COMPILER_GCC )
  98. __attribute__ ( ( destructor ) ) static void _ensureAllFreed()
  99. {
  100. Memory::ensureAllFreed();
  101. }
  102. #endif
  103. #endif
  104. // Process a time event and update all sub-processes
  105. void processTimeEvent(S32 elapsedTime)
  106. {
  107. PROFILE_START(ProcessTimeEvent);
  108. // If recording a video and not playinb back a journal, override the elapsedTime
  109. if (VIDCAP->isRecording() && !Journal::IsPlaying())
  110. elapsedTime = VIDCAP->getMsPerFrame();
  111. // cap the elapsed time to one second
  112. // if it's more than that we're probably in a bad catch-up situation
  113. if(elapsedTime > 1024)
  114. elapsedTime = 1024;
  115. U32 timeDelta;
  116. if(ATTS(gTimeAdvance))
  117. timeDelta = ATTS(gTimeAdvance);
  118. else
  119. timeDelta = (U32) (elapsedTime * ATTS(gTimeScale));
  120. Platform::advanceTime(elapsedTime);
  121. // Don't build up more time than a single tick... this makes the sim
  122. // frame rate dependent but is a useful hack for singleplayer.
  123. if ( ATTS(gFrameSkip) )
  124. if ( timeDelta > TickMs )
  125. timeDelta = TickMs;
  126. bool tickPass;
  127. PROFILE_START(ServerProcess);
  128. tickPass = serverProcess(timeDelta);
  129. PROFILE_END();
  130. PROFILE_START(ServerNetProcess);
  131. // only send packets if a tick happened
  132. if(tickPass)
  133. GNet->processServer();
  134. // Used to indicate if server was just ticked.
  135. Con::setBoolVariable( "$pref::hasServerTicked", tickPass );
  136. PROFILE_END();
  137. PROFILE_START(SimAdvanceTime);
  138. Sim::advanceTime(timeDelta);
  139. PROFILE_END();
  140. PROFILE_START(ClientProcess);
  141. tickPass = clientProcess(timeDelta);
  142. // Used to indicate if client was just ticked.
  143. Con::setBoolVariable( "$pref::hasClientTicked", tickPass );
  144. PROFILE_END_NAMED(ClientProcess);
  145. PROFILE_START(ClientNetProcess);
  146. if(tickPass)
  147. GNet->processClient();
  148. PROFILE_END();
  149. GNet->checkTimeouts();
  150. gFPS.update();
  151. // Give the texture manager a chance to cleanup any
  152. // textures that haven't been referenced for a bit.
  153. if( GFX )
  154. TEXMGR->cleanupCache( 5 );
  155. PROFILE_END();
  156. // Update the console time
  157. Con::setFloatVariable("Sim::Time",F32(Platform::getVirtualMilliseconds()) / 1000);
  158. }
  159. void StandardMainLoop::init()
  160. {
  161. #ifdef TORQUE_DEBUG
  162. gStartupTimer = PlatformTimer::create();
  163. #endif
  164. #ifdef TORQUE_DEBUG_GUARD
  165. Memory::flagCurrentAllocs( Memory::FLAG_Global );
  166. #endif
  167. Platform::setMathControlStateKnown();
  168. // Asserts should be created FIRST
  169. PlatformAssert::create();
  170. ManagedSingleton< ThreadManager >::createSingleton();
  171. FrameAllocator::init(TORQUE_FRAME_SIZE); // See comments in torqueConfig.h
  172. // Yell if we can't initialize the network.
  173. if(!Net::init())
  174. {
  175. AssertISV(false, "StandardMainLoop::initCore - could not initialize networking!");
  176. }
  177. _StringTable::create();
  178. // Set up the resource manager and get some basic file types in it.
  179. Con::init();
  180. Platform::initConsole();
  181. NetStringTable::create();
  182. // Use debug output logging on the Xbox and OSX builds
  183. #if defined( _XBOX ) || defined( TORQUE_OS_MAC )
  184. DebugOutputConsumer::init();
  185. #endif
  186. // init Filesystem first, so we can actually log errors for all components that follow
  187. Platform::FS::InstallFileSystems(); // install all drives for now until we have everything using the volume stuff
  188. Platform::FS::MountDefaults();
  189. // Set our working directory.
  190. Torque::FS::SetCwd( "game:/" );
  191. // Set our working directory.
  192. Platform::setCurrentDirectory( Platform::getMainDotCsDir() );
  193. Processor::init();
  194. Math::init();
  195. Platform::init(); // platform specific initialization
  196. RedBook::init();
  197. Platform::initConsole();
  198. ThreadPool::GlobalThreadPool::createSingleton();
  199. // Set engineAPI initialized to true
  200. engineAPI::gIsInitialized = true;
  201. // Initialize modules.
  202. EngineModuleManager::initializeSystem();
  203. // Initialise ITickable.
  204. #ifdef TORQUE_TGB_ONLY
  205. ITickable::init( 4 );
  206. #endif
  207. #ifdef TORQUE_ENABLE_VFS
  208. // [tom, 10/28/2006] Load the VFS here so that it stays loaded
  209. Zip::ZipArchive *vfs = openEmbeddedVFSArchive();
  210. gResourceManager->addVFSRoot(vfs);
  211. #endif
  212. Con::addVariable("timeScale", TypeF32, &ATTS(gTimeScale), "Animation time scale.\n"
  213. "@ingroup platform");
  214. Con::addVariable("timeAdvance", TypeS32, &ATTS(gTimeAdvance), "The speed at which system processing time advances.\n"
  215. "@ingroup platform");
  216. Con::addVariable("frameSkip", TypeS32, &ATTS(gFrameSkip), "Sets the number of frames to skip while rendering the scene.\n"
  217. "@ingroup platform");
  218. Con::setVariable( "defaultGame", StringTable->insert("scripts") );
  219. Con::addVariable( "_forceAllMainThread", TypeBool, &ThreadPool::getForceAllMainThread(), "Force all work items to execute on main thread. turns this into a single-threaded system. Primarily useful to find whether malfunctions are caused by parallel execution or not.\n"
  220. "@ingroup platform" );
  221. #if defined( TORQUE_MINIDUMP ) && defined( TORQUE_RELEASE )
  222. Con::addVariable("MiniDump::Dir", TypeString, &gMiniDumpDir);
  223. Con::addVariable("MiniDump::Exec", TypeString, &gMiniDumpExec);
  224. Con::addVariable("MiniDump::Params", TypeString, &gMiniDumpParams);
  225. Con::addVariable("MiniDump::ExecDir", TypeString, &gMiniDumpExecDir);
  226. #endif
  227. // Register the module manager.
  228. ModuleDatabase.registerObject("ModuleDatabase");
  229. // Register the asset database.
  230. AssetDatabase.registerObject("AssetDatabase");
  231. // Register the asset database as a module listener.
  232. ModuleDatabase.addListener(&AssetDatabase);
  233. ActionMap* globalMap = new ActionMap;
  234. globalMap->registerObject("GlobalActionMap");
  235. Sim::getActiveActionMapSet()->pushObject(globalMap);
  236. // Do this before we init the process so that process notifiees can get the time manager
  237. tm = new TimeManager;
  238. tm->timeEvent.notify(&::processTimeEvent);
  239. // Start up the Input Event Manager
  240. INPUTMGR->start();
  241. Sampler::init();
  242. // Hook in for UDP notification
  243. Net::getPacketReceiveEvent().notify(GNet, &NetInterface::processPacketReceiveEvent);
  244. #ifdef TORQUE_DEBUG_GUARD
  245. Memory::flagCurrentAllocs( Memory::FLAG_Static );
  246. #endif
  247. }
  248. void StandardMainLoop::shutdown()
  249. {
  250. // Stop the Input Event Manager
  251. INPUTMGR->stop();
  252. delete tm;
  253. preShutdown();
  254. // Unregister the module database.
  255. ModuleDatabase.unregisterObject();
  256. // Unregister the asset database.
  257. AssetDatabase.unregisterObject();
  258. // Shut down modules.
  259. EngineModuleManager::shutdownSystem();
  260. ThreadPool::GlobalThreadPool::deleteSingleton();
  261. #ifdef TORQUE_ENABLE_VFS
  262. closeEmbeddedVFSArchive();
  263. #endif
  264. RedBook::destroy();
  265. Platform::shutdown();
  266. #if defined( _XBOX ) || defined( TORQUE_OS_MAC )
  267. DebugOutputConsumer::destroy();
  268. #endif
  269. NetStringTable::destroy();
  270. Con::shutdown();
  271. _StringTable::destroy();
  272. FrameAllocator::destroy();
  273. Net::shutdown();
  274. Sampler::destroy();
  275. ManagedSingleton< ThreadManager >::deleteSingleton();
  276. // asserts should be destroyed LAST
  277. PlatformAssert::destroy();
  278. #if defined( TORQUE_DEBUG ) && !defined( TORQUE_DISABLE_MEMORY_MANAGER )
  279. Memory::validate();
  280. #endif
  281. }
  282. void StandardMainLoop::preShutdown()
  283. {
  284. #ifdef TORQUE_TOOLS
  285. // Tools are given a chance to do pre-quit processing
  286. // - This is because for tools we like to do things such
  287. // as prompting to save changes before shutting down
  288. // and onExit is packaged which means we can't be sure
  289. // where in the shutdown namespace chain we are when using
  290. // onExit since some components of the tools may already be
  291. // destroyed that may be vital to saving changes to avoid
  292. // loss of work [1/5/2007 justind]
  293. if( Con::isFunction("onPreExit") )
  294. Con::executef( "onPreExit");
  295. #endif
  296. //exec the script onExit() function
  297. if ( Con::isFunction( "onExit" ) )
  298. Con::executef("onExit");
  299. }
  300. bool StandardMainLoop::handleCommandLine( S32 argc, const char **argv )
  301. {
  302. // Allow the window manager to process command line inputs; this is
  303. // done to let web plugin functionality happen in a fairly transparent way.
  304. PlatformWindowManager::get()->processCmdLineArgs(argc, argv);
  305. Process::handleCommandLine( argc, argv );
  306. // Set up the command line args for the console scripts...
  307. Con::setIntVariable("Game::argc", argc);
  308. U32 i;
  309. for (i = 0; i < argc; i++)
  310. Con::setVariable(avar("Game::argv%d", i), argv[i]);
  311. #ifdef TORQUE_PLAYER
  312. if(argc > 2 && dStricmp(argv[1], "-project") == 0)
  313. {
  314. char playerPath[1024];
  315. Platform::makeFullPathName(argv[2], playerPath, sizeof(playerPath));
  316. Platform::setCurrentDirectory(playerPath);
  317. argv += 2;
  318. argc -= 2;
  319. // Re-locate the game:/ asset mount.
  320. Torque::FS::Unmount( "game" );
  321. Torque::FS::Mount( "game", Platform::FS::createNativeFS( playerPath ) );
  322. }
  323. #endif
  324. // Executes an entry script file. This is "main.tscript"
  325. // by default, but any file name (with no whitespace
  326. // in it) may be run if it is specified as the first
  327. // command-line parameter. The script used, default
  328. // or otherwise, is not compiled and is loaded here
  329. // directly because the resource system restricts
  330. // access to the "root" directory.
  331. bool foundExternalMain = false;
  332. CInterface::CallMain(&foundExternalMain);
  333. if (foundExternalMain)
  334. return true;
  335. #ifdef TORQUE_ENABLE_VFS
  336. Zip::ZipArchive *vfs = openEmbeddedVFSArchive();
  337. bool useVFS = vfs != NULL;
  338. #endif
  339. Stream *mainCsStream = NULL;
  340. // The working filestream.
  341. FileStream str;
  342. const char *defaultScriptName = "main." TORQUE_SCRIPT_EXTENSION;
  343. bool useDefaultScript = true;
  344. // Check if any command-line parameters were passed (the first is just the app name).
  345. if (argc > 1)
  346. {
  347. // If so, check if the first parameter is a file to open.
  348. if ( (String::compare(argv[1], "") != 0 ) && (str.open(argv[1], Torque::FS::File::Read)) )
  349. {
  350. // If it opens, we assume it is the script to run.
  351. useDefaultScript = false;
  352. #ifdef TORQUE_ENABLE_VFS
  353. useVFS = false;
  354. #endif
  355. mainCsStream = &str;
  356. }
  357. }
  358. if (useDefaultScript)
  359. {
  360. bool success = false;
  361. #ifdef TORQUE_ENABLE_VFS
  362. if(useVFS)
  363. success = (mainCsStream = vfs->openFile(defaultScriptName, Zip::ZipArchive::Read)) != NULL;
  364. else
  365. #endif
  366. success = str.open(defaultScriptName, Torque::FS::File::Read);
  367. #if defined( TORQUE_DEBUG ) && defined (TORQUE_TOOLS) && !defined(TORQUE_DEDICATED) && !defined( _XBOX )
  368. if (!success)
  369. {
  370. OpenFileDialog ofd;
  371. FileDialogData &fdd = ofd.getData();
  372. fdd.mFilters = StringTable->insert("Main Entry Script (main." TORQUE_SCRIPT_EXTENSION ")|main." TORQUE_SCRIPT_EXTENSION "|");
  373. fdd.mTitle = StringTable->insert("Locate Game Entry Script");
  374. // Get the user's selection
  375. if( !ofd.Execute() )
  376. return false;
  377. // Process and update CWD so we can run the selected main.tscript
  378. S32 pathLen = dStrlen( fdd.mFile );
  379. FrameTemp<char> szPathCopy( pathLen + 1);
  380. dStrcpy( szPathCopy, fdd.mFile, pathLen + 1 );
  381. //forwardslash( szPathCopy );
  382. const char *path = dStrrchr(szPathCopy, '/');
  383. if(path)
  384. {
  385. U32 len = path - (const char*)szPathCopy;
  386. szPathCopy[len+1] = 0;
  387. Platform::setCurrentDirectory(szPathCopy);
  388. // Re-locate the game:/ asset mount.
  389. Torque::FS::Unmount( "game" );
  390. Torque::FS::Mount( "game", Platform::FS::createNativeFS( ( const char* ) szPathCopy ) );
  391. success = str.open(fdd.mFile, Torque::FS::File::Read);
  392. if(success)
  393. defaultScriptName = fdd.mFile;
  394. }
  395. }
  396. #endif
  397. if( !success )
  398. {
  399. char msg[1024];
  400. dSprintf(msg, sizeof(msg), "Failed to open \"%s\".", defaultScriptName);
  401. Platform::AlertOK("Error", msg);
  402. #ifdef TORQUE_ENABLE_VFS
  403. closeEmbeddedVFSArchive();
  404. #endif
  405. return false;
  406. }
  407. #ifdef TORQUE_ENABLE_VFS
  408. if(! useVFS)
  409. #endif
  410. mainCsStream = &str;
  411. }
  412. // This should rarely happen, but lets deal with
  413. // it gracefully if it does.
  414. if ( mainCsStream == NULL )
  415. return false;
  416. U32 size = mainCsStream->getStreamSize();
  417. char *script = new char[size + 1];
  418. mainCsStream->read(size, script);
  419. #ifdef TORQUE_ENABLE_VFS
  420. if(useVFS)
  421. vfs->closeFile(mainCsStream);
  422. else
  423. #endif
  424. str.close();
  425. script[size] = 0;
  426. char buffer[1024], *ptr;
  427. Platform::makeFullPathName(useDefaultScript ? defaultScriptName : argv[1], buffer, sizeof(buffer), Platform::getCurrentDirectory());
  428. ptr = dStrrchr(buffer, '/');
  429. if(ptr != NULL)
  430. *ptr = 0;
  431. Platform::setMainDotCsDir(buffer);
  432. Platform::setCurrentDirectory(buffer);
  433. Con::setVariable("TorqueScriptFileExtension", TORQUE_SCRIPT_EXTENSION);
  434. Con::evaluate(script, false, useDefaultScript ? defaultScriptName : argv[1]);
  435. delete[] script;
  436. #ifdef TORQUE_ENABLE_VFS
  437. closeEmbeddedVFSArchive();
  438. #endif
  439. return true;
  440. }
  441. bool StandardMainLoop::doMainLoop()
  442. {
  443. #ifdef TORQUE_DEBUG
  444. if( gStartupTimer )
  445. {
  446. Con::printf( "Started up in %.2f seconds...",
  447. F32( gStartupTimer->getElapsedMs() ) / 1000.f );
  448. SAFE_DELETE( gStartupTimer );
  449. }
  450. #endif
  451. bool keepRunning = true;
  452. // while(keepRunning)
  453. {
  454. tm->setBackgroundThreshold(mClamp(sgBackgroundProcessSleepTime, 1, 200));
  455. tm->setForegroundThreshold(mClamp(sgTimeManagerProcessInterval, 1, 200));
  456. // update foreground/background status
  457. if(WindowManager->getFirstWindow())
  458. {
  459. static bool lastFocus = false;
  460. bool newFocus = ( WindowManager->getFocusedWindow() != NULL );
  461. if(lastFocus != newFocus)
  462. {
  463. #ifndef TORQUE_SHIPPING
  464. Con::printf("Window focus status changed: focus: %d", newFocus);
  465. if (!newFocus)
  466. Con::printf(" Using background sleep time: %u", Platform::getBackgroundSleepTime());
  467. #endif
  468. #ifdef TORQUE_OS_MAC
  469. if (newFocus)
  470. WindowManager->getFirstWindow()->show();
  471. #endif
  472. lastFocus = newFocus;
  473. }
  474. // under the web plugin do not sleep the process when the child window loses focus as this will cripple the browser perfomance
  475. if (!Platform::getWebDeployment())
  476. tm->setBackground(!newFocus);
  477. else
  478. tm->setBackground(false);
  479. }
  480. else
  481. {
  482. tm->setBackground(false);
  483. }
  484. PROFILE_START(MainLoop);
  485. Sampler::beginFrame();
  486. if(!Process::processEvents())
  487. keepRunning = false;
  488. ThreadPool::processMainThreadWorkItems();
  489. Sampler::endFrame();
  490. ConsoleValue::resetConversionBuffer();
  491. PROFILE_END_NAMED(MainLoop);
  492. }
  493. return keepRunning;
  494. }
  495. S32 StandardMainLoop::getReturnStatus()
  496. {
  497. return Process::getReturnStatus();
  498. }
  499. void StandardMainLoop::setRestart(bool restart )
  500. {
  501. gRequiresRestart = restart;
  502. }
  503. bool StandardMainLoop::requiresRestart()
  504. {
  505. return gRequiresRestart;
  506. }