Changeset - r13338:391f5d181322
[Not reviewed]
master
0 3 0
frosch - 15 years ago 2009-10-24 18:51:21
frosch@openttd.org
(svn r17857) -Fix (r10442): [NewGRF] 'subtract-in' is also signed for production callback version 0.
3 files changed with 7 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -2963,21 +2963,21 @@ static void NewSpriteGroup(byte *buf, si
 

	
 
					IndustryProductionSpriteGroup *group = new IndustryProductionSpriteGroup();
 
					act_group = group;
 
					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);
 
						}
 
						group->again = grf_load_byte(&buf);
 
					}
src/newgrf_industries.cpp
Show inline comments
 
@@ -499,13 +499,13 @@ bool CheckIfCallBackAllowsAvailability(I
 
			return (res == 0);
 
		}
 
	}
 
	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;
 
}
 

	
 
/**
 
 * Get the industry production callback and apply it to the industry.
 
@@ -540,13 +540,13 @@ void IndustryProductionCallback(Industry
 
		if (tgroup == NULL || tgroup->type != SGT_INDUSTRY_PRODUCTION) break;
 
		const IndustryProductionSpriteGroup *group = (const IndustryProductionSpriteGroup *)tgroup;
 

	
 
		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);
 
		}
 

	
 
		int32 again = DerefIndProd(group->again, deref);
src/newgrf_spritegroup.h
Show inline comments
 
@@ -276,14 +276,14 @@ struct TileLayoutSpriteGroup : SpriteGro
 
};
 

	
 
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;
 
};
 

	
 

	
 
struct ResolverObject {
 
	CallbackID callback;
0 comments (0 inline, 0 general)