diff options
author | frosch <frosch@openttd.org> | 2009-10-24 18:51:21 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-10-24 18:51:21 +0000 |
commit | 8e23ba540c62bce9cba1f58435b019757869ed29 (patch) | |
tree | 0a9b0c85926507c30126791c066a741e1445d958 /src | |
parent | 64f9ee3a2dce292a6d6980b0c65b2d2dbfc3f570 (diff) | |
download | openttd-8e23ba540c62bce9cba1f58435b019757869ed29.tar.xz |
(svn r17857) -Fix (r10442): [NewGRF] 'subtract-in' is also signed for production callback version 0.
Diffstat (limited to 'src')
-rw-r--r-- | src/newgrf.cpp | 6 | ||||
-rw-r--r-- | src/newgrf_industries.cpp | 4 | ||||
-rw-r--r-- | src/newgrf_spritegroup.h | 4 |
3 files changed, 7 insertions, 7 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 28dca23b0..aa07f1774 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -2966,15 +2966,15 @@ static void NewSpriteGroup(byte *buf, size_t len) group->version = type; if (type == 0) { for (uint i = 0; i < 3; i++) { - group->substract_input[i] = grf_load_word(&buf); + group->subtract_input[i] = (int16)grf_load_word(&buf); // signed } for (uint i = 0; i < 2; i++) { - group->add_output[i] = grf_load_word(&buf); + group->add_output[i] = grf_load_word(&buf); // unsigned } group->again = grf_load_byte(&buf); } else { for (uint i = 0; i < 3; i++) { - group->substract_input[i] = grf_load_byte(&buf); + group->subtract_input[i] = grf_load_byte(&buf); } for (uint i = 0; i < 2; i++) { group->add_output[i] = grf_load_byte(&buf); diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 42f0f4fc7..e361f65f4 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -502,7 +502,7 @@ bool CheckIfCallBackAllowsAvailability(IndustryType type, IndustryAvailabilityCa return true; } -static int32 DerefIndProd(uint field, bool use_register) +static int32 DerefIndProd(int field, bool use_register) { return use_register ? (int32)GetRegister(field) : field; } @@ -543,7 +543,7 @@ void IndustryProductionCallback(Industry *ind, int reason) bool deref = (group->version == 1); for (uint i = 0; i < 3; i++) { - ind->incoming_cargo_waiting[i] = Clamp(ind->incoming_cargo_waiting[i] - DerefIndProd(group->substract_input[i], deref) * multiplier, 0, 0xFFFF); + ind->incoming_cargo_waiting[i] = Clamp(ind->incoming_cargo_waiting[i] - DerefIndProd(group->subtract_input[i], deref) * multiplier, 0, 0xFFFF); } for (uint i = 0; i < 2; i++) { ind->produced_cargo_waiting[i] = Clamp(ind->produced_cargo_waiting[i] + max(DerefIndProd(group->add_output[i], deref), 0) * multiplier, 0, 0xFFFF); diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h index f10574bdd..69086fce2 100644 --- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -279,8 +279,8 @@ struct IndustryProductionSpriteGroup : SpriteGroup { IndustryProductionSpriteGroup() : SpriteGroup(SGT_INDUSTRY_PRODUCTION) {} uint8 version; - uint16 substract_input[3]; - uint16 add_output[2]; + int16 subtract_input[3]; // signed + uint16 add_output[2]; // unsigned uint8 again; }; |