summaryrefslogtreecommitdiff
path: root/src/newgrf_industries.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-08-07 20:11:27 +0000
committeryexo <yexo@openttd.org>2010-08-07 20:11:27 +0000
commite80f3390863aa4a722b0d7516cca7420b12df53a (patch)
tree6696408aa41b164d70f99c01ef97ee11a364ae1b /src/newgrf_industries.cpp
parent50fe2264ec43f72648518ea18551c851624396fd (diff)
downloadopenttd-e80f3390863aa4a722b0d7516cca7420b12df53a.tar.xz
(svn r20396) -Codechange: introduce a helper function to test whether an industry temporarily refues to accept some cargo
Diffstat (limited to 'src/newgrf_industries.cpp')
-rw-r--r--src/newgrf_industries.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp
index a7d9606a3..fc8c8bbef 100644
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -17,6 +17,7 @@
#include "newgrf_commons.h"
#include "newgrf_text.h"
#include "newgrf_town.h"
+#include "newgrf_cargo.h"
#include "window_func.h"
#include "town.h"
#include "company_base.h"
@@ -583,3 +584,24 @@ void GetIndustryResolver(ResolverObject *ro, uint index)
Industry *i = Industry::Get(index);
NewIndustryResolver(ro, i->location.tile, i, i->type);
}
+
+/**
+ * Check whether an industry temporarily refuses to accept a certain cargo.
+ * @param ind The industry to query.
+ * @param cargo_type The cargo to get information about.
+ * @pre cargo_type is in ind->accepts_cargo.
+ * @return Whether the given industry refuses to accept this cargo type.
+ */
+bool IndustryTemporarilyRefusesCargo(Industry *ind, CargoID cargo_type)
+{
+ assert(cargo_type == ind->accepts_cargo[0] || cargo_type == ind->accepts_cargo[1] || cargo_type == ind->accepts_cargo[2]);
+
+ const IndustrySpec *indspec = GetIndustrySpec(ind->type);
+ if (HasBit(indspec->callback_mask, CBM_IND_REFUSE_CARGO)) {
+ uint16 res = GetIndustryCallback(CBID_INDUSTRY_REFUSE_CARGO,
+ 0, GetReverseCargoTranslation(cargo_type, indspec->grf_prop.grffile),
+ ind, ind->type, ind->location.tile);
+ return res == 0;
+ }
+ return false;
+}