summaryrefslogtreecommitdiff
path: root/src/ai/api/ai_industry.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-08-07 20:51:53 +0000
committeryexo <yexo@openttd.org>2010-08-07 20:51:53 +0000
commit178f74c31cd79ac248308a6fa389e5aa223b0895 (patch)
treee782722a0c69d4242fffc9e12fad9409679221d0 /src/ai/api/ai_industry.cpp
parentaf9d8824bd7d08fa512f34c02c238d0042d060a7 (diff)
downloadopenttd-178f74c31cd79ac248308a6fa389e5aa223b0895.tar.xz
(svn r20399) -Change: [NoAI] AIIndustry::IsCargoAccepted now returns 3 possible values so AIs can detect a temporaral refusal from an industry to accept some cargo type
Diffstat (limited to 'src/ai/api/ai_industry.cpp')
-rw-r--r--src/ai/api/ai_industry.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/ai/api/ai_industry.cpp b/src/ai/api/ai_industry.cpp
index c1cb42ef8..cb5c3cee4 100644
--- a/src/ai/api/ai_industry.cpp
+++ b/src/ai/api/ai_industry.cpp
@@ -15,6 +15,7 @@
#include "../../industry.h"
#include "../../strings_func.h"
#include "../../station_base.h"
+#include "../../newgrf_industries.h"
#include "table/strings.h"
/* static */ int32 AIIndustry::GetIndustryCount()
@@ -45,18 +46,21 @@
return industry_name;
}
-/* static */ bool AIIndustry::IsCargoAccepted(IndustryID industry_id, CargoID cargo_id)
+/* static */ AIIndustry::CargoAcceptState AIIndustry::IsCargoAccepted(IndustryID industry_id, CargoID cargo_id)
{
- if (!IsValidIndustry(industry_id)) return false;
- if (!AICargo::IsValidCargo(cargo_id)) return false;
+ if (!IsValidIndustry(industry_id)) return CAS_NOT_ACCEPTED;
+ if (!AICargo::IsValidCargo(cargo_id)) return CAS_NOT_ACCEPTED;
- const Industry *i = ::Industry::Get(industry_id);
+ Industry *i = ::Industry::Get(industry_id);
for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
- if (i->accepts_cargo[j] == cargo_id) return true;
+ if (i->accepts_cargo[j] == cargo_id) {
+ if (IndustryTemporarilyRefusesCargo(i, cargo_id)) return CAS_TEMP_REFUSED;
+ return CAS_ACCEPTED;
+ }
}
- return false;
+ return CAS_NOT_ACCEPTED;
}
/* static */ int32 AIIndustry::GetStockpiledCargo(IndustryID industry_id, CargoID cargo_id)