summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYexo <yexo@openttd.org>2010-03-13 00:15:24 +0000
committerYexo <yexo@openttd.org>2010-03-13 00:15:24 +0000
commitdfa528d058e5499558e7fd8dca3b292851f7625a (patch)
tree7965c3366300677028430c11012a986ddf18ffc2 /src
parentd0b496feb63980b1ec9bf402b7fa2c236e07f999 (diff)
downloadopenttd-dfa528d058e5499558e7fd8dca3b292851f7625a.tar.xz
(svn r19395) -Fix [FS#3669]: the AI Debug window didn't open if an AI or library fails to compile when loading a savegame
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_gui.cpp12
-rw-r--r--src/ai/ai_gui.hpp2
-rw-r--r--src/saveload/afterload.cpp2
3 files changed, 16 insertions, 0 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index c7ff796d9..a297f74aa 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -1024,3 +1024,15 @@ void InitializeAIGui()
{
AIDebugWindow::ai_debug_company = INVALID_COMPANY;
}
+
+/** Open the AI debug window if one of the AI scripts has crashed. */
+void ShowAIDebugWindowIfAIError()
+{
+ Company *c;
+ FOR_ALL_COMPANIES(c) {
+ if (c->is_ai && c->ai_instance->IsDead()) {
+ ShowAIDebugWindow(c->index);
+ break;
+ }
+ }
+}
diff --git a/src/ai/ai_gui.hpp b/src/ai/ai_gui.hpp
index e76681636..0a47e992b 100644
--- a/src/ai/ai_gui.hpp
+++ b/src/ai/ai_gui.hpp
@@ -17,6 +17,7 @@
#ifdef ENABLE_AI
void ShowAIDebugWindow(CompanyID show_company = INVALID_COMPANY);
void ShowAIConfigWindow();
+void ShowAIDebugWindowIfAIError();
#else
#include "table/strings.h"
@@ -25,6 +26,7 @@ static inline void ShowAIConfigWindow()
ShowErrorMessage(STR_ERROR_NO_AI, STR_ERROR_NO_AI_SUB, WL_INFO);
}
static inline void ShowAIDebugWindow(CompanyID show_company = INVALID_COMPANY) {ShowAIConfigWindow();}
+static inline void ShowAIDebugWindowIfAIError() {}
#endif /* ENABLE_AI */
#endif /* AI_GUI_HPP */
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index bb6496e00..15777af79 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -41,6 +41,7 @@
#include "../company_func.h"
#include "../road_cmd.h"
#include "../ai/ai.hpp"
+#include "../ai/ai_gui.hpp"
#include "../town.h"
#include "../economy_base.h"
#include "../animated_tile_func.h"
@@ -263,6 +264,7 @@ static void InitializeWindowsAndCaches()
CheckTrainsLengths();
ShowNewGRFError();
+ ShowAIDebugWindowIfAIError();
}
typedef void (CDECL *SignalHandlerPointer)(int);