Codechange: [Script] Use helper function over direct casting CompanyID

In the script's API `COMPANY_INVALID` has a value of -1, whereas the internal
game's `INVALID_COMPANY` has a value of 255. Since the script's API also has
a `COMPANY_SPECTATOR` with a value of 255, these enumerations cannot be easily
reconciled by casting. As such, replace all casts in the script API with
either ScriptCompany::FromScriptCompanyID or ScriptCompany::ToScriptCompanyID.

Also make clear whether CompanyID is ::CompanyID or ScriptCompany::CompanyID
by using either one of those over CompanyID in the script's API.
This commit is contained in:
Rubidium
2025-02-08 21:26:58 +01:00
committed by rubidium42
parent 8ab3e9f0a3
commit 4cda9f900d
37 changed files with 201 additions and 184 deletions

View File

@@ -269,21 +269,21 @@ protected:
* information about.
* @param company The new company.
*/
static void SetCompany(CompanyID company);
static void SetCompany(::CompanyID company);
/**
* Get the current company we are executing commands for or
* requesting information about.
* @return The current company.
*/
static CompanyID GetCompany();
static ::CompanyID GetCompany();
/**
* Get the root company, the company that the script really
* runs under / for.
* @return The root company.
*/
static CompanyID GetRootCompany();
static ::CompanyID GetRootCompany();
/**
* Set the cost of the last command.