1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-22 11:44:17 +01:00

Codechange: make IndustryID an enum

This commit is contained in:
Rubidium
2025-01-19 15:27:00 +01:00
committed by rubidium42
parent 9015c3651f
commit c25c3e8710
7 changed files with 13 additions and 10 deletions

View File

@@ -35,7 +35,7 @@
if (type == GT_STORY_PAGE && ScriptStoryPage::IsValidStoryPage(static_cast<StoryPageID>(destination))) story_page = ::StoryPage::Get(static_cast<StoryPageID>(destination));
return (type == GT_NONE && destination == 0) ||
(type == GT_TILE && ScriptMap::IsValidTile(::TileIndex(destination))) ||
(type == GT_INDUSTRY && ScriptIndustry::IsValidIndustry(destination)) ||
(type == GT_INDUSTRY && ScriptIndustry::IsValidIndustry(static_cast<IndustryID>(destination))) ||
(type == GT_TOWN && ScriptTown::IsValidTown(static_cast<TownID>(destination))) ||
(type == GT_COMPANY && ScriptCompany::ResolveCompanyID(ScriptCompany::ToScriptCompanyID(static_cast<::CompanyID>(destination))) != ScriptCompany::COMPANY_INVALID) ||
(type == GT_STORY_PAGE && story_page != nullptr && (c == INVALID_COMPANY ? story_page->company == INVALID_COMPANY : story_page->company == INVALID_COMPANY || story_page->company == c));

View File

@@ -33,7 +33,7 @@
EnforcePrecondition(false, (ref_type == NR_NONE) ||
(ref_type == NR_TILE && ScriptMap::IsValidTile(::TileIndex(reference))) ||
(ref_type == NR_STATION && ScriptStation::IsValidStation(reference)) ||
(ref_type == NR_INDUSTRY && ScriptIndustry::IsValidIndustry(reference)) ||
(ref_type == NR_INDUSTRY && ScriptIndustry::IsValidIndustry(static_cast<IndustryID>(reference))) ||
(ref_type == NR_TOWN && ScriptTown::IsValidTown(static_cast<TownID>(reference))));
::CompanyID c = ScriptCompany::FromScriptCompanyID(company);

View File

@@ -37,8 +37,8 @@
EnforcePrecondition(false, ScriptCargo::IsValidCargo(cargo_type));
EnforcePrecondition(false, from_type == SPT_INDUSTRY || from_type == SPT_TOWN);
EnforcePrecondition(false, to_type == SPT_INDUSTRY || to_type == SPT_TOWN);
EnforcePrecondition(false, (from_type == SPT_INDUSTRY && ScriptIndustry::IsValidIndustry(from_id)) || (from_type == SPT_TOWN && ScriptTown::IsValidTown(static_cast<TownID>(from_id))));
EnforcePrecondition(false, (to_type == SPT_INDUSTRY && ScriptIndustry::IsValidIndustry(to_id)) || (to_type == SPT_TOWN && ScriptTown::IsValidTown(static_cast<TownID>(to_id))));
EnforcePrecondition(false, (from_type == SPT_INDUSTRY && ScriptIndustry::IsValidIndustry(static_cast<IndustryID>(from_id))) || (from_type == SPT_TOWN && ScriptTown::IsValidTown(static_cast<TownID>(from_id))));
EnforcePrecondition(false, (to_type == SPT_INDUSTRY && ScriptIndustry::IsValidIndustry(static_cast<IndustryID>(to_id))) || (to_type == SPT_TOWN && ScriptTown::IsValidTown(static_cast<TownID>(to_id))));
Source from{static_cast<SourceID>(from_id), static_cast<SourceType>(from_type)};
Source to{static_cast<SourceID>(to_id), static_cast<SourceType>(to_type)};