diff options
Diffstat (limited to 'src/ai/api/ai_town.cpp')
-rw-r--r-- | src/ai/api/ai_town.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/ai/api/ai_town.cpp b/src/ai/api/ai_town.cpp index e78d7dfc7..c1efe5ec7 100644 --- a/src/ai/api/ai_town.cpp +++ b/src/ai/api/ai_town.cpp @@ -70,25 +70,17 @@ const Town *t = ::Town::Get(town_id); - switch (AICargo::GetTownEffect(cargo_id)) { - case AICargo::TE_PASSENGERS: return t->pass.old_max; - case AICargo::TE_MAIL: return t->mail.old_max; - default: return -1; - } + return t->supplied[cargo_id].old_max; } -/* static */ int32 AITown::GetLastMonthTransported(TownID town_id, CargoID cargo_id) +/* static */ int32 AITown::GetLastMonthSupplied(TownID town_id, CargoID cargo_id) { if (!IsValidTown(town_id)) return -1; if (!AICargo::IsValidCargo(cargo_id)) return -1; const Town *t = ::Town::Get(town_id); - switch (AICargo::GetTownEffect(cargo_id)) { - case AICargo::TE_PASSENGERS: return t->pass.old_act; - case AICargo::TE_MAIL: return t->mail.old_act; - default: return -1; - } + return t->supplied[cargo_id].old_act; } /* static */ int32 AITown::GetLastMonthTransportedPercentage(TownID town_id, CargoID cargo_id) @@ -97,12 +89,17 @@ if (!AICargo::IsValidCargo(cargo_id)) return -1; const Town *t = ::Town::Get(town_id); + return ::ToPercent8(t->GetPercentTransported(cargo_id)); +} - switch (AICargo::GetTownEffect(cargo_id)) { - case AICargo::TE_PASSENGERS: return ::ToPercent8(t->GetPercentPassTransported()); - case AICargo::TE_MAIL: return ::ToPercent8(t->GetPercentMailTransported()); - default: return -1; - } +/* static */ int32 AITown::GetLastMonthReceived(TownID town_id, AICargo::TownEffect towneffect_id) +{ + if (!IsValidTown(town_id)) return -1; + if (!AICargo::IsValidTownEffect(towneffect_id)) return -1; + + const Town *t = ::Town::Get(town_id); + + return t->received[towneffect_id].old_act; } /* static */ int32 AITown::GetDistanceManhattanToTile(TownID town_id, TileIndex tile) |