summaryrefslogtreecommitdiff
path: root/src/ai/api/ai_town.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-08-27 13:50:07 +0000
committersmatz <smatz@openttd.org>2009-08-27 13:50:07 +0000
commit713f5d44ce5328c785f172f7cf798407e6d78fcd (patch)
treeda8a764a78fd23592a27e441595380c9ee2d2022 /src/ai/api/ai_town.cpp
parent072ce4bb17dcb02e8e832f46e4fcadfd7c4be944 (diff)
downloadopenttd-713f5d44ce5328c785f172f7cf798407e6d78fcd.tar.xz
(svn r17294) -Add [NoAI]: AITown::GetLastMonthTransportedPercentage and AIIndustry::GetLastMonthTransportedPercentage
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));