1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-10 22:31:40 +02:00

Do not create ENGINE in headless mode

This commit is contained in:
Ivan Savenko
2025-03-12 13:32:22 +00:00
parent eaad6f9ce0
commit 4684756c49
3 changed files with 12 additions and 16 deletions

View File

@@ -58,7 +58,9 @@ ObjectConstruction::~ObjectConstruction()
ENGINE->captureChildren = !ENGINE->createdObj.empty();
}
void GameEngine::init()
GameEngine::GameEngine()
: captureChildren(false)
, fakeStatusBar(std::make_shared<EmptyStatusBar>())
{
inGuiThread = true;
@@ -133,12 +135,6 @@ void GameEngine::updateFrame()
ENGINE->cursor().update();
}
GameEngine::GameEngine()
: captureChildren(false)
, fakeStatusBar(std::make_shared<EmptyStatusBar>())
{
}
GameEngine::~GameEngine()
{
// enforce deletion order on shutdown

View File

@@ -108,7 +108,6 @@ public:
GameEngine();
~GameEngine();
void init();
[[noreturn]] void mainLoop();
/// called whenever SDL_WINDOWEVENT_RESTORED is reported or the user selects a different resolution, requiring to center/resize all windows

View File

@@ -24,7 +24,6 @@
#include "../client/mainmenu/CMainMenu.h"
#include "../client/render/Graphics.h"
#include "../client/render/IRenderHandler.h"
#include "../client/render/IScreenHandler.h"
#include "../client/windows/CMessage.h"
#include "../client/windows/InfoWindows.h"
@@ -294,13 +293,13 @@ int main(int argc, char * argv[])
srand ( (unsigned int)time(nullptr) );
ENGINE = std::make_unique<GameEngine>();
if(!settings["session"]["headless"].Bool())
ENGINE->init();
ENGINE = std::make_unique<GameEngine>();
GAME = std::make_unique<GameInstance>();
ENGINE->setEngineUser(GAME.get());
if (ENGINE)
ENGINE->setEngineUser(GAME.get());
#ifndef VCMI_NO_THREADED_LOAD
//we can properly play intro only in the main thread, so we have to move loading to the separate thread
@@ -331,7 +330,7 @@ int main(int argc, char * argv[])
handleFatalError(criticalInitializationError.value(), false);
}
if(!settings["session"]["headless"].Bool())
if (ENGINE)
{
pomtime.getDiff();
graphics = new Graphics(); // should be before curh
@@ -380,7 +379,7 @@ int main(int argc, char * argv[])
try
{
if(!settings["session"]["headless"].Bool())
if (ENGINE)
{
checkForModLoadingFailure();
ENGINE->mainLoop();
@@ -396,6 +395,7 @@ int main(int argc, char * argv[])
catch (const GameShutdownException & )
{
// no-op - just break out of main loop
logGlobal->info("Main loop termination requested");
}
GAME->server().endNetwork();
@@ -405,7 +405,8 @@ int main(int argc, char * argv[])
if(GAME->server().client)
GAME->server().endGameplay();
ENGINE->windows().clear();
if (ENGINE)
ENGINE->windows().clear();
}
GAME.reset();