diff --git a/src/newgrf.cpp b/src/newgrf.cpp --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -2966,15 +2966,15 @@ static void NewSpriteGroup(byte *buf, si 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 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -502,7 +502,7 @@ bool CheckIfCallBackAllowsAvailability(I 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 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 --- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -279,8 +279,8 @@ struct IndustryProductionSpriteGroup : S 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; };