Changeset - r13038:d42de8c3636a
[Not reviewed]
master
0 1 0
rubidium - 15 years ago 2009-09-15 17:23:24
rubidium@openttd.org
(svn r17546) -Fix (r9617): sign extending of profit calculation didn't work
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/economy.cpp
Show inline comments
 
@@ -812,13 +812,13 @@ Money GetTransportedGoodsIncome(uint num
 
		uint32 var18 = min(dist, 0xFFFF) | (min(num_pieces, 0xFF) << 16) | (transit_days << 24);
 
		uint16 callback = GetCargoCallback(CBID_CARGO_PROFIT_CALC, 0, var18, cs);
 
		if (callback != CALLBACK_FAILED) {
 
			int result = GB(callback, 0, 14);
 

	
 
			/* Simulate a 15 bit signed value */
 
			if (HasBit(callback, 14)) result = 0x4000 - result;
 
			if (HasBit(callback, 14)) result -= 0x4000;
 

	
 
			/* "The result should be a signed multiplier that gets multiplied
 
			 * by the amount of cargo moved and the price factor, then gets
 
			 * divided by 8192." */
 
			return result * num_pieces * cs->current_payment / 8192;
 
		}
0 comments (0 inline, 0 general)