From d2f776ef3ee7bd78eb1daec310f3e253b8323ea0 Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 2 Jan 2012 22:44:28 +0000 Subject: [PATCH] (svn r23720) -Fix/Feature [FS#4935]: show the script debug window also when the game script crashes --- src/ai/ai_gui.cpp | 5 +++++ src/game/game_instance.cpp | 19 +++++++++++++++++++ src/game/game_instance.hpp | 1 + src/lang/english.txt | 2 +- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 1843906b67..f60233077f 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -1321,4 +1321,9 @@ void ShowAIDebugWindowIfAIError() break; } } + + GameInstance *g = Game::GetGameInstance(); + if (g != NULL && g->IsDead()) { + ShowAIDebugWindow(OWNER_DEITY); + } } diff --git a/src/game/game_instance.cpp b/src/game/game_instance.cpp index 7ab235cc77..9535c6abee 100644 --- a/src/game/game_instance.cpp +++ b/src/game/game_instance.cpp @@ -11,11 +11,13 @@ #include "../stdafx.h" #include "../debug.h" +#include "../error.h" #include "../saveload/saveload.h" #include "../script/squirrel_class.hpp" #include "../script/script_storage.hpp" +#include "../ai/ai_gui.hpp" #include "game_config.hpp" #include "game_info.hpp" #include "game_instance.hpp" @@ -196,6 +198,23 @@ ScriptInfo *GameInstance::FindLibrary(const char *library, int version) return (ScriptInfo *)Game::FindLibrary(library, version); } +void GameInstance::Died() +{ + ScriptInstance::Died(); + + ShowAIDebugWindow(OWNER_DEITY); + + const GameInfo *info = Game::GetInfo(); + if (info != NULL) { + ShowErrorMessage(STR_ERROR_AI_PLEASE_REPORT_CRASH, INVALID_STRING_ID, WL_WARNING); + + if (info->GetURL() != NULL) { + ScriptLog::Info("Please report the error to the following URL:"); + ScriptLog::Info(info->GetURL()); + } + } +} + /** * DoCommand callback function for all commands executed by Game Scripts. * @param result The result of the command. diff --git a/src/game/game_instance.hpp b/src/game/game_instance.hpp index efb67398d8..08ce344247 100644 --- a/src/game/game_instance.hpp +++ b/src/game/game_instance.hpp @@ -30,6 +30,7 @@ public: private: /* virtual */ void RegisterAPI(); + /* virtual */ void Died(); /* virtual */ CommandCallback *GetDoCommandCallback(); /* virtual */ void LoadDummyScript() {} }; diff --git a/src/lang/english.txt b/src/lang/english.txt index 3c25e87ef2..cc7a5b6647 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -3486,7 +3486,7 @@ STR_AI_GAME_SCRIPT :{BLACK}Game Scr STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Check the Game Script log STR_ERROR_AI_NO_AI_FOUND :No suitable AI found to load.{}This AI is a dummy AI and won't do anything.{}You can download several AIs via the 'Online Content' system -STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}One of the running AIs crashed. Please report this to the AI author with a screenshot of the AI Debug Window +STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}One of the running scripts crashed. Please report this to the script author with a screenshot of the AI / GameScript Debug Window STR_ERROR_AI_DEBUG_SERVER_ONLY :{YELLOW}AI / GameScript Debug window is only available for the server # AI configuration window