diff options
author | peter1138 <peter1138@openttd.org> | 2006-11-28 21:03:28 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2006-11-28 21:03:28 +0000 |
commit | 86d4052b1e1c4d9df2caf84956c8e47378607fad (patch) | |
tree | 5a357ebccac82da73d3ad28972ceccb578bef15e | |
parent | 3311f57b207bff2e46e76c46b38e014fafcee5e3 (diff) | |
download | openttd-86d4052b1e1c4d9df2caf84956c8e47378607fad.tar.xz |
(svn r7282) -Fix (r625): ttdpatch vars are little endian
-rw-r--r-- | newgrf_engine.c | 68 | ||||
-rw-r--r-- | newgrf_station.c | 4 |
2 files changed, 36 insertions, 36 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; diff --git a/newgrf_station.c b/newgrf_station.c index 04688821d..043fe113d 100644 --- a/newgrf_station.c +++ b/newgrf_station.c @@ -371,7 +371,7 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by case 0xF2: return st->truck_stops->status; case 0xF3: return st->bus_stops->status; case 0xF6: return st->airport_flags; - case 0xF7: return st->airport_flags & 0xFF; + case 0xF7: return GB(st->airport_flags, 8, 8); case 0xFA: return max(st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0); } @@ -380,7 +380,7 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by const GoodsEntry *g = &st->goods[GB(variable - 0x8C, 3, 4)]; switch (GB(variable - 0x8C, 0, 3)) { case 0: return g->waiting_acceptance; - case 1: return g->waiting_acceptance & 0xFF; + case 1: return GB(g->waiting_acceptance, 8, 8); case 2: return g->days_since_pickup; case 3: return g->rating; case 4: return g->enroute_from; |