mirror of https://github.com/OpenRCT2/OpenRCT2.git
Make more global functions part of rct_peep
This commit is contained in:
parent
1590bc8e6f
commit
afac7f6557
|
@ -4033,7 +4033,8 @@ static void window_ride_maintenance_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
|||
gfx_draw_string_left_wrapped(dpi, nullptr, x + 4, y, 280, stringId, COLOUR_BLACK);
|
||||
} else {
|
||||
rct_peep *mechanicSprite = &(get_sprite(ride->mechanic)->peep);
|
||||
if (peep_is_mechanic(mechanicSprite)) {
|
||||
if (mechanicSprite->IsMechanic())
|
||||
{
|
||||
set_format_arg(0, rct_string_id, mechanicSprite->name_string_idx);
|
||||
set_format_arg(2, uint32, mechanicSprite->id);
|
||||
gfx_draw_string_left_wrapped(dpi, gCommonFormatArgs, x + 4, y, 280, stringId, COLOUR_BLACK);
|
||||
|
|
|
@ -757,57 +757,51 @@ void peep_window_state_update(rct_peep * peep)
|
|||
}
|
||||
}
|
||||
|
||||
void peep_pickup(rct_peep * peep)
|
||||
void rct_peep::Pickup()
|
||||
{
|
||||
peep->RemoveFromRide();
|
||||
peep->Invalidate();
|
||||
RemoveFromRide();
|
||||
Invalidate();
|
||||
|
||||
sprite_move(LOCATION_NULL, peep->y, peep->z, (rct_sprite *)peep);
|
||||
peep->SetState(PEEP_STATE_PICKED);
|
||||
peep->sub_state = 0;
|
||||
sprite_move(LOCATION_NULL, y, z, (rct_sprite *)this);
|
||||
SetState(PEEP_STATE_PICKED);
|
||||
sub_state = 0;
|
||||
}
|
||||
|
||||
void peep_pickup_abort(rct_peep * peep, sint32 old_x)
|
||||
void rct_peep::PickupAbort(sint32 old_x)
|
||||
{
|
||||
if (!peep)
|
||||
if (state != PEEP_STATE_PICKED)
|
||||
return;
|
||||
|
||||
if (peep->state != PEEP_STATE_PICKED)
|
||||
return;
|
||||
sprite_move(old_x, y, z + 8, (rct_sprite *)this);
|
||||
Invalidate();
|
||||
|
||||
sprite_move(old_x, peep->y, peep->z + 8, (rct_sprite *)peep);
|
||||
peep->Invalidate();
|
||||
|
||||
if (peep->x != (sint16)LOCATION_NULL)
|
||||
if (x != (sint16)LOCATION_NULL)
|
||||
{
|
||||
peep->SetState(PEEP_STATE_FALLING);
|
||||
peep->action = 0xFF;
|
||||
peep->special_sprite = 0;
|
||||
peep->action_sprite_image_offset = 0;
|
||||
peep->action_sprite_type = 0;
|
||||
peep->path_check_optimisation = 0;
|
||||
SetState(PEEP_STATE_FALLING);
|
||||
action = 0xFF;
|
||||
special_sprite = 0;
|
||||
action_sprite_image_offset = 0;
|
||||
action_sprite_type = 0;
|
||||
path_check_optimisation = 0;
|
||||
}
|
||||
|
||||
gPickupPeepImage = UINT32_MAX;
|
||||
}
|
||||
|
||||
bool peep_pickup_place(rct_peep * peep, sint32 x, sint32 y, sint32 z, bool apply)
|
||||
bool rct_peep::Place(sint32 posX, sint32 posY, sint32 posZ, bool apply)
|
||||
{
|
||||
if (!peep)
|
||||
return false;
|
||||
|
||||
rct_tile_element * tileElement = map_get_path_element_at(x / 32, y / 32, z);
|
||||
rct_tile_element * tileElement = map_get_path_element_at(posX / 32, posY / 32, posZ);
|
||||
|
||||
if (!tileElement)
|
||||
{
|
||||
tileElement = map_get_surface_element_at({x, y});
|
||||
tileElement = map_get_surface_element_at({ posX, posY });
|
||||
}
|
||||
|
||||
if (!tileElement)
|
||||
return false;
|
||||
|
||||
sint32 dest_x = x & 0xFFE0;
|
||||
sint32 dest_y = y & 0xFFE0;
|
||||
sint32 dest_x = posX & 0xFFE0;
|
||||
sint32 dest_y = posY & 0xFFE0;
|
||||
|
||||
// Set the coordinate of destination to be exactly
|
||||
// in the middle of a tile.
|
||||
|
@ -839,21 +833,21 @@ bool peep_pickup_place(rct_peep * peep, sint32 x, sint32 y, sint32 z, bool apply
|
|||
|
||||
if (apply)
|
||||
{
|
||||
sprite_move(dest_x, dest_y, dest_z, (rct_sprite *)peep);
|
||||
peep->Invalidate();
|
||||
peep->SetState(PEEP_STATE_FALLING);
|
||||
peep->action = 0xFF;
|
||||
peep->special_sprite = 0;
|
||||
peep->action_sprite_image_offset = 0;
|
||||
peep->action_sprite_type = 0;
|
||||
peep->path_check_optimisation = 0;
|
||||
sprite_move(dest_x, dest_y, dest_z, (rct_sprite *)this);
|
||||
Invalidate();
|
||||
SetState(PEEP_STATE_FALLING);
|
||||
action = 0xFF;
|
||||
special_sprite = 0;
|
||||
action_sprite_image_offset = 0;
|
||||
action_sprite_type = 0;
|
||||
path_check_optimisation = 0;
|
||||
sprite_position_tween_reset();
|
||||
|
||||
if (peep->type == PEEP_TYPE_GUEST)
|
||||
if (type == PEEP_TYPE_GUEST)
|
||||
{
|
||||
peep->action_sprite_type = 0xFF;
|
||||
peep->happiness_target = Math::Max(peep->happiness_target - 10, 0);
|
||||
peep->UpdateCurrentActionSpriteType();
|
||||
action_sprite_type = 0xFF;
|
||||
happiness_target = Math::Max(happiness_target - 10, 0);
|
||||
UpdateCurrentActionSpriteType();
|
||||
}
|
||||
|
||||
network_set_pickup_peep(game_command_playerid, nullptr);
|
||||
|
@ -869,11 +863,13 @@ bool peep_pickup_command(uint32 peepnum, sint32 x, sint32 y, sint32 z, sint32 ac
|
|||
log_error("Failed to pick up peep for sprite %d", peepnum);
|
||||
return false;
|
||||
}
|
||||
rct_peep * peep = GET_PEEP(peepnum);
|
||||
|
||||
rct_peep * const peep = GET_PEEP(peepnum);
|
||||
if (!peep || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case 0: // pickup
|
||||
|
@ -898,18 +894,25 @@ bool peep_pickup_command(uint32 peepnum, sint32 x, sint32 y, sint32 z, sint32 ac
|
|||
input_set_flag(INPUT_FLAG_TOOL_ACTIVE, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (apply)
|
||||
{
|
||||
network_set_pickup_peep(game_command_playerid, peep);
|
||||
network_set_pickup_peep_old_x(game_command_playerid, peep->x);
|
||||
peep_pickup(peep);
|
||||
peep->Pickup();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1: // cancel
|
||||
if (apply)
|
||||
{
|
||||
peep_pickup_abort(network_get_pickup_peep(game_command_playerid), x);
|
||||
// TODO: Verify if this is really needed or that we can use `peep` instead
|
||||
rct_peep * const pickedUpPeep = network_get_pickup_peep(game_command_playerid);
|
||||
if (pickedUpPeep)
|
||||
{
|
||||
pickedUpPeep->PickupAbort(x);
|
||||
}
|
||||
|
||||
network_set_pickup_peep(game_command_playerid, nullptr);
|
||||
}
|
||||
break;
|
||||
|
@ -918,7 +921,8 @@ bool peep_pickup_command(uint32 peepnum, sint32 x, sint32 y, sint32 z, sint32 ac
|
|||
{
|
||||
return false;
|
||||
}
|
||||
if (!peep_pickup_place(peep, x, y, z, apply))
|
||||
|
||||
if (!peep->Place(x, y, z, apply))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -2252,12 +2256,6 @@ sint32 peep_get_easteregg_name_id(rct_peep * peep)
|
|||
return -1;
|
||||
}
|
||||
|
||||
sint32 peep_is_mechanic(rct_peep * peep)
|
||||
{
|
||||
return (peep->sprite_identifier == SPRITE_IDENTIFIER_PEEP && peep->type == PEEP_TYPE_STAFF &&
|
||||
peep->staff_type == STAFF_TYPE_MECHANIC);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x699F5A
|
||||
|
|
|
@ -714,6 +714,9 @@ public: // Peep
|
|||
bool GetNextIsSloped() const;
|
||||
bool GetNextIsSurface() const;
|
||||
void SetNextFlags(uint8 next_direction, bool is_sloped, bool is_surface);
|
||||
void Pickup();
|
||||
void PickupAbort(sint32 old_x);
|
||||
bool Place(sint32 x, sint32 y, sint32 z, bool apply);
|
||||
public: // Guest
|
||||
void Tick128UpdateGuest(sint32 index);
|
||||
void RemoveFromQueue();
|
||||
|
@ -728,6 +731,7 @@ public: // Guest
|
|||
bool HeadingForRideOrParkExit() const;
|
||||
public: // Staff
|
||||
void Tick128UpdateStaff();
|
||||
bool IsMechanic() const;
|
||||
|
||||
private: // Peep update
|
||||
void UpdateFalling();
|
||||
|
@ -940,10 +944,6 @@ sint32 get_peep_face_sprite_small(rct_peep * peep);
|
|||
sint32 get_peep_face_sprite_large(rct_peep * peep);
|
||||
sint32 peep_check_easteregg_name(sint32 index, rct_peep * peep);
|
||||
sint32 peep_get_easteregg_name_id(rct_peep * peep);
|
||||
sint32 peep_is_mechanic(rct_peep * peep);
|
||||
void peep_pickup(rct_peep * peep);
|
||||
void peep_pickup_abort(rct_peep * peep, sint32 old_x);
|
||||
bool peep_pickup_place(rct_peep * peep, sint32 x, sint32 y, sint32 z, bool apply);
|
||||
bool peep_pickup_command(uint32 peepnum, sint32 x, sint32 y, sint32 z, sint32 action, bool apply);
|
||||
void game_command_pickup_guest(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi,
|
||||
sint32 * ebp);
|
||||
|
|
|
@ -2339,6 +2339,11 @@ void rct_peep::Tick128UpdateStaff()
|
|||
UpdateCurrentActionSpriteType();
|
||||
}
|
||||
|
||||
bool rct_peep::IsMechanic() const
|
||||
{
|
||||
return (sprite_identifier == SPRITE_IDENTIFIER_PEEP && type == PEEP_TYPE_STAFF && staff_type == STAFF_TYPE_MECHANIC);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006BF1FD
|
||||
|
|
|
@ -2604,7 +2604,7 @@ static void ride_mechanic_status_update(sint32 rideIndex, sint32 mechanicStatus)
|
|||
mechanic = &(get_sprite(ride->mechanic)->peep);
|
||||
}
|
||||
if (mechanic == nullptr ||
|
||||
!peep_is_mechanic(mechanic) ||
|
||||
!mechanic->IsMechanic() ||
|
||||
(mechanic->state != PEEP_STATE_HEADING_TO_INSPECTION && mechanic->state != PEEP_STATE_ANSWERING) ||
|
||||
mechanic->current_ride != rideIndex
|
||||
) {
|
||||
|
@ -2619,7 +2619,7 @@ static void ride_mechanic_status_update(sint32 rideIndex, sint32 mechanicStatus)
|
|||
mechanic = &(get_sprite(ride->mechanic)->peep);
|
||||
}
|
||||
if (mechanic == nullptr ||
|
||||
!peep_is_mechanic(mechanic) ||
|
||||
!mechanic->IsMechanic() ||
|
||||
(
|
||||
mechanic->state != PEEP_STATE_HEADING_TO_INSPECTION &&
|
||||
mechanic->state != PEEP_STATE_FIXING &&
|
||||
|
@ -2762,7 +2762,7 @@ rct_peep *ride_get_assigned_mechanic(Ride *ride)
|
|||
ride->mechanic_status == RIDE_MECHANIC_STATUS_HAS_FIXED_STATION_BRAKES
|
||||
) {
|
||||
rct_peep *peep = &(get_sprite(ride->mechanic)->peep);
|
||||
if (peep_is_mechanic(peep))
|
||||
if (peep->IsMechanic())
|
||||
return peep;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue