Skip to content

Instantly share code, notes, and snippets.

@SamuXarick
Created February 16, 2023 18:37
Show Gist options
  • Save SamuXarick/61f83b3b0e1a93e940130538f96299d5 to your computer and use it in GitHub Desktop.
Save SamuXarick/61f83b3b0e1a93e940130538f96299d5 to your computer and use it in GitHub Desktop.
void SelectValidDebugCompany()
{
/* Check if the currently selected company is still active. */
if (this->IsValidDebugCompany(script_debug_company)) return;
script_debug_company = INVALID_COMPANY;
/* If no AI is available, see if there is a game script. */
if (Game::GetInstance() != nullptr) {
ChangeToScript(OWNER_DEITY);
return;
}
for (const Company *c : Company::Iterate()) {
if (c->is_ai) {
ChangeToScript(c->index);
return;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment