MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SelectValidDebugCompany

Method SelectValidDebugCompany

src/script/script_gui.cpp:726–742  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

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.

Callers 3

ScriptDebugWindowMethod · 0.95
OnPaintMethod · 0.95
OnInvalidateDataMethod · 0.95

Calls 3

IsValidDebugCompanyMethod · 0.95
ChangeToScriptMethod · 0.95
InvalidFunction · 0.85

Tested by

no test coverage detected