1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 19:13:07 +01:00

Update UpdateSpriteType

This commit is contained in:
duncanspumpkin
2018-04-04 19:18:49 +01:00
parent 5d7da79702
commit 82884396f4
4 changed files with 70 additions and 72 deletions

View File

@@ -314,7 +314,7 @@ static void cheat_set_guest_parameter(sint32 parameter, sint32 value)
peep->intensity = (15 << 4) | value;
break;
}
peep_update_sprite_type(peep);
peep->UpdateSpriteType();
}
}
@@ -336,12 +336,12 @@ static void cheat_give_all_guests(sint32 object)
case OBJECT_BALLOON:
peep->item_standard_flags |= PEEP_ITEM_BALLOON;
peep->balloon_colour = scenario_rand_max(COLOUR_COUNT - 1);
peep_update_sprite_type(peep);
peep->UpdateSpriteType();
break;
case OBJECT_UMBRELLA:
peep->item_standard_flags |= PEEP_ITEM_UMBRELLA;
peep->umbrella_colour = scenario_rand_max(COLOUR_COUNT - 1);
peep_update_sprite_type(peep);
peep->UpdateSpriteType();
break;
}
}

View File

@@ -456,7 +456,7 @@ void rct_peep::Tick128UpdateGuest(sint32 index)
}
}
peep_update_sprite_type(this);
UpdateSpriteType();
if (state == PEEP_STATE_ON_RIDE || state == PEEP_STATE_ENTERING_RIDE)
{
@@ -774,7 +774,7 @@ void rct_peep::Tick128UpdateGuest(sint32 index)
}
window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY;
peep_update_sprite_type(this);
UpdateSpriteType();
}
else
{
@@ -792,7 +792,7 @@ void rct_peep::Tick128UpdateGuest(sint32 index)
}
window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY;
peep_update_sprite_type(this);
UpdateSpriteType();
}
}
}
@@ -1412,7 +1412,7 @@ loc_69B221:
photo4_ride_ref = rideIndex;
window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY;
peep_update_sprite_type(this);
UpdateSpriteType();
if (peep_flags & PEEP_FLAGS_TRACKING)
{
set_format_arg(0, rct_string_id, name_string_idx);
@@ -5243,7 +5243,7 @@ void rct_peep::UpdateWalking()
}
window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY;
peep_update_sprite_type(this);
UpdateSpriteType();
sint32 litterX = x + (scenario_rand() & 0x7) - 3;
sint32 litterY = y + (scenario_rand() & 0x7) - 3;
@@ -5641,7 +5641,7 @@ void rct_peep::UpdateWatching()
sub_state++;
time_to_stand = Math::Clamp(0, ((129 - energy) * 16 + 50) / 2, 255);
peep_update_sprite_type(this);
UpdateSpriteType();
}
else if (sub_state == 1)
{
@@ -5705,7 +5705,7 @@ void rct_peep::UpdateWatching()
return;
SetState(PEEP_STATE_WALKING);
peep_update_sprite_type(this);
UpdateSpriteType();
// Send peep to the centre of current tile.
destination_x = (x & 0xFFE0) + 16;
destination_y = (y & 0xFFE0) + 16;
@@ -5807,7 +5807,7 @@ void rct_peep::UpdateUsingBin()
space_left_in_bin--;
item_standard_flags &= ~(1 << cur_container);
window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY;
peep_update_sprite_type(this);
UpdateSpriteType();
continue;
}
uint8 bp = item_standard_litter[cur_container];
@@ -5819,7 +5819,7 @@ void rct_peep::UpdateUsingBin()
item_standard_flags &= ~(1 << cur_container);
window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY;
peep_update_sprite_type(this);
UpdateSpriteType();
}
// Original bug: This would clear any rubbish placed by the previous function
@@ -5841,7 +5841,7 @@ void rct_peep::UpdateUsingBin()
item_extra_flags &= ~(1 << cur_container);
window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY;
peep_update_sprite_type(this);
UpdateSpriteType();
continue;
}
uint8 bp = item_extra_litter[cur_container];
@@ -5853,7 +5853,7 @@ void rct_peep::UpdateUsingBin()
item_extra_flags &= ~(1 << cur_container);
window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY;
peep_update_sprite_type(this);
UpdateSpriteType();
}
// Place new amount in bin by first clearing the value

View File

@@ -737,39 +737,39 @@ void peep_decrement_num_riders(rct_peep * peep)
}
/* Part of 0x0069B8CC rct2: 0x0069BC31 */
static void set_sprite_type(rct_peep * peep, uint8 type)
void rct_peep::SetSpriteType(uint8 new_sprite_type)
{
if (peep->sprite_type == type)
if (sprite_type == new_sprite_type)
return;
peep->sprite_type = type;
peep->action_sprite_image_offset = 0;
peep->no_action_frame_num = 0;
sprite_type = new_sprite_type;
action_sprite_image_offset = 0;
no_action_frame_num = 0;
if (peep->action >= PEEP_ACTION_NONE_1)
peep->action = PEEP_ACTION_NONE_2;
if (action >= PEEP_ACTION_NONE_1)
action = PEEP_ACTION_NONE_2;
peep->peep_flags &= ~PEEP_FLAGS_SLOW_WALK;
assert(type < Util::CountOf(gSpriteTypeToSlowWalkMap));
if (gSpriteTypeToSlowWalkMap[type])
peep_flags &= ~PEEP_FLAGS_SLOW_WALK;
assert(new_sprite_type < Util::CountOf(gSpriteTypeToSlowWalkMap));
if (gSpriteTypeToSlowWalkMap[new_sprite_type])
{
peep->peep_flags |= PEEP_FLAGS_SLOW_WALK;
peep_flags |= PEEP_FLAGS_SLOW_WALK;
}
peep->action_sprite_type = 0xFF;
peep->UpdateCurrentActionSpriteType();
action_sprite_type = 0xFF;
UpdateCurrentActionSpriteType();
if (peep->state == PEEP_STATE_SITTING)
if (state == PEEP_STATE_SITTING)
{
peep->action = PEEP_ACTION_NONE_1;
peep->next_action_sprite_type = 7;
peep->SwitchNextActionSpriteType();
action = PEEP_ACTION_NONE_1;
next_action_sprite_type = 7;
SwitchNextActionSpriteType();
}
if (peep->state == PEEP_STATE_WATCHING)
if (state == PEEP_STATE_WATCHING)
{
peep->action = PEEP_ACTION_NONE_1;
peep->next_action_sprite_type = 2;
peep->SwitchNextActionSpriteType();
action = PEEP_ACTION_NONE_1;
next_action_sprite_type = 2;
SwitchNextActionSpriteType();
}
}
@@ -821,43 +821,40 @@ static item_pref_t item_order_preference[] = {
*
* rct2: 0x0069B8CC
*/
void peep_update_sprite_type(rct_peep * peep)
void rct_peep::UpdateSpriteType()
{
if (peep->sprite_type == PEEP_SPRITE_TYPE_BALLOON && (scenario_rand() & 0xFFFF) <= 327)
if (sprite_type == PEEP_SPRITE_TYPE_BALLOON && (scenario_rand() & 0xFFFF) <= 327)
{
bool isBalloonPopped = false;
if (peep->x != LOCATION_NULL)
if (x != LOCATION_NULL)
{
if ((scenario_rand() & 0xFFFF) <= 13107)
{
isBalloonPopped = true;
audio_play_sound_at_location(SOUND_BALLOON_POP, peep->x, peep->y, peep->z);
audio_play_sound_at_location(SOUND_BALLOON_POP, x, y, z);
}
create_balloon(peep->x, peep->y, peep->z + 9, peep->balloon_colour, isBalloonPopped);
create_balloon(x, y, z + 9, balloon_colour, isBalloonPopped);
}
peep->item_standard_flags &= ~PEEP_ITEM_BALLOON;
peep->window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY;
item_standard_flags &= ~PEEP_ITEM_BALLOON;
window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY;
}
if (climate_is_raining() && (peep->item_standard_flags & PEEP_ITEM_UMBRELLA) && peep->x != LOCATION_NULL)
if (climate_is_raining() && (item_standard_flags & PEEP_ITEM_UMBRELLA) && x != LOCATION_NULL)
{
sint32 x = peep->x & 0xFFE0;
sint32 y = peep->y & 0xFFE0;
if (x < 0x1FFF && y < 0x1FFF)
if ((x & 0xFFE0) < 0x1FFF && (y & 0xFFE0) < 0x1FFF)
{
rct_tile_element * tile_element = map_get_first_element_at(x / 32, y / 32);
rct_tile_element * tileElement = map_get_first_element_at(x / 32, y / 32);
while (true)
{
if ((peep->z / 8) < tile_element->base_height)
if ((z / 8) < tileElement->base_height)
break;
if (tile_element_is_last_for_tile(tile_element))
if (tile_element_is_last_for_tile(tileElement))
{
set_sprite_type(peep, PEEP_SPRITE_TYPE_UMBRELLA);
SetSpriteType(PEEP_SPRITE_TYPE_UMBRELLA);
return;
}
tile_element++;
tileElement++;
}
}
}
@@ -866,59 +863,59 @@ void peep_update_sprite_type(rct_peep * peep)
{
if (item_pref->type == 0)
{
if (peep->item_standard_flags & item_pref->item)
if (item_standard_flags & item_pref->item)
{
set_sprite_type(peep, item_pref->sprite_type);
SetSpriteType(item_pref->sprite_type);
return;
}
}
else
{
if (peep->item_extra_flags & item_pref->item)
if (item_extra_flags & item_pref->item)
{
set_sprite_type(peep, item_pref->sprite_type);
SetSpriteType(item_pref->sprite_type);
return;
}
}
}
if (peep->state == PEEP_STATE_WATCHING && peep->standing_flags & (1 << 1))
if (state == PEEP_STATE_WATCHING && standing_flags & (1 << 1))
{
set_sprite_type(peep, PEEP_SPRITE_TYPE_WATCHING);
SetSpriteType(PEEP_SPRITE_TYPE_WATCHING);
return;
}
if (peep->nausea > 170)
if (nausea > 170)
{
set_sprite_type(peep, PEEP_SPRITE_TYPE_VERY_NAUSEOUS);
SetSpriteType(PEEP_SPRITE_TYPE_VERY_NAUSEOUS);
return;
}
if (peep->nausea > 140)
if (nausea > 140)
{
set_sprite_type(peep, PEEP_SPRITE_TYPE_NAUSEOUS);
SetSpriteType(PEEP_SPRITE_TYPE_NAUSEOUS);
return;
}
if (peep->energy <= 64 && peep->happiness < 128)
if (energy <= 64 && happiness < 128)
{
set_sprite_type(peep, PEEP_SPRITE_TYPE_HEAD_DOWN);
SetSpriteType(PEEP_SPRITE_TYPE_HEAD_DOWN);
return;
}
if (peep->energy <= 80 && peep->happiness < 128)
if (energy <= 80 && happiness < 128)
{
set_sprite_type(peep, PEEP_SPRITE_TYPE_ARMS_CROSSED);
SetSpriteType(PEEP_SPRITE_TYPE_ARMS_CROSSED);
return;
}
if (peep->toilet > 220)
if (toilet > 220)
{
set_sprite_type(peep, PEEP_SPRITE_TYPE_REQUIRE_BATHROOM);
SetSpriteType(PEEP_SPRITE_TYPE_REQUIRE_BATHROOM);
return;
}
set_sprite_type(peep, PEEP_SPRITE_TYPE_NORMAL);
SetSpriteType(PEEP_SPRITE_TYPE_NORMAL);
}
/**
@@ -3545,7 +3542,7 @@ static void peep_give_passing_peeps_ice_cream(rct_peep * peep, rct_peep * otherP
return;
otherPeep->item_standard_flags |= PEEP_ITEM_ICE_CREAM;
peep_update_sprite_type(otherPeep);
otherPeep->UpdateSpriteType();
}
/**
@@ -4154,7 +4151,7 @@ static void peep_release_balloon(rct_peep * peep, sint16 spawn_height)
{
create_balloon(peep->x, peep->y, spawn_height, peep->balloon_colour, false);
peep->window_invalidate_flags |= PEEP_INVALIDATE_PEEP_INVENTORY;
peep_update_sprite_type(peep);
peep->UpdateSpriteType();
}
}
}

View File

@@ -718,6 +718,7 @@ public: // Guest
void OnEnterRide(uint8 rideIndex);
void OnExitRide(uint8 rideIndex);
void RemoveFromRide();
void UpdateSpriteType();
bool HeadingForRideOrParkExit() const;
public: // Staff
void Tick128UpdateStaff();
@@ -799,6 +800,7 @@ public: // Guest
void CheckCantFindRide();
void CheckCantFindExit();
bool DecideAndBuyItem(uint8 rideIndex, sint32 shopItem, money32 price);
void SetSpriteType(uint8 new_sprite_type);
};
assert_struct_size(rct_peep, 0x100);
#pragma pack(pop)
@@ -924,7 +926,6 @@ bool peep_pickup_command(uint32 peepnum, sint32 x, sint32 y, sint32 z, sin
void game_command_pickup_guest(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi,
sint32 * ebp);
void peep_sprite_remove(rct_peep * peep);
void peep_update_sprite_type(rct_peep * peep);
void peep_window_state_update(rct_peep * peep);
void peep_decrement_num_riders(rct_peep * peep);