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:
@@ -263,7 +263,7 @@
|
||||
auto company_id = ::Industry::Get(industry_id)->exclusive_supplier;
|
||||
if (!::Company::IsValidID(company_id)) return ScriptCompany::COMPANY_INVALID;
|
||||
|
||||
return (ScriptCompany::CompanyID)((uint8_t)company_id);
|
||||
return ScriptCompany::ToScriptCompanyID(company_id);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptIndustry::SetExclusiveSupplier(IndustryID industry_id, ScriptCompany::CompanyID company_id)
|
||||
@@ -283,7 +283,7 @@
|
||||
auto company_id = ::Industry::Get(industry_id)->exclusive_consumer;
|
||||
if (!::Company::IsValidID(company_id)) return ScriptCompany::COMPANY_INVALID;
|
||||
|
||||
return (ScriptCompany::CompanyID)((uint8_t)company_id);
|
||||
return ScriptCompany::ToScriptCompanyID(company_id);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptIndustry::SetExclusiveConsumer(IndustryID industry_id, ScriptCompany::CompanyID company_id)
|
||||
|
||||
Reference in New Issue
Block a user