Add: precondition checks to functions that work with both valid company and deity

These are functions that either use ScriptObject::Command or ScriptObject::GetCompany.
This is a bit over-protective, but having the check everywhere makes it easier to
validate that no check is missing automatically instead of by review.

At this moment these checks will not do anything useful, as either IsValid or
IsDeity from ScriptCompanyMode returns true, but that will change later.
This commit is contained in:
Rubidium
2023-03-02 21:22:37 +01:00
committed by rubidium42
parent 2fffde0891
commit 534f2419ad
27 changed files with 65 additions and 1 deletions

View File

@@ -21,6 +21,7 @@
/* static */ bool ScriptStation::IsValidStation(StationID station_id)
{
EnforceDeityOrCompanyModeValid(false);
const Station *st = ::Station::GetIfValid(station_id);
return st != nullptr && (st->owner == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity() || st->owner == OWNER_NONE);
}