From dfa528d058e5499558e7fd8dca3b292851f7625a Mon Sep 17 00:00:00 2001 From: Yexo Date: Sat, 13 Mar 2010 00:15:24 +0000 Subject: (svn r19395) -Fix [FS#3669]: the AI Debug window didn't open if an AI or library fails to compile when loading a savegame --- src/ai/ai_gui.cpp | 12 ++++++++++++ src/ai/ai_gui.hpp | 2 ++ 2 files changed, 14 insertions(+) (limited to 'src/ai') 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 */ -- cgit v1.2.3-70-g09d2