1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-18 01:42:38 +01:00

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

@@ -173,8 +173,21 @@ struct ScriptListWindow : public Window {
std::advance(it, this->selected);
GetConfig(slot)->Change(it->second->GetName(), it->second->GetVersion());
}
if (_game_mode == GM_EDITOR) {
if (slot == OWNER_DEITY) {
if (Game::GetInstance() != nullptr) Game::ResetInstance();
Game::StartNew();
} else {
Company *c = Company::GetIfValid(slot);
if (c != nullptr && c->ai_instance != nullptr) {
c->ai_instance.reset();
AI::StartNew(slot);
}
}
}
InvalidateWindowData(WC_GAME_OPTIONS, slot == OWNER_DEITY ? WN_GAME_OPTIONS_GS : WN_GAME_OPTIONS_AI);
InvalidateWindowClassesData(WC_SCRIPT_SETTINGS);
InvalidateWindowClassesData(WC_SCRIPT_DEBUG, -1);
CloseWindowByClass(WC_QUERY_STRING);
InvalidateWindowClassesData(WC_TEXTFILE);
}