mirror of https://github.com/OpenRCT2/OpenRCT2.git
Use PEEP_ACTION_EVENTS enum for rct_peep::action field
Use the PEEP_ACTION_EVENTS enum for the rct_peep::action field explicitly, so that we get type safety on it from the compiler and debugger. In the process, force PEEP_ACTION_EVENTS to be of size uint8_t, and use named constants for NONE actions instead of magic numbers in a few places.
This commit is contained in:
parent
88b86eb0c1
commit
e1016bf71e
|
@ -3246,7 +3246,7 @@ void rct_peep::UpdateBuying()
|
|||
|
||||
if (sub_state == 1)
|
||||
{
|
||||
if (action != 0xFF)
|
||||
if (action != PEEP_ACTION_NONE_2)
|
||||
{
|
||||
int16_t actionX;
|
||||
int16_t actionY;
|
||||
|
@ -5475,7 +5475,7 @@ void rct_peep::UpdateQueuing()
|
|||
|
||||
uint8_t pathingResult;
|
||||
PerformNextAction(pathingResult);
|
||||
if (action < 0xFE)
|
||||
if (action < PEEP_ACTION_NONE_1)
|
||||
return;
|
||||
if (sprite_type == PEEP_SPRITE_TYPE_NORMAL)
|
||||
{
|
||||
|
@ -5496,7 +5496,7 @@ void rct_peep::UpdateQueuing()
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!(time_in_queue & 0x3F) && action == 0xFE && next_action_sprite_type == 2)
|
||||
if (!(time_in_queue & 0x3F) && action == PEEP_ACTION_NONE_1 && next_action_sprite_type == 2)
|
||||
{
|
||||
switch (sprite_type)
|
||||
{
|
||||
|
@ -5644,7 +5644,7 @@ void rct_peep::UpdateWatching()
|
|||
sprite_direction = (var_37 & 3) * 8;
|
||||
Invalidate();
|
||||
|
||||
action = 0xFE;
|
||||
action = PEEP_ACTION_NONE_1;
|
||||
next_action_sprite_type = 2;
|
||||
|
||||
SwitchNextActionSpriteType();
|
||||
|
@ -5656,7 +5656,7 @@ void rct_peep::UpdateWatching()
|
|||
}
|
||||
else if (sub_state == 1)
|
||||
{
|
||||
if (action < 0xFE)
|
||||
if (action < PEEP_ACTION_NONE_1)
|
||||
{
|
||||
// 6917F6
|
||||
int16_t actionX = 0;
|
||||
|
@ -5664,9 +5664,9 @@ void rct_peep::UpdateWatching()
|
|||
int16_t xy_distance;
|
||||
UpdateAction(&actionX, &actionY, &xy_distance);
|
||||
|
||||
if (action != 0xFF)
|
||||
if (action != PEEP_ACTION_NONE_2)
|
||||
return;
|
||||
action = 0xFE;
|
||||
action = PEEP_ACTION_NONE_1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -114,7 +114,7 @@ static constexpr const char *gPeepEasterEggNames[] = {
|
|||
/** rct2: 0x00981DB0 */
|
||||
static struct
|
||||
{
|
||||
uint8_t action;
|
||||
PEEP_ACTION_EVENTS action;
|
||||
uint8_t flags;
|
||||
} PeepThoughtToActionMap[] = {
|
||||
{ PEEP_ACTION_SHAKE_HEAD, 1 },
|
||||
|
@ -654,7 +654,7 @@ bool rct_peep::UpdateAction(int16_t* actionX, int16_t* actionY, int16_t* xy_dist
|
|||
if (action_frame >= peepAnimation[action_sprite_type].num_frames)
|
||||
{
|
||||
action_sprite_image_offset = 0;
|
||||
action = 0xFF;
|
||||
action = PEEP_ACTION_NONE_2;
|
||||
UpdateCurrentActionSpriteType();
|
||||
Invalidate();
|
||||
*actionX = x;
|
||||
|
@ -760,7 +760,7 @@ void rct_peep::PickupAbort(int32_t old_x)
|
|||
if (x != (int16_t)LOCATION_NULL)
|
||||
{
|
||||
SetState(PEEP_STATE_FALLING);
|
||||
action = 0xFF;
|
||||
action = PEEP_ACTION_NONE_2;
|
||||
special_sprite = 0;
|
||||
action_sprite_image_offset = 0;
|
||||
action_sprite_type = 0;
|
||||
|
@ -814,7 +814,7 @@ bool rct_peep::Place(TileCoordsXYZ location, bool apply)
|
|||
sprite_move(destination.x, destination.y, destination.z, (rct_sprite*)this);
|
||||
Invalidate();
|
||||
SetState(PEEP_STATE_FALLING);
|
||||
action = 0xFF;
|
||||
action = PEEP_ACTION_NONE_2;
|
||||
special_sprite = 0;
|
||||
action_sprite_image_offset = 0;
|
||||
action_sprite_type = 0;
|
||||
|
@ -1231,7 +1231,7 @@ void rct_peep::Update()
|
|||
stepsToTake = 95;
|
||||
if ((peep_flags & PEEP_FLAGS_SLOW_WALK) && state != PEEP_STATE_QUEUING)
|
||||
stepsToTake /= 2;
|
||||
if (action == 255 && (GetNextIsSloped()))
|
||||
if (action == PEEP_ACTION_NONE_2 && (GetNextIsSloped()))
|
||||
{
|
||||
stepsToTake /= 2;
|
||||
if (state == PEEP_STATE_QUEUING)
|
||||
|
@ -2248,8 +2248,8 @@ int32_t peep_get_easteregg_name_id(rct_peep* peep)
|
|||
*/
|
||||
void peep_insert_new_thought(rct_peep* peep, uint8_t thought_type, uint8_t thought_arguments)
|
||||
{
|
||||
uint8_t action = PeepThoughtToActionMap[thought_type].action;
|
||||
if (action != 0xFF && peep->action >= 254)
|
||||
PEEP_ACTION_EVENTS action = PeepThoughtToActionMap[thought_type].action;
|
||||
if (action != PEEP_ACTION_NONE_2 && peep->action >= PEEP_ACTION_NONE_1)
|
||||
{
|
||||
peep->action = action;
|
||||
peep->action_frame = 0;
|
||||
|
@ -3127,7 +3127,7 @@ void rct_peep::PerformNextAction(uint8_t& pathing_result)
|
|||
void rct_peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result)
|
||||
{
|
||||
pathing_result = 0;
|
||||
uint8_t previousAction = action;
|
||||
PEEP_ACTION_EVENTS previousAction = action;
|
||||
|
||||
if (action == PEEP_ACTION_NONE_1)
|
||||
action = PEEP_ACTION_NONE_2;
|
||||
|
|
|
@ -249,7 +249,7 @@ enum PEEP_USING_BIN_SUB_STATE
|
|||
PEEP_USING_BIN_GOING_BACK,
|
||||
};
|
||||
|
||||
enum PEEP_ACTION_EVENTS
|
||||
enum PEEP_ACTION_EVENTS : uint8_t
|
||||
{
|
||||
PEEP_ACTION_CHECK_TIME = 0,
|
||||
// If no food then check watch
|
||||
|
@ -610,7 +610,7 @@ struct rct_peep
|
|||
// reads this again
|
||||
uint8_t next_action_sprite_type; // 0x6F
|
||||
uint8_t action_sprite_image_offset; // 0x70
|
||||
uint8_t action; // 0x71
|
||||
PEEP_ACTION_EVENTS action; // 0x71
|
||||
uint8_t action_frame; // 0x72
|
||||
uint8_t step_progress; // 0x73
|
||||
union
|
||||
|
|
|
@ -3092,7 +3092,7 @@ bool rct_peep::UpdateFixingFinishFixOrInspect(bool firstRun, int32_t steps, Ride
|
|||
Invalidate();
|
||||
}
|
||||
|
||||
if (action != 0xFF)
|
||||
if (action != PEEP_ACTION_NONE_2)
|
||||
{
|
||||
UpdateAction();
|
||||
return false;
|
||||
|
|
|
@ -1403,7 +1403,7 @@ private:
|
|||
dst->sprite_identifier = SPRITE_IDENTIFIER_PEEP;
|
||||
// Peep vs. staff (including which kind)
|
||||
dst->sprite_type = RCT1::GetPeepSpriteType(src->sprite_type);
|
||||
dst->action = src->action;
|
||||
dst->action = static_cast<PEEP_ACTION_EVENTS>(src->action);
|
||||
dst->special_sprite = src->special_sprite;
|
||||
dst->next_action_sprite_type = src->next_action_sprite_type;
|
||||
dst->action_sprite_image_offset = src->action_sprite_image_offset;
|
||||
|
|
Loading…
Reference in New Issue