From 5340af4a124b01fc43b22c6c5e3906b705cb7889 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sat, 20 Feb 2016 16:42:17 +0000 Subject: [PATCH] Refactor sprite_flags --- src/interface/viewport.c | 2 +- src/peep/peep.h | 8 +------- src/ride/vehicle.c | 6 +++--- src/ride/vehicle.h | 2 +- src/windows/guest_list.c | 14 +++++++------- src/windows/map.c | 2 +- src/windows/staff_list.c | 4 ++-- src/world/balloon.c | 2 +- src/world/duck.c | 2 +- src/world/sprite.c | 2 +- src/world/sprite.h | 30 +++++++++++++++++++----------- 11 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/interface/viewport.c b/src/interface/viewport.c index 1d50df5e81..567bef26c7 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -1087,7 +1087,7 @@ void viewport_vehicle_paint_setup(rct_vehicle *vehicle, int imageDirection) int y = vehicle->y; int z = vehicle->z; - if (vehicle->var_0C & 0x80) { + if (vehicle->sprite_flags & SPRITE_FLAGS_IS_CRASHED_VEHICLE_SPRITE) { uint32 ebx = 22965 + vehicle->var_C5; RCT2_GLOBAL(0x9DEA52, uint16) = 0; RCT2_GLOBAL(0x9DEA54, uint16) = 0; diff --git a/src/peep/peep.h b/src/peep/peep.h index bf65311002..20a8318a94 100644 --- a/src/peep/peep.h +++ b/src/peep/peep.h @@ -374,12 +374,6 @@ enum { PEEP_RIDE_DECISION_THINKING = 1 << 2 }; -// Flags used by peep->list_flags -enum { - PEEP_LIST_FLAGS_VISIBLE = 1 << 8, // Peep is eligible to show in summarized guest list window (is inside park?) - PEEP_LIST_FLAGS_FLASHING = 1 << 9, // Peep belongs to highlighted group (flashes red on map) -}; - typedef struct { uint8 type; //0 uint8 item; //1 @@ -397,7 +391,7 @@ typedef struct { // Height from center of sprite to bottom uint8 sprite_height_negative; // 0x09 uint16 sprite_index; // 0x0A - uint16 list_flags; // 0x0C Used for highlighting peeps on map with staff list or guest list open + uint16 sprite_flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 7b7d458ce0..0512300756 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -2503,7 +2503,7 @@ static void vehicle_update_collision_setup(rct_vehicle* vehicle) { ); } - train->var_0C |= (1 << 7); + train->sprite_flags |= SPRITE_FLAGS_IS_CRASHED_VEHICLE_SPRITE; train->var_C8 = scenario_rand(); train->var_CA = scenario_rand(); @@ -4095,7 +4095,7 @@ static void vehicle_crash_on_land(rct_vehicle* vehicle) { while (numParticles-- != 0) crashed_vehicle_particle_create(vehicle->colours, vehicle->x, vehicle->y, vehicle->z); - vehicle->var_0C |= (1 << 7); + vehicle->sprite_flags |= SPRITE_FLAGS_IS_CRASHED_VEHICLE_SPRITE; vehicle->var_C5 = 0; vehicle->var_C8 = 0; vehicle->sprite_width = 13; @@ -4147,7 +4147,7 @@ static void vehicle_crash_on_water(rct_vehicle* vehicle) { for (int i = 0; i < 10; ++i) crashed_vehicle_particle_create(vehicle->colours, vehicle->x - 4, vehicle->y + 8, vehicle->z); - vehicle->var_0C |= (1 << 7); + vehicle->sprite_flags |= SPRITE_FLAGS_IS_CRASHED_VEHICLE_SPRITE; vehicle->var_C5 = 0; vehicle->var_C8 = 0; vehicle->sprite_width = 13; diff --git a/src/ride/vehicle.h b/src/ride/vehicle.h index 150373ed71..f34d097413 100644 --- a/src/ride/vehicle.h +++ b/src/ride/vehicle.h @@ -90,7 +90,7 @@ typedef struct { // Height from center of sprite to bottom uint8 sprite_height_negative; // 0x09 uint16 sprite_index; // 0x0A - uint16 var_0C; + uint16 sprite_flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 diff --git a/src/windows/guest_list.c b/src/windows/guest_list.c index 7daa3e92a4..ba02320304 100644 --- a/src/windows/guest_list.c +++ b/src/windows/guest_list.c @@ -656,14 +656,14 @@ static void window_guest_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, // For each guest FOR_ALL_GUESTS(spriteIndex, peep) { - peep->list_flags &= ~(PEEP_LIST_FLAGS_FLASHING); + peep->sprite_flags &= ~(SPRITE_FLAGS_PEEP_FLASHING); if (peep->outside_of_park != 0) continue; if (_window_guest_list_selected_filter != -1) { if (window_guest_list_is_peep_in_filter(peep)) continue; RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) |= (1 << 0); - peep->list_flags |= PEEP_LIST_FLAGS_FLASHING; + peep->sprite_flags |= SPRITE_FLAGS_PEEP_FLASHING; } if (_window_guest_list_tracking_only && !(peep->flags & PEEP_FLAGS_TRACKING)) continue; @@ -842,11 +842,11 @@ static void window_guest_list_find_groups() // Set all guests to unassigned FOR_ALL_GUESTS(spriteIndex, peep) if (peep->outside_of_park == 0) - peep->list_flags |= PEEP_LIST_FLAGS_VISIBLE; + peep->sprite_flags |= SPRITE_FLAGS_PEEP_VISIBLE; // For each guest / group FOR_ALL_GUESTS(spriteIndex, peep) { - if (peep->outside_of_park != 0 || !(peep->list_flags & PEEP_LIST_FLAGS_VISIBLE)) + if (peep->outside_of_park != 0 || !(peep->sprite_flags & SPRITE_FLAGS_PEEP_VISIBLE)) continue; // New group, cap at 240 though @@ -857,7 +857,7 @@ static void window_guest_list_find_groups() int ax = peep->sprite_index; _window_guest_list_num_groups++; _window_guest_list_groups_num_guests[groupIndex] = 1; - peep->list_flags &= ~(PEEP_LIST_FLAGS_VISIBLE); + peep->sprite_flags &= ~(SPRITE_FLAGS_PEEP_VISIBLE); get_arguments_from_peep( peep, &_window_guest_list_groups_argument_1[groupIndex], &_window_guest_list_groups_argument_2[groupIndex]); RCT2_GLOBAL(0x00F1EDF6, uint32) = _window_guest_list_groups_argument_1[groupIndex]; @@ -869,7 +869,7 @@ static void window_guest_list_find_groups() // Find more peeps that belong to same group FOR_ALL_GUESTS(spriteIndex2, peep2) { - if (peep2->outside_of_park != 0 || !(peep2->list_flags & PEEP_LIST_FLAGS_VISIBLE)) + if (peep2->outside_of_park != 0 || !(peep2->sprite_flags & SPRITE_FLAGS_PEEP_VISIBLE)) continue; uint32 argument1, argument2; @@ -880,7 +880,7 @@ static void window_guest_list_find_groups() // Assign guest _window_guest_list_groups_num_guests[groupIndex]++; - peep2->list_flags &= ~(PEEP_LIST_FLAGS_VISIBLE); + peep2->sprite_flags &= ~(SPRITE_FLAGS_PEEP_VISIBLE); // Add face sprite, cap at 56 though if (_window_guest_list_groups_num_guests[groupIndex] >= 56) diff --git a/src/windows/map.c b/src/windows/map.c index 6beb32463a..92d5e0c229 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -1028,7 +1028,7 @@ static void window_map_paint_peep_overlay(rct_drawpixelinfo *dpi) color = 0x14; - if ((peep->list_flags & PEEP_LIST_FLAGS_FLASHING) != 0) { + if ((peep->sprite_flags & SPRITE_FLAGS_PEEP_FLASHING) != 0) { if (peep->type == PEEP_TYPE_STAFF) { if ((RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) & (1 << 3)) != 0) { color = 0x8A; diff --git a/src/windows/staff_list.c b/src/windows/staff_list.c index d4f519447e..b3cd0dc3ef 100644 --- a/src/windows/staff_list.c +++ b/src/windows/staff_list.c @@ -314,10 +314,10 @@ void window_staff_list_update(rct_window *w) widget_invalidate(w, WIDX_STAFF_LIST_HANDYMEN_TAB + RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8)); RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_MAP_FLASHING_FLAGS, uint16) |= (1 << 2); FOR_ALL_STAFF(spriteIndex, peep) { - peep->list_flags &= ~(PEEP_LIST_FLAGS_FLASHING); + peep->sprite_flags &= ~(SPRITE_FLAGS_PEEP_FLASHING); if (peep->staff_type == RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8)) { - peep->list_flags |= PEEP_LIST_FLAGS_FLASHING; + peep->sprite_flags |= SPRITE_FLAGS_PEEP_FLASHING; } } } diff --git a/src/world/balloon.c b/src/world/balloon.c index f05cebea6c..22659e3aa4 100644 --- a/src/world/balloon.c +++ b/src/world/balloon.c @@ -70,7 +70,7 @@ void balloon_press(rct_balloon *balloon) return; uint32 random = util_rand(); - if ((balloon->var_0A & 7) || (random & 0xFFFF) < 0x2000) { + if ((balloon->sprite_index & 7) || (random & 0xFFFF) < 0x2000) { balloon_pop(balloon); return; } diff --git a/src/world/duck.c b/src/world/duck.c index b44a5700f7..852ef6da40 100644 --- a/src/world/duck.c +++ b/src/world/duck.c @@ -167,7 +167,7 @@ static void duck_update_fly_to_water(rct_duck *duck) */ static void duck_update_swim(rct_duck *duck) { - if ((RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) + duck->var_0A) & 3) + if ((RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) + duck->sprite_index) & 3) return; uint32 randomNumber = scenario_rand(); diff --git a/src/world/sprite.c b/src/world/sprite.c index 60ce0a7caf..b28049fd9a 100644 --- a/src/world/sprite.c +++ b/src/world/sprite.c @@ -212,7 +212,7 @@ rct_sprite *create_sprite(uint8 bl) sprite->sprite_width = 0x10; sprite->sprite_height_negative = 0x14; sprite->sprite_height_positive = 0x8; - sprite->var_0C = 0; + sprite->sprite_flags = 0; sprite->sprite_left = SPRITE_LOCATION_NULL; sprite->next_in_quadrant = RCT2_ADDRESS(0xF1EF60, uint16)[0x10000]; diff --git a/src/world/sprite.h b/src/world/sprite.h index 5b9d02bf63..cbf39283b8 100644 --- a/src/world/sprite.h +++ b/src/world/sprite.h @@ -56,7 +56,7 @@ typedef struct { // Height from center of sprite to bottom uint8 sprite_height_negative; // 0x09 uint16 sprite_index; // 0x0A - uint16 var_0C; + uint16 sprite_flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 @@ -88,7 +88,7 @@ typedef struct { uint8 linked_list_type_offset; // 0x08 Valid values are SPRITE_LINKEDLIST_OFFSET_... uint8 sprite_height_negative; // 0x09 uint16 sprite_index; // 0x0A - uint16 pad_0C; + uint16 sprite_flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 @@ -108,8 +108,8 @@ typedef struct { uint16 previous; // 0x06 uint8 linked_list_type_offset; // 0x08 Valid values are SPRITE_LINKEDLIST_OFFSET_... uint8 var_09; // 0x09 - uint16 var_0A; - uint8 pad_0C[0x2]; + uint16 sprite_index; // 0x0A + uint16 sprite_flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 @@ -137,8 +137,8 @@ typedef struct { uint16 previous; // 0x06 uint8 linked_list_type_offset; // 0x08 Valid values are SPRITE_LINKEDLIST_OFFSET_... uint8 var_09; // 0x09 - uint16 var_0A; - uint8 pad_0C[0x2]; + uint16 sprite_index; // 0x0A + uint16 sprite_flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 @@ -163,7 +163,8 @@ typedef struct { uint16 previous; // 0x06 uint8 linked_list_type_offset; // 0x08 Valid values are SPRITE_LINKEDLIST_OFFSET_... uint8 var_09; - uint8 pad_0A[0x4]; + uint16 sprite_index; // 0x0A + uint16 sprite_flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 @@ -196,7 +197,8 @@ typedef struct { uint16 previous; // 0x06 uint8 linked_list_type_offset; // 0x08 Valid values are SPRITE_LINKEDLIST_OFFSET_... uint8 var_09; - uint8 pad_0A[0x4]; + uint16 sprite_index; // 0x0A + uint16 sprite_flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 @@ -221,7 +223,7 @@ typedef struct { // Height from center of sprite to bottom uint8 sprite_height_negative; // 0x09 uint16 sprite_index; // 0x0A - uint16 var_0C; + uint16 sprite_flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 @@ -263,7 +265,7 @@ typedef struct { // Height from center of sprite to bottom uint8 sprite_height_negative; // 0x09 uint16 sprite_index; // 0x0A - uint16 var_0C; + uint16 sprite_flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 @@ -292,7 +294,7 @@ typedef struct { // Height from center of sprite to bottom uint8 sprite_height_negative; // 0x09 uint16 sprite_index; // 0x0A - uint16 var_0C; + uint16 sprite_flags; // 0x0C sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 @@ -360,6 +362,12 @@ enum { SPRITE_MISC_JUMPING_FOUNTAIN_SNOW }; +enum { + SPRITE_FLAGS_IS_CRASHED_VEHICLE_SPRITE = 1 << 7, + SPRITE_FLAGS_PEEP_VISIBLE = 1 << 8, // Peep is eligible to show in summarized guest list window (is inside park?) + SPRITE_FLAGS_PEEP_FLASHING = 1 << 9, // Peep belongs to highlighted group (flashes red on map) +}; + // rct2: 0x010E63BC extern rct_sprite* g_sprite_list;