summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-11-24 14:03:47 +0000
committerrubidium <rubidium@openttd.org>2007-11-24 14:03:47 +0000
commitbd8bf991398765620c2beea281369262c8d14a8b (patch)
tree5e4e74ea9fc13e3620e686571e8a92a3ebd59646
parentcbd1c0521860b4e07efc3ba4ad5fea42f58136cb (diff)
downloadopenttd-bd8bf991398765620c2beea281369262c8d14a8b.tar.xz
(svn r11514) -Change: implement the automatic multiplier handler for NewGRF industries.
-rw-r--r--src/newgrf_industries.cpp12
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);