1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-23 20:24:12 +01:00

Codechange: change Source into a class with conversion helpers

A Source is either a CompanyID (Headquarters), IndustryID or TownID.
When making those types stronger a lot of casts would be needed, but
with these simple helpers the intent is shown more clearly.
This commit is contained in:
Rubidium
2025-02-08 15:02:13 +01:00
committed by rubidium42
parent 2929411130
commit 155d7de132
14 changed files with 87 additions and 54 deletions

View File

@@ -82,7 +82,7 @@
/* static */ SQInteger ScriptSubsidy::GetSourceIndex(SubsidyID subsidy_id)
{
if (!IsValidSubsidy(subsidy_id)) return INVALID_SOURCE;
if (!IsValidSubsidy(subsidy_id)) return Source::Invalid;
return ::Subsidy::Get(subsidy_id)->src.id;
}
@@ -96,7 +96,7 @@
/* static */ SQInteger ScriptSubsidy::GetDestinationIndex(SubsidyID subsidy_id)
{
if (!IsValidSubsidy(subsidy_id)) return INVALID_SOURCE;
if (!IsValidSubsidy(subsidy_id)) return Source::Invalid;
return ::Subsidy::Get(subsidy_id)->dst.id;
}