Skip to content

Commit

Permalink
Fix: Use the same safety checks as 'stop_ai' for 'reload_ai'
Browse files Browse the repository at this point in the history
  • Loading branch information
glx22 committed Jan 18, 2021
1 parent 41dbcbc commit 38afa48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/ai/ai_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,8 @@ struct AIDebugWindow : public Window {
this->SetWidgetLoweredState(WID_AID_MATCH_CASE_BTN, this->case_sensitive_break_check);

this->SetWidgetDisabledState(WID_AID_SETTINGS, ai_debug_company == INVALID_COMPANY);
this->SetWidgetDisabledState(WID_AID_RELOAD_TOGGLE, ai_debug_company == INVALID_COMPANY || ai_debug_company == OWNER_DEITY);
extern CompanyID _local_company;
this->SetWidgetDisabledState(WID_AID_RELOAD_TOGGLE, ai_debug_company == INVALID_COMPANY || ai_debug_company == OWNER_DEITY || ai_debug_company == _local_company);
this->SetWidgetDisabledState(WID_AID_CONTINUE_BTN, ai_debug_company == INVALID_COMPANY ||
(ai_debug_company == OWNER_DEITY ? !Game::IsPaused() : !AI::IsPaused(ai_debug_company)));
}
Expand Down
4 changes: 3 additions & 1 deletion src/console_cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,8 @@ DEF_CONSOLE_CMD(ConReloadAI)
return true;
}

if (Company::IsHumanID(company_id)) {
/* In offline mode the player can be in an AI company, after cheating or loading network save with an AI in first slot. */
if (Company::IsHumanID(company_id) || company_id == _local_company) {
IConsoleWarning("Company is not controlled by an AI.");
return true;
}
Expand Down Expand Up @@ -1285,6 +1286,7 @@ DEF_CONSOLE_CMD(ConStopAI)
return true;
}

/* In offline mode the player can be in an AI company, after cheating or loading network save with an AI in first slot. */
if (Company::IsHumanID(company_id) || company_id == _local_company) {
IConsoleWarning("Company is not controlled by an AI.");
return true;
Expand Down

0 comments on commit 38afa48

Please sign in to comment.