* Ensure that \c script_debug_company refers to a valid AI company or GS, or is set to #CompanyID::Invalid(). * If no valid company is selected, it selects the first valid AI or GS if any. */
| 724 | * If no valid company is selected, it selects the first valid AI or GS if any. |
| 725 | */ |
| 726 | void SelectValidDebugCompany() |
| 727 | { |
| 728 | /* Check if the currently selected company is still active. */ |
| 729 | if (this->IsValidDebugCompany(this->filter.script_debug_company)) return; |
| 730 | |
| 731 | this->filter.script_debug_company = CompanyID::Invalid(); |
| 732 | |
| 733 | for (const Company *c : Company::Iterate()) { |
| 734 | if (c->is_ai) { |
| 735 | this->ChangeToScript(c->index); |
| 736 | return; |
| 737 | } |
| 738 | } |
| 739 | |
| 740 | /* If no AI is available, see if there is a game script. */ |
| 741 | if (Game::GetInstance() != nullptr) this->ChangeToScript(OWNER_DEITY); |
| 742 | } |
| 743 | |
| 744 | /** |
| 745 | * Constructor for the window. |
no test coverage detected