1
0
Fork 0

(svn r24929) -Fix [FS#5415]: Don't try to pause or unpause crashed scripts.

release/1.3
frosch 2013-01-20 18:43:49 +00:00
parent dafff99b2a
commit a00320c61d
1 changed files with 27 additions and 10 deletions

View File

@ -987,6 +987,19 @@ struct AIDebugWindow : public Window {
return (ScriptLog::LogData *)Company::Get(ai_debug_company)->ai_instance->GetLogPointer(); return (ScriptLog::LogData *)Company::Get(ai_debug_company)->ai_instance->GetLogPointer();
} }
/**
* Check whether the currently selected AI/GS is dead.
* @return true if dead.
*/
bool IsDead() const
{
if (ai_debug_company == OWNER_DEITY) {
GameInstance *game = Game::GetInstance();
return game == NULL || game->IsDead();
}
return !Company::IsValidAiID(ai_debug_company) || Company::Get(ai_debug_company)->ai_instance->IsDead();
}
/** /**
* Constructor for the window. * Constructor for the window.
* @param desc The description of the window. * @param desc The description of the window.
@ -1286,6 +1299,7 @@ struct AIDebugWindow : public Window {
case WID_AID_CONTINUE_BTN: case WID_AID_CONTINUE_BTN:
/* Unpause current AI / game script and mark the corresponding script button dirty. */ /* Unpause current AI / game script and mark the corresponding script button dirty. */
if (!IsDead()) {
if (ai_debug_company == OWNER_DEITY) { if (ai_debug_company == OWNER_DEITY) {
Game::Unpause(); Game::Unpause();
this->SetWidgetDirty(WID_AID_SCRIPT_GAME); this->SetWidgetDirty(WID_AID_SCRIPT_GAME);
@ -1293,6 +1307,7 @@ struct AIDebugWindow : public Window {
AI::Unpause(ai_debug_company); AI::Unpause(ai_debug_company);
this->SetWidgetDirty(WID_AID_COMPANY_BUTTON_START + ai_debug_company); this->SetWidgetDirty(WID_AID_COMPANY_BUTTON_START + ai_debug_company);
} }
}
/* If the last AI/Game Script is unpaused, unpause the game too. */ /* If the last AI/Game Script is unpaused, unpause the game too. */
if ((_pause_mode & PM_PAUSED_NORMAL) == PM_PAUSED_NORMAL) { if ((_pause_mode & PM_PAUSED_NORMAL) == PM_PAUSED_NORMAL) {
@ -1365,11 +1380,13 @@ struct AIDebugWindow : public Window {
this->break_string_filter.AddLine(log->lines[log->pos]); this->break_string_filter.AddLine(log->lines[log->pos]);
if (this->break_string_filter.GetState()) { if (this->break_string_filter.GetState()) {
/* Pause execution of script. */ /* Pause execution of script. */
if (!IsDead()) {
if (ai_debug_company == OWNER_DEITY) { if (ai_debug_company == OWNER_DEITY) {
Game::Pause(); Game::Pause();
} else { } else {
AI::Pause(ai_debug_company); AI::Pause(ai_debug_company);
} }
}
/* Pause the game. */ /* Pause the game. */
if ((_pause_mode & PM_PAUSED_NORMAL) == PM_UNPAUSED) { if ((_pause_mode & PM_PAUSED_NORMAL) == PM_UNPAUSED) {