summaryrefslogtreecommitdiff
path: root/src/ai/api/ai_town.cpp
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-11-23 16:05:19 +0000
committertruebrain <truebrain@openttd.org>2011-11-23 16:05:19 +0000
commit229e572663158d8fd37cabf3c2a3cb06811ff0a1 (patch)
treee27f01fdf1de01262be29bb795b0be8d54b04f5e /src/ai/api/ai_town.cpp
parent4e09cde6495f35a6d56cacc0dbf636df7bc94dbd (diff)
downloadopenttd-229e572663158d8fd37cabf3c2a3cb06811ff0a1.tar.xz
(svn r23298) -Add: track statistics of all incoming and outgoing goods. Incoming based on TownEffect, outgoing based on CargoType (based on patch by Terkhen)
Diffstat (limited to 'src/ai/api/ai_town.cpp')
-rw-r--r--src/ai/api/ai_town.cpp29
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)