diff options
author | rubidium <rubidium@openttd.org> | 2007-11-24 14:03:47 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-11-24 14:03:47 +0000 |
commit | 63b0cba29b5cd494b7fbe15dc4119fde4f9e72b8 (patch) | |
tree | 5e4e74ea9fc13e3620e686571e8a92a3ebd59646 | |
parent | ce8d9b7fecf1db65ac8e15af1c8be953b9f06697 (diff) | |
download | openttd-63b0cba29b5cd494b7fbe15dc4119fde4f9e72b8.tar.xz |
(svn r11514) -Change: implement the automatic multiplier handler for NewGRF industries.
-rw-r--r-- | src/newgrf_industries.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 7bd447a21..603fba8f4 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -201,7 +201,11 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par case 0x42: { // waiting cargo, but only if those two callback flags are set uint16 callback = indspec->callback_flags; if (HasBit(callback, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(callback, CBM_IND_PRODUCTION_256_TICKS)) { - return min(industry->incoming_cargo_waiting[variable - 0x40], (uint16)0xFFFF); + if ((indspec->behaviour & INDUSTRYBEH_PROD_MULTI_HNDLING) != 0) { + return min(industry->incoming_cargo_waiting[variable - 0x40] / industry->prod_level, (uint16)0xFFFF); + } else { + return min(industry->incoming_cargo_waiting[variable - 0x40], (uint16)0xFFFF); + } } else { return 0; } @@ -505,6 +509,8 @@ void IndustryProductionCallback(Industry *ind, int reason) ResolverObject object; NewIndustryResolver(&object, ind->xy, ind); if ((spec->behaviour & INDUSTRYBEH_PRODCALLBACK_RANDOM) != 0) object.callback_param1 = Random(); + int multiplier = 1; + if ((spec->behaviour & INDUSTRYBEH_PROD_MULTI_HNDLING) != 0) multiplier = ind->prod_level; object.callback_param2 = reason; for (uint loop = 0;; loop++) { @@ -515,10 +521,10 @@ void IndustryProductionCallback(Industry *ind, int reason) bool deref = (group->g.indprod.version == 1); for (uint i = 0; i < 3; i++) { - ind->incoming_cargo_waiting[i] = Clamp(ind->incoming_cargo_waiting[i] - DerefIndProd(group->g.indprod.substract_input[i], deref), 0, 0xFFFF); + ind->incoming_cargo_waiting[i] = Clamp(ind->incoming_cargo_waiting[i] - DerefIndProd(group->g.indprod.substract_input[i], deref) * multiplier, 0, 0xFFFF); } for (uint i = 0; i < 2; i++) { - ind->produced_cargo_waiting[i] = Clamp(ind->produced_cargo_waiting[i] + DerefIndProd(group->g.indprod.add_output[i], deref), 0, 0xFFFF); + ind->produced_cargo_waiting[i] = Clamp(ind->produced_cargo_waiting[i] + max(DerefIndProd(group->g.indprod.add_output[i], deref), 0) * multiplier, 0, 0xFFFF); } int32 again = DerefIndProd(group->g.indprod.again, deref); |