From f806b46cc967202db3d2fbf3384d0f037c13ed8a Mon Sep 17 00:00:00 2001 From: rubidium Date: Thu, 21 Jun 2007 14:32:27 +0000 Subject: (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch. --- src/newgrf_engine.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/newgrf_engine.cpp') diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index 7a3e980eb..fc2dacdcf 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -727,19 +727,19 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by case 0x4F: return GB(v->reliability, 8, 8); case 0x50: return v->reliability_spd_dec; case 0x51: return GB(v->reliability_spd_dec, 8, 8); - case 0x52: return v->profit_this_year; - case 0x53: return GB(v->profit_this_year, 8, 24); - case 0x54: return GB(v->profit_this_year, 16, 16); - case 0x55: return GB(v->profit_this_year, 24, 8); - case 0x56: return v->profit_last_year; - case 0x57: return GB(v->profit_last_year, 8, 24); - case 0x58: return GB(v->profit_last_year, 16, 16); - case 0x59: return GB(v->profit_last_year, 24, 8); + case 0x52: return ClampToI32(v->profit_this_year); + case 0x53: return GB(ClampToI32(v->profit_this_year), 8, 24); + case 0x54: return GB(ClampToI32(v->profit_this_year), 16, 16); + case 0x55: return GB(ClampToI32(v->profit_this_year), 24, 8); + case 0x56: return ClampToI32(v->profit_last_year); + case 0x57: return GB(ClampToI32(v->profit_last_year), 8, 24); + case 0x58: return GB(ClampToI32(v->profit_last_year), 16, 16); + case 0x59: return GB(ClampToI32(v->profit_last_year), 24, 8); case 0x5A: return v->next == NULL ? INVALID_VEHICLE : v->next->index; - case 0x5C: return v->value; - case 0x5D: return GB(v->value, 8, 24); - case 0x5E: return GB(v->value, 16, 16); - case 0x5F: return GB(v->value, 24, 8); + case 0x5C: return ClampToI32(v->value); + case 0x5D: return GB(ClampToI32(v->value), 8, 24); + case 0x5E: return GB(ClampToI32(v->value), 16, 16); + case 0x5F: return GB(ClampToI32(v->value), 24, 8); case 0x60: return v->string_id; case 0x61: return GB(v->string_id, 8, 8); case 0x72: return v->cargo_subtype; -- cgit v1.2.3-54-g00ecf