summaryrefslogtreecommitdiff
path: root/src/ai/api/ai_town.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ai/api/ai_town.cpp')
-rw-r--r--src/ai/api/ai_town.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/ai/api/ai_town.cpp b/src/ai/api/ai_town.cpp
index 72f068f09..78144b998 100644
--- a/src/ai/api/ai_town.cpp
+++ b/src/ai/api/ai_town.cpp
@@ -92,6 +92,20 @@
}
}
+/* static */ int32 AITown::GetLastMonthTransportedPercentage(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 ::ToPercent8(t->pct_pass_transported);
+ case AICargo::TE_MAIL: return ::ToPercent8(t->pct_mail_transported);
+ default: return -1;
+ }
+}
+
/* static */ int32 AITown::GetDistanceManhattanToTile(TownID town_id, TileIndex tile)
{
return AIMap::DistanceManhattan(tile, GetLocation(town_id));