summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2007-11-27 04:16:08 +0000
committerbelugas <belugas@openttd.org>2007-11-27 04:16:08 +0000
commit9402d4054ab4740ddf5758ed5bf0f379a75f00ea (patch)
tree745c246cb5fc0c354f7f41878850e5030fb95a74
parent8c5814156f6f81da96d582d1dd757f70f6ead398 (diff)
downloadopenttd-9402d4054ab4740ddf5758ed5bf0f379a75f00ea.tar.xz
(svn r11532) -Feature[newgrf]: Add decrement(0x0D) / increment(0x0E) production operations from result of production callback cb29/35.
Only var 0x93 will be affected by these operations
-rw-r--r--src/industry_cmd.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 05da2c9dc..28ff57720 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -2011,6 +2011,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
!(HasBit(indspec->callback_flags, CBM_IND_MONTHLYPROD_CHANGE) || HasBit(indspec->callback_flags, CBM_IND_PRODUCTION_CHANGE)); // production change callbacks
byte div = 0;
byte mul = 0;
+ int8 increment = 0;
if (HasBit(indspec->callback_flags, monthly ? CBM_IND_MONTHLYPROD_CHANGE : CBM_IND_PRODUCTION_CHANGE)) {
uint16 res = GetIndustryCallback(monthly ? CBID_INDUSTRY_MONTHLYPROD_CHANGE : CBID_INDUSTRY_PRODUCTION_CHANGE, 0, Random(), i, i->type, i->xy);
@@ -2032,6 +2033,10 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
case 0x8: div = res - 0x3; break; // Divide production by 32
case 0x9: case 0xA: case 0xB: // Multiply production by 4, 8, 16
case 0xC: mul = res - 0x7; break; // Multiply production by 32
+ case 0xD: // decrement production
+ case 0xE: // increment production
+ increment = res == 0x0D ? -1 : 1;
+ break;
}
}
}
@@ -2122,6 +2127,11 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
}
}
+ if (increment != 0) {
+ i->prod_level = ClampU(i->prod_level + increment, 4, 0x80);
+ if (i->prod_level == 4) closeit = true;
+ }
+
/* Close if needed and allowed */
if (closeit && !CheckIndustryCloseDownProtection(i->type)) {
i->prod_level = 0;