summaryrefslogtreecommitdiff
path: root/src/ai/api/ai_industry.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_industry.cpp
parent072ce4bb17dcb02e8e832f46e4fcadfd7c4be944 (diff)
downloadopenttd-713f5d44ce5328c785f172f7cf798407e6d78fcd.tar.xz
(svn r17294) -Add [NoAI]: AITown::GetLastMonthTransportedPercentage and AIIndustry::GetLastMonthTransportedPercentage
Diffstat (limited to 'src/ai/api/ai_industry.cpp')
-rw-r--r--src/ai/api/ai_industry.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/ai/api/ai_industry.cpp b/src/ai/api/ai_industry.cpp
index 3870a216b..2002374e6 100644
--- a/src/ai/api/ai_industry.cpp
+++ b/src/ai/api/ai_industry.cpp
@@ -98,6 +98,20 @@
return -1;
}
+/* static */ int32 AIIndustry::GetLastMonthTransportedPercentage(IndustryID industry_id, CargoID cargo_id)
+{
+ if (!IsValidIndustry(industry_id)) return -1;
+ if (!AICargo::IsValidCargo(cargo_id)) return -1;
+
+ const Industry *i = ::Industry::Get(industry_id);
+
+ for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
+ if (i->produced_cargo[j] == cargo_id) return ::ToPercent8(i->last_month_pct_transported[j]);
+ }
+
+ return -1;
+}
+
/* static */ TileIndex AIIndustry::GetLocation(IndustryID industry_id)
{
if (!IsValidIndustry(industry_id)) return INVALID_TILE;