summaryrefslogtreecommitdiff
path: root/newgrf_engine.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-11-28 21:03:28 +0000
committerpeter1138 <peter1138@openttd.org>2006-11-28 21:03:28 +0000
commit23762f9534df43e9b0232e4fe2d4d0afab3e391c (patch)
tree5a357ebccac82da73d3ad28972ceccb578bef15e /newgrf_engine.c
parent555564380871723eea3b9c5d10bcb6ff70d02e56 (diff)
downloadopenttd-23762f9534df43e9b0232e4fe2d4d0afab3e391c.tar.xz
(svn r7282) -Fix (r625): ttdpatch vars are little endian
Diffstat (limited to 'newgrf_engine.c')
-rw-r--r--newgrf_engine.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/newgrf_engine.c b/newgrf_engine.c
index 3fda432e7..64c88ab22 100644
--- a/newgrf_engine.c
+++ b/newgrf_engine.c
@@ -686,50 +686,50 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
case 0x00: return v->type;
case 0x01: return MapOldSubType(v);
case 0x04: return v->index;
- case 0x05: return v->index & 0xFF;
+ case 0x05: return GB(v->index, 8, 8);
case 0x0A: return PackOrder(&v->current_order);
- case 0x0B: return PackOrder(&v->current_order) & 0xFF;
+ case 0x0B: return GB(PackOrder(&v->current_order), 8, 8);
case 0x0C: return v->num_orders;
case 0x0D: return v->cur_order_index;
case 0x10: return v->load_unload_time_rem;
- case 0x11: return v->load_unload_time_rem & 0xFF;
+ case 0x11: return GB(v->load_unload_time_rem, 8, 8);
case 0x12: return max(v->date_of_last_service - DAYS_TILL_ORIGINAL_BASE_YEAR, 0);
- case 0x13: return max(v->date_of_last_service - DAYS_TILL_ORIGINAL_BASE_YEAR, 0) & 0xFF;
+ case 0x13: return GB(max(v->date_of_last_service - DAYS_TILL_ORIGINAL_BASE_YEAR, 0), 8, 8);
case 0x14: return v->service_interval;
- case 0x15: return v->service_interval & 0xFF;
+ case 0x15: return GB(v->service_interval, 8, 8);
case 0x16: return v->last_station_visited;
case 0x17: return v->tick_counter;
case 0x18: return v->max_speed;
- case 0x19: return v->max_speed & 0xFF;
+ case 0x19: return GB(v->max_speed, 8, 8);
case 0x1A: return v->x_pos;
- case 0x1B: return v->x_pos & 0xFF;
+ case 0x1B: return GB(v->x_pos, 8, 8);
case 0x1C: return v->y_pos;
- case 0x1D: return v->y_pos & 0xFF;
+ case 0x1D: return GB(v->y_pos, 8, 8);
case 0x1E: return v->z_pos;
case 0x1F: return object->info_view ? DIR_W : v->direction;
case 0x28: return v->cur_image;
- case 0x29: return v->cur_image & 0xFF;
+ case 0x29: return GB(v->cur_image, 8, 8);
case 0x32: return v->vehstatus;
- case 0x33: return v->vehstatus;
+ case 0x33: return GB(v->vehstatus, 8, 8);
case 0x34: return v->cur_speed;
- case 0x35: return v->cur_speed & 0xFF;
+ case 0x35: return GB(v->cur_speed, 8, 8);
case 0x36: return v->subspeed;
case 0x37: return v->acceleration;
case 0x39: return v->cargo_type;
case 0x3A: return v->cargo_cap;
- case 0x3B: return v->cargo_cap & 0xFF;
+ case 0x3B: return GB(v->cargo_cap, 8, 8);
case 0x3C: return v->cargo_count;
- case 0x3D: return v->cargo_count & 0xFF;
+ case 0x3D: return GB(v->cargo_count, 8, 8);
case 0x3E: return v->cargo_source;
case 0x3F: return v->cargo_days;
case 0x40: return v->age;
- case 0x41: return v->age & 0xFF;
+ case 0x41: return GB(v->age, 8, 8);
case 0x42: return v->max_age;
- case 0x43: return v->max_age & 0xFF;
+ case 0x43: return GB(v->max_age, 8, 8);
case 0x44: return clamp(v->build_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR;
case 0x45: return v->unitnumber;
case 0x46: return v->engine_type;
- case 0x47: return v->engine_type & 0xFF;
+ case 0x47: return GB(v->engine_type, 8, 8);
case 0x48: return v->spritenum;
case 0x49: return v->day_counter;
case 0x4A: return v->breakdowns_since_last_service;
@@ -737,24 +737,24 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
case 0x4C: return v->breakdown_delay;
case 0x4D: return v->breakdown_chance;
case 0x4E: return v->reliability;
- case 0x4F: return v->reliability & 0xFF;
+ case 0x4F: return GB(v->reliability, 8, 8);
case 0x50: return v->reliability_spd_dec;
- case 0x51: return v->reliability_spd_dec & 0xFF;
+ case 0x51: return GB(v->reliability_spd_dec, 8, 8);
case 0x52: return v->profit_this_year;
- case 0x53: return v->profit_this_year & 0xFFFFFF;
- case 0x54: return v->profit_this_year & 0xFFFF;
- case 0x55: return v->profit_this_year & 0xFF;
+ 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 v->profit_last_year & 0xFF;
- case 0x58: return v->profit_last_year;
- case 0x59: return v->profit_last_year & 0xFF;
+ 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 0x5A: return v->next == NULL ? INVALID_VEHICLE : v->next->index;
case 0x5C: return v->value;
- case 0x5D: return v->value & 0xFFFFFF;
- case 0x5E: return v->value & 0xFFFF;
- case 0x5F: return v->value & 0xFF;
+ 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 0x60: return v->string_id;
- case 0x61: return v->string_id & 0xFF;
+ case 0x61: return GB(v->string_id, 8, 8);
case 0x72: return v->cargo_subtype;
case 0x7A: return v->random_bits;
case 0x7B: return v->waiting_triggers;
@@ -768,11 +768,11 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
case 0x66: return v->u.rail.railtype;
case 0x73: return v->u.rail.cached_veh_length;
case 0x74: return v->u.rail.cached_power;
- case 0x75: return v->u.rail.cached_power & 0xFFFFFF;
- case 0x76: return v->u.rail.cached_power & 0xFFFF;
- case 0x77: return v->u.rail.cached_power & 0xFF;
+ case 0x75: return GB(v->u.rail.cached_power, 8, 24);
+ case 0x76: return GB(v->u.rail.cached_power, 16, 16);
+ case 0x77: return GB(v->u.rail.cached_power, 24, 8);
case 0x7C: return v->first->index;
- case 0x7D: return v->first->index & 0xFF;
+ case 0x7D: return GB(v->first->index, 8, 8);
case 0x7F: return 0; // Used for vehicle reversing hack in TTDP
}
break;
@@ -781,11 +781,11 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
switch (variable - 0x80) {
case 0x62: return v->u.road.state;
case 0x64: return v->u.road.blocked_ctr;
- case 0x65: return v->u.road.blocked_ctr & 0xFF;
+ case 0x65: return GB(v->u.road.blocked_ctr, 8, 8);
case 0x66: return v->u.road.overtaking;
case 0x67: return v->u.road.overtaking_ctr;
case 0x68: return v->u.road.crashed_ctr;
- case 0x69: return v->u.road.crashed_ctr & 0xFF;
+ case 0x69: return GB(v->u.road.crashed_ctr, 8, 8);
}
break;