1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Moved main loop to game engine class

This commit is contained in:
Ivan Savenko
2025-03-03 20:30:15 +00:00
parent 222b73bbcd
commit f8c1d217d4
3 changed files with 31 additions and 41 deletions

View File

@@ -68,11 +68,7 @@ namespace po_style = boost::program_options::command_line_style;
static std::atomic<bool> headlessQuit = false;
static std::optional<std::string> criticalInitializationError;
#ifndef VCMI_IOS
void processCommand(const std::string &message);
#endif
[[noreturn]] static void quitApplication();
static void mainLoop();
static CBasicLogConfigurator *logConfig;
@@ -387,12 +383,15 @@ int main(int argc, char * argv[])
GAME->mainmenu()->playMusic();
}
std::vector<std::string> names;
#ifndef VCMI_UNIX
// on Linux, name of main thread is also name of our process. Which we don't want to change
setThreadName("MainGUI");
#endif
if(!settings["session"]["headless"].Bool())
{
checkForModLoadingFailure();
mainLoop();
ENGINE->mainLoop();
}
else
{
@@ -404,23 +403,6 @@ int main(int argc, char * argv[])
quitApplication();
}
return 0;
}
static void mainLoop()
{
#ifndef VCMI_UNIX
// on Linux, name of main thread is also name of our process. Which we don't want to change
setThreadName("MainGUI");
#endif
while(1) //main SDL events loop
{
ENGINE->input().fetchEvents();
ENGINE->renderFrame();
}
}
[[noreturn]] static void quitApplicationImmediately(int error_code)
{
// Perform quick exit without executing static destructors and let OS cleanup anything that we did not