Fix: [Script] Reset instance when changing running scripts in scenario editor (#13906)

This commit is contained in:
Loïc Guilloux
2025-04-03 21:14:45 +02:00
committed by GitHub
parent 20805ba84b
commit b25daba561
3 changed files with 26 additions and 6 deletions

View File

@@ -103,8 +103,7 @@
{
Backup<CompanyID> cur_company(_current_company);
Game::instance.reset();
Game::info = nullptr;
Game::ResetInstance();
cur_company.Restore();
@@ -162,10 +161,7 @@
if (!_settings_game.script_config.game->ResetInfo(true)) {
Debug(script, 0, "After a reload, the GameScript by the name '{}' was no longer found, and removed from the list.", _settings_game.script_config.game->GetName());
_settings_game.script_config.game->Change(std::nullopt);
if (Game::instance != nullptr) {
Game::instance.reset();
Game::info = nullptr;
}
if (Game::instance != nullptr) Game::ResetInstance();
} else if (Game::instance != nullptr) {
Game::info = _settings_game.script_config.game->GetInfo();
}
@@ -234,6 +230,12 @@
return Game::scanner_library->FindLibrary(library, version);
}
/* static */ void Game::ResetInstance()
{
Game::instance.reset();
Game::info = nullptr;
}
/**
* Check whether we have an Game (library) with the exact characteristics as ci.
* @param ci the characteristics to search on (shortname and md5sum)