summaryrefslogtreecommitdiff
path: root/src/industry_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-07-08 17:40:04 +0000
committerrubidium <rubidium@openttd.org>2007-07-08 17:40:04 +0000
commit95ea8fd2f192cc0bcf7538ec4cd97e4dddcff9d5 (patch)
treee8b08f0eebf44557962f1210eb8b7887d9d999bf /src/industry_cmd.cpp
parent064c1ea89e4f5395654ea3cad060422b5d495b59 (diff)
downloadopenttd-95ea8fd2f192cc0bcf7538ec4cd97e4dddcff9d5.tar.xz
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
Diffstat (limited to 'src/industry_cmd.cpp')
-rw-r--r--src/industry_cmd.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 0162f7ce5..6429f2ff1 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -330,12 +330,36 @@ static Slope GetSlopeTileh_Industry(TileIndex tile, Slope tileh)
static void GetAcceptedCargo_Industry(TileIndex tile, AcceptedCargo ac)
{
- const IndustryTileSpec *itspec = GetIndustryTileSpec(GetIndustryGfx(tile));
- CargoID a;
+ IndustryGfx gfx = GetIndustryGfx(tile);
+ const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx);
+
+ /* When we have to use a callback, we put our data in the next two variables */
+ CargoID raw_accepts_cargo[lengthof(itspec->accepts_cargo)];
+ uint8 raw_acceptance[lengthof(itspec->acceptance)];
+
+ /* And then these will always point to a same sized array with the required data */
+ const CargoID *accepts_cargo = itspec->accepts_cargo;
+ const uint8 *acceptance = itspec->acceptance;
+
+ if (HASBIT(itspec->callback_flags, CBM_INDT_ACCEPT_CARGO)) {
+ uint16 res = GetIndustryTileCallback(CBID_INDTILE_ACCEPT_CARGO, 0, 0, gfx, GetIndustryByTile(tile), tile);
+ if (res != CALLBACK_FAILED) {
+ accepts_cargo = raw_accepts_cargo;
+ for (uint i = 0; i < lengthof(itspec->accepts_cargo); i++) raw_accepts_cargo[i] = GetCargoTranslation(GB(res, i * 5, 5), itspec->grf_prop.grffile);
+ }
+ }
+
+ if (HASBIT(itspec->callback_flags, CBM_INDT_CARGO_ACCEPTANCE)) {
+ uint16 res = GetIndustryTileCallback(CBID_INDTILE_CARGO_ACCEPTANCE, 0, 0, gfx, GetIndustryByTile(tile), tile);
+ if (res != CALLBACK_FAILED) {
+ acceptance = raw_acceptance;
+ for (uint i = 0; i < lengthof(itspec->accepts_cargo); i++) raw_acceptance[i] = GB(res, i * 4, 4);
+ }
+ }
for (byte i = 0; i < lengthof(itspec->accepts_cargo); i++) {
- a = itspec->accepts_cargo[i];
- if (a != CT_INVALID) ac[a] = itspec->acceptance[i];
+ CargoID a = accepts_cargo[i];
+ if (a != CT_INVALID) ac[a] = acceptance[i];
}
}