Entity type5: Remove peep assigned type (#14380)

* Remove users of AssignedPeepType

* Remove AssignedPeepType

Field no longer required due to changes to EntityType

* Move enum to the RCT12 header

* Increment network version

* Update replays
This commit is contained in:
Duncan 2021-03-24 08:54:05 +00:00 committed by GitHub
parent a5a63f839a
commit 977d05ba29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 50 additions and 60 deletions

View File

@ -48,8 +48,8 @@ set(TITLE_SEQUENCE_SHA1 "304d13a126c15bf2c86ff13b81a2f2cc1856ac8d")
set(OBJECTS_URL "https://github.com/OpenRCT2/objects/releases/download/v1.0.21/objects.zip")
set(OBJECTS_SHA1 "c38af45d51a6e440386180feacf76c64720b6ac5")
set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v0.0.34/replays.zip")
set(REPLAYS_SHA1 "1EEC4382EB8D4CDCC3530E0F983D4412DFC77F6E")
set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v0.0.35/replays.zip")
set(REPLAYS_SHA1 "5875A182E2828B8E0234F496B5D5E84CFE25EFCB")
option(FORCE32 "Force 32-bit build. It will add `-m32` to compiler flags.")
option(WITH_TESTS "Build tests")

View File

@ -48,8 +48,8 @@
<TitleSequencesSha1>304d13a126c15bf2c86ff13b81a2f2cc1856ac8d</TitleSequencesSha1>
<ObjectsUrl>https://github.com/OpenRCT2/objects/releases/download/v1.0.21/objects.zip</ObjectsUrl>
<ObjectsSha1>c38af45d51a6e440386180feacf76c64720b6ac5</ObjectsSha1>
<ReplaysUrl>https://github.com/OpenRCT2/replays/releases/download/v0.0.34/replays.zip</ReplaysUrl>
<ReplaysSha1>1EEC4382EB8D4CDCC3530E0F983D4412DFC77F6E</ReplaysSha1>
<ReplaysUrl>https://github.com/OpenRCT2/replays/releases/download/v0.0.35/replays.zip</ReplaysUrl>
<ReplaysSha1>5875A182E2828B8E0234F496B5D5E84CFE25EFCB</ReplaysSha1>
</PropertyGroup>
<ItemGroup>

View File

@ -593,7 +593,7 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo* dpi, rc
auto clipCoords = ScreenCoordsXY{ 10, 19 };
if (peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == StaffType::Entertainer)
if (peep->Is<Staff>() && peep->AssignedStaffType == StaffType::Entertainer)
{
clipCoords.y += 3;
}

View File

@ -372,7 +372,7 @@ rct_window* window_guest_open(Peep* peep)
{
return nullptr;
}
if (peep->AssignedPeepType == PeepType::Staff)
if (peep->Is<Staff>())
{
return window_staff_open(peep);
}
@ -758,7 +758,7 @@ static void window_guest_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dp
return;
}
if (peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == StaffType::Entertainer)
if (peep->Is<Staff>() && peep->AssignedStaffType == StaffType::Entertainer)
screenCoords.y++;
int32_t animationFrame = GetPeepAnimation(peep->SpriteType).base_image + 1;

View File

@ -922,9 +922,9 @@ private:
if (peepA != nullptr && peepB != nullptr)
{
// Compare types
if (peepA->AssignedPeepType != peepB->AssignedPeepType)
if (peepA->Type != peepB->Type)
{
return static_cast<int32_t>(peepA->AssignedPeepType) < static_cast<int32_t>(peepB->AssignedPeepType);
return static_cast<int32_t>(peepA->Type) < static_cast<int32_t>(peepB->Type);
}
// Compare name

View File

@ -288,7 +288,7 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32
// If normal peep set sprite to normal (no food)
// If staff set sprite to staff sprite
auto spriteType = PeepSpriteType::Normal;
if (peep->AssignedPeepType == PeepType::Staff)
if (peep->Is<Staff>())
{
spriteType = peep->SpriteType;
if (peep->AssignedStaffType == StaffType::Entertainer)

View File

@ -1019,7 +1019,7 @@ void window_staff_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dpi)
return;
}
if (peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == StaffType::Entertainer)
if (peep->Is<Staff>() && peep->AssignedStaffType == StaffType::Entertainer)
screenCoords.y++;
int32_t ebx = GetPeepAnimation(peep->SpriteType).base_image + 1;

View File

@ -223,7 +223,6 @@ struct GameStateSnapshots final : public IGameStateSnapshots
COMPARE_FIELD(Peep, State);
COMPARE_FIELD(Peep, SubState);
COMPARE_FIELD(Peep, SpriteType);
COMPARE_FIELD(Peep, AssignedPeepType);
COMPARE_FIELD(Peep, GuestNumRides);
COMPARE_FIELD(Peep, TshirtColour);
COMPARE_FIELD(Peep, TrousersColour);

View File

@ -149,7 +149,6 @@ GameActions::Result::Ptr StaffHireNewAction::QueryExecute(bool execute) const
newPeep->WalkingFrameNum = 0;
newPeep->ActionSpriteType = PeepActionSpriteType::None;
newPeep->PathCheckOptimisation = 0;
newPeep->AssignedPeepType = PeepType::Staff;
newPeep->OutsideOfPark = false;
newPeep->PeepFlags = 0;
newPeep->PaidToEnter = 0;

View File

@ -679,9 +679,9 @@ void viewport_update_smart_sprite_follow(rct_window* window)
return;
}
if (peep->AssignedPeepType == PeepType::Guest)
if (peep->Is<Guest>())
viewport_update_smart_guest_follow(window, peep);
else if (peep->AssignedPeepType == PeepType::Staff)
else if (peep->Is<Staff>())
viewport_update_smart_staff_follow(window, peep);
}
else if (entity->Type == EntityType::Vehicle)

View File

@ -36,7 +36,7 @@
// This string specifies which version of network stream current build uses.
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "5"
#define NETWORK_STREAM_VERSION "6"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
static Peep* _pickup_peep = nullptr;

View File

@ -24,7 +24,7 @@ template<> void PaintEntity(paint_session* session, const Peep* peep, int32_t im
#ifdef __ENABLE_LIGHTFX__
if (lightfx_is_available())
{
if (peep->AssignedPeepType == PeepType::Staff)
if (peep->Is<Staff>())
{
int16_t peep_x, peep_y, peep_z;

View File

@ -48,10 +48,10 @@ void sprite_paint_setup(paint_session* session, const uint16_t x, const uint16_t
{
if (highlightPathIssues)
{
const auto peep = spr->As<Peep>();
if (peep != nullptr)
const auto staff = spr->As<Staff>();
if (staff != nullptr)
{
if (!(peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == StaffType::Handyman))
if (staff->AssignedStaffType != StaffType::Handyman)
{
continue;
}

View File

@ -481,7 +481,7 @@ static int32_t guest_path_find_aimless(Peep* peep, uint8_t edges)
*/
static uint8_t peep_pathfind_get_max_number_junctions(Peep* peep)
{
if (peep->AssignedPeepType == PeepType::Staff)
if (peep->Is<Staff>())
return 8;
// PEEP_FLAGS_2? It's cleared here but not set anywhere!
@ -1262,9 +1262,9 @@ Direction peep_pathfind_choose_direction(const TileCoordsXYZ& loc, Peep* peep)
/* The max number of tiles to check - a whole-search limit.
* Mainly to limit the performance impact of the path finding. */
int32_t maxTilesChecked = (peep->AssignedPeepType == PeepType::Staff) ? 50000 : 15000;
int32_t maxTilesChecked = (peep->Is<Staff>()) ? 50000 : 15000;
// Used to allow walking through no entry banners
_peepPathFindIsStaff = (peep->AssignedPeepType == PeepType::Staff);
_peepPathFindIsStaff = peep->Is<Staff>();
TileCoordsXYZ goal = gPeepPathFindGoalPosition;

View File

@ -708,7 +708,7 @@ void peep_window_state_update(Peep* peep)
if (w != nullptr)
window_event_invalidate_call(w);
if (peep->AssignedPeepType == PeepType::Guest)
if (peep->Is<Guest>())
{
if (peep->State == PeepState::OnRide || peep->State == PeepState::EnteringRide)
{
@ -810,7 +810,7 @@ std::unique_ptr<GameActions::Result> Peep::Place(const TileCoordsXYZ& location,
PathCheckOptimisation = 0;
EntityTweener::Get().Reset();
if (AssignedPeepType == PeepType::Guest)
if (Is<Guest>())
{
ActionSpriteType = PeepActionSpriteType::Invalid;
HappinessTarget = std::max(HappinessTarget - 10, 0);
@ -839,17 +839,15 @@ void peep_sprite_remove(Peep* peep)
window_close_by_number(WC_FIRE_PROMPT, EnumValue(peep->Type));
// Needed for invalidations after sprite removal
bool wasGuest = peep->AssignedPeepType == PeepType::Guest;
if (peep->AssignedPeepType == PeepType::Guest)
bool wasGuest = peep->Is<Guest>();
if (wasGuest)
{
News::DisableNewsItems(News::ItemType::PeepOnRide, peep->sprite_index);
}
else
{
gStaffModes[peep->StaffId] = StaffMode::None;
peep->AssignedPeepType = PeepType::Invalid;
staff_update_greyed_patrol_areas();
peep->AssignedPeepType = PeepType::Staff;
News::DisableNewsItems(News::ItemType::Peep, peep->sprite_index);
}
@ -864,7 +862,7 @@ void peep_sprite_remove(Peep* peep)
*/
void Peep::Remove()
{
if (AssignedPeepType == PeepType::Guest)
if (Is<Guest>())
{
if (!OutsideOfPark)
{
@ -1007,7 +1005,7 @@ void Peep::Update1()
if (!CheckForPath())
return;
if (AssignedPeepType == PeepType::Guest)
if (Is<Guest>())
{
SetState(PeepState::Walking);
}
@ -1109,7 +1107,7 @@ static void peep_update_thoughts(Peep* peep)
*/
void Peep::Update()
{
if (AssignedPeepType == PeepType::Guest)
if (Is<Guest>())
{
if (PreviousRide != RIDE_ID_NULL)
if (++PreviousRideTimeOut >= 720)
@ -1631,7 +1629,6 @@ Peep* Peep::Generate(const CoordsXYZ& coords)
peep->Mass = (scenario_rand() & 0x1F) + 45;
peep->PathCheckOptimisation = 0;
peep->InteractionRideIndex = RIDE_ID_NULL;
peep->AssignedPeepType = PeepType::Guest;
peep->PreviousRide = RIDE_ID_NULL;
peep->Thoughts->type = PeepThoughtType::None;
peep->WindowInvalidateFlags = 0;
@ -1951,7 +1948,7 @@ void Peep::FormatNameTo(Formatter& ft) const
{
if (Name == nullptr)
{
if (AssignedPeepType == PeepType::Staff)
if (Is<Staff>())
{
static constexpr const rct_string_id staffNames[] = {
STR_HANDYMAN_X,
@ -2155,7 +2152,7 @@ int32_t get_peep_face_sprite_large(Peep* peep)
void peep_set_map_tooltip(Peep* peep)
{
auto ft = Formatter();
if (peep->AssignedPeepType == PeepType::Guest)
if (peep->Is<Guest>())
{
ft.Add<rct_string_id>((peep->PeepFlags & PEEP_FLAGS_TRACKING) ? STR_TRACKED_GUEST_MAP_TIP : STR_GUEST_MAP_TIP);
ft.Add<uint32_t>(get_peep_face_sprite_small(peep));
@ -2596,7 +2593,7 @@ static void peep_footpath_move_forward(Peep* peep, const CoordsXYE& coords, bool
int16_t z = peep->GetZOnSlope(coords.x, coords.y);
if (peep->AssignedPeepType == PeepType::Staff)
if (peep->Is<Staff>())
{
peep->MoveTo({ coords, z });
return;
@ -3058,10 +3055,10 @@ void Peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result)
}
} while (!(tileElement++)->IsLastForTile());
if (AssignedPeepType == PeepType::Staff || (GetNextIsSurface()))
if (Is<Staff>() || (GetNextIsSurface()))
{
int16_t height = abs(tile_element_height(newLoc) - z);
if (height <= 3 || (AssignedPeepType == PeepType::Staff && height <= 32))
if (height <= 3 || (Is<Staff>() && height <= 32))
{
InteractionRideIndex = RIDE_ID_NULL;
if (State == PeepState::Queuing)
@ -3090,7 +3087,7 @@ void Peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result)
return;
}
if (AssignedPeepType == PeepType::Staff && !GetNextIsSurface())
if (Is<Staff>() && !GetNextIsSurface())
{
// Prevent staff from leaving the path on their own unless they're allowed to mow.
if (!((this->StaffOrders & STAFF_ORDERS_MOWING) && this->StaffMowingTimeout >= 12))
@ -3165,9 +3162,9 @@ int32_t peep_compare(const uint16_t sprite_index_a, const uint16_t sprite_index_
}
// Compare types
if (peep_a->AssignedPeepType != peep_b->AssignedPeepType)
if (peep_a->Type != peep_b->Type)
{
return static_cast<int32_t>(peep_a->AssignedPeepType) - static_cast<int32_t>(peep_b->AssignedPeepType);
return static_cast<int32_t>(peep_a->Type) - static_cast<int32_t>(peep_b->Type);
}
if (peep_a->Name == nullptr && peep_b->Name == nullptr)

View File

@ -56,14 +56,6 @@ namespace GameActions
}
using ParkEntranceIndex = uint8_t;
enum class PeepType : uint8_t
{
Guest,
Staff,
Invalid = 0xFF
};
enum class StaffType : uint8_t
{
Handyman,
@ -570,7 +562,6 @@ struct Peep : SpriteBase
PeepUsingBinSubState UsingBinSubState;
};
PeepSpriteType SpriteType;
PeepType AssignedPeepType;
union
{
StaffType AssignedStaffType;

View File

@ -1347,7 +1347,7 @@ private:
{
rct1_peep* srcPeep = &_s4.sprites[i].peep;
Peep* peep = nullptr;
if (static_cast<PeepType>(srcPeep->type) == PeepType::Guest)
if (static_cast<RCT12PeepType>(srcPeep->type) == RCT12PeepType::Guest)
{
peep = CreateEntity<Guest>();
}
@ -1447,8 +1447,6 @@ private:
dst->StepProgress = src->step_progress;
dst->VandalismSeen = src->vandalism_seen;
dst->AssignedPeepType = static_cast<PeepType>(src->type);
dst->TshirtColour = RCT1::GetColour(src->tshirt_colour);
dst->TrousersColour = RCT1::GetColour(src->trousers_colour);
dst->UmbrellaColour = RCT1::GetColour(src->umbrella_colour);
@ -1575,7 +1573,7 @@ private:
dst->SetItemFlags(src->GetItemFlags());
if (dst->AssignedPeepType == PeepType::Guest)
if (dst->Is<Guest>())
{
if (dst->OutsideOfPark && dst->State != PeepState::LeavingPark)
{

View File

@ -713,6 +713,14 @@ enum class RCT12MiscEntityType : uint8_t
JumpingFountainSnow
};
enum class RCT12PeepType : uint8_t
{
Guest,
Staff,
Invalid = 0xFF
};
struct RCT12SpriteBase
{
RCT12SpriteIdentifier sprite_identifier; // 0x00

View File

@ -1200,7 +1200,7 @@ void S6Exporter::ExportEntityPeep(RCT2SpritePeep* dst, const Peep* src)
}
if (generateName)
{
if (src->AssignedPeepType == PeepType::Staff)
if (src->Is<Staff>())
{
static constexpr const rct_string_id staffNames[] = {
STR_HANDYMAN_X,
@ -1228,7 +1228,7 @@ void S6Exporter::ExportEntityPeep(RCT2SpritePeep* dst, const Peep* src)
dst->state = static_cast<uint8_t>(src->State);
dst->sub_state = src->SubState;
dst->sprite_type = static_cast<uint8_t>(src->SpriteType);
dst->peep_type = static_cast<uint8_t>(src->AssignedPeepType);
dst->peep_type = static_cast<uint8_t>(src->Type == EntityType::Staff ? RCT12PeepType::Staff : RCT12PeepType::Guest);
dst->no_of_rides = src->GuestNumRides;
dst->tshirt_colour = src->TshirtColour;
dst->trousers_colour = src->TrousersColour;

View File

@ -1478,7 +1478,6 @@ public:
dst->State = static_cast<PeepState>(src->state);
dst->SubState = src->sub_state;
dst->SpriteType = static_cast<PeepSpriteType>(src->sprite_type);
dst->AssignedPeepType = static_cast<PeepType>(src->peep_type);
dst->GuestNumRides = src->no_of_rides;
dst->TshirtColour = src->tshirt_colour;
dst->TrousersColour = src->trousers_colour;
@ -1689,7 +1688,7 @@ public:
output = EntityType::Vehicle;
break;
case RCT12SpriteIdentifier::Peep:
if (PeepType(static_cast<const RCT2SpritePeep*>(src)->peep_type) == PeepType::Guest)
if (RCT12PeepType(static_cast<const RCT2SpritePeep*>(src)->peep_type) == RCT12PeepType::Guest)
{
output = EntityType::Guest;
}

View File

@ -703,7 +703,7 @@ namespace OpenRCT2::Scripting
auto peep = GetPeep();
if (peep != nullptr)
{
return peep->AssignedPeepType == PeepType::Staff ? "staff" : "guest";
return peep->Is<Staff>() ? "staff" : "guest";
}
return "";
}

View File

@ -159,7 +159,6 @@ static void CompareSpriteDataPeep(const Peep& left, const Peep& right)
COMPARE_FIELD(State);
COMPARE_FIELD(SubState);
COMPARE_FIELD(SpriteType);
COMPARE_FIELD(AssignedPeepType);
COMPARE_FIELD(GuestNumRides);
COMPARE_FIELD(TshirtColour);
COMPARE_FIELD(TrousersColour);