diff --git a/src/openrct2/entity/Peep.cpp b/src/openrct2/entity/Peep.cpp index b4bb0cadde..2c1bae2fe0 100644 --- a/src/openrct2/entity/Peep.cpp +++ b/src/openrct2/entity/Peep.cpp @@ -360,10 +360,6 @@ PeepAnimationType Peep::GetAnimationType() */ void Peep::UpdateCurrentAnimationType() { - if (EnumValue(AnimationGroup) >= EnumValue(PeepAnimationGroup::Count)) - { - return; - } PeepAnimationType newAnimationType = GetAnimationType(); if (AnimationType == newAnimationType) { diff --git a/src/openrct2/entity/Peep.h b/src/openrct2/entity/Peep.h index bd8f92ada2..cd003bcf9b 100644 --- a/src/openrct2/entity/Peep.h +++ b/src/openrct2/entity/Peep.h @@ -234,60 +234,43 @@ enum PeepNextFlags enum class PeepAnimationGroup : uint8_t { Normal = 0, - Handyman = 0, // 1, - Mechanic = 0, // 2, - Security = 0, // 3, - SecurityAlt = 1, // 23, + // Security staff + Alternate = 1, - EntertainerPanda = 0, // 4, - EntertainerTiger = 0, // 5, - EntertainerElephant = 0, // 6, - EntertainerRoman = 0, // 7, - EntertainerGorilla = 0, // 8, - EntertainerSnowman = 0, // 9, - EntertainerKnight = 0, // 10, - EntertainerAstronaut = 0, // 11, - EntertainerBandit = 0, // 12, - EntertainerSheriff = 0, // 13, - EntertainerPirate = 0, // 14, - - // Guest variations (compensate for Staff/Entertainer slots) - IceCream = 15 - 14, - Chips = 16 - 14, - Burger = 17 - 14, - Drink = 18 - 14, - Balloon = 19 - 14, - Candyfloss = 20 - 14, - Umbrella = 21 - 14, - Pizza = 22 - 14, - - // Guest variations (compensate for SecurityAlt as well) - Popcorn = 24 - 15, - ArmsCrossed = 25 - 15, - HeadDown = 26 - 15, - Nauseous = 27 - 15, - VeryNauseous = 28 - 15, - RequireToilet = 29 - 15, - Hat = 30 - 15, - HotDog = 31 - 15, - Tentacle = 32 - 15, - ToffeeApple = 33 - 15, - Doughnut = 34 - 15, - Coffee = 35 - 15, - Chicken = 36 - 15, - Lemonade = 37 - 15, - Watching = 38 - 15, - Pretzel = 39 - 15, - Sunglasses = 40 - 15, - SuJongkwa = 41 - 15, - Juice = 42 - 15, - FunnelCake = 43 - 15, - Noodles = 44 - 15, - Sausage = 45 - 15, - Soup = 46 - 15, - Sandwich = 47 - 15, - Count = 48 - 15, + // Guest variations + IceCream = 1, + Chips = 2, + Burger = 3, + Drink = 4, + Balloon = 5, + Candyfloss = 6, + Umbrella = 7, + Pizza = 8, + Popcorn = 9, + ArmsCrossed = 10, + HeadDown = 11, + Nauseous = 12, + VeryNauseous = 13, + RequireToilet = 14, + Hat = 15, + HotDog = 16, + Tentacle = 17, + ToffeeApple = 18, + Doughnut = 19, + Coffee = 20, + Chicken = 21, + Lemonade = 22, + Watching = 23, + Pretzel = 24, + Sunglasses = 25, + SuJongkwa = 26, + Juice = 27, + FunnelCake = 28, + Noodles = 29, + Sausage = 30, + Soup = 31, + Sandwich = 32, Invalid = 255 }; diff --git a/src/openrct2/entity/Staff.cpp b/src/openrct2/entity/Staff.cpp index 260e0fd323..b370821225 100644 --- a/src/openrct2/entity/Staff.cpp +++ b/src/openrct2/entity/Staff.cpp @@ -1637,9 +1637,9 @@ void Staff::Tick128UpdateStaff() if (AssignedStaffType != StaffType::Security) return; - PeepAnimationGroup newAnimationGroup = PeepAnimationGroup::SecurityAlt; + PeepAnimationGroup newAnimationGroup = PeepAnimationGroup::Alternate; if (State != PeepState::Patrolling) - newAnimationGroup = PeepAnimationGroup::Security; + newAnimationGroup = PeepAnimationGroup::Normal; if (AnimationGroup == newAnimationGroup) return; diff --git a/src/openrct2/object/PeepAnimationsObject.cpp b/src/openrct2/object/PeepAnimationsObject.cpp index 8264b37ab6..170d80a927 100644 --- a/src/openrct2/object/PeepAnimationsObject.cpp +++ b/src/openrct2/object/PeepAnimationsObject.cpp @@ -117,9 +117,13 @@ void PeepAnimationsObject::ReadJson(IReadObjectContext* context, json_t& root) auto position = Json::GetNumber(groupJson["legacyPosition"]); if (position <= EnumValue(RCT12PeepAnimationGroup::Count)) { - group.legacyPosition = static_cast(position); + group.legacyPosition = static_cast(position); } } + else + { + group.legacyPosition = RCT12PeepAnimationGroup::Invalid; + } // Do we have a preferred way of addressing this object in scripts? if (groupJson.contains("scriptName")) @@ -166,7 +170,7 @@ size_t PeepAnimationsObject::GetNumAnimationGroups() const return _animationGroups.size(); } -PeepAnimationGroup PeepAnimationsObject::GetLegacyPosition(PeepAnimationGroup animGroup) const +RCT12PeepAnimationGroup PeepAnimationsObject::GetLegacyPosition(PeepAnimationGroup animGroup) const { return _animationGroups[EnumValue(animGroup)].legacyPosition; } diff --git a/src/openrct2/object/PeepAnimationsObject.h b/src/openrct2/object/PeepAnimationsObject.h index f653f4eb15..0f63b1ee09 100644 --- a/src/openrct2/object/PeepAnimationsObject.h +++ b/src/openrct2/object/PeepAnimationsObject.h @@ -16,6 +16,8 @@ #include #include +enum class RCT12PeepAnimationGroup : uint8_t; + class PeepAnimationsObject final : public Object { private: @@ -41,7 +43,7 @@ public: OpenRCT2::AnimationPeepType GetPeepType() const; size_t GetNumAnimationGroups() const; - PeepAnimationGroup GetLegacyPosition(PeepAnimationGroup animGroup) const; + RCT12PeepAnimationGroup GetLegacyPosition(PeepAnimationGroup animGroup) const; std::string_view GetScriptName(PeepAnimationGroup animGroup) const; bool IsSlowWalking() diff --git a/src/openrct2/park/Legacy.cpp b/src/openrct2/park/Legacy.cpp index dec5defd4c..7078809da4 100644 --- a/src/openrct2/park/Legacy.cpp +++ b/src/openrct2/park/Legacy.cpp @@ -2297,8 +2297,7 @@ const std::vector& GetLegacyPeepAnimationObjects(const ObjectL return peepAnimObjects; } -// TODO: change type to legacy PeepAnimationGroup and new PeepAnimationGroup -using AnimObjectConversionTable = std::map>; +using AnimObjectConversionTable = std::map>; static AnimObjectConversionTable BuildPeepAnimObjectConversionTable() { @@ -2313,11 +2312,12 @@ static AnimObjectConversionTable BuildPeepAnimObjectConversionTable() for (auto j = 0u; j < object->GetNumAnimationGroups(); j++) { - auto legacyPosition = object->GetLegacyPosition(PeepAnimationGroup(j)); - if (legacyPosition == PeepAnimationGroup::Invalid) + auto pag = PeepAnimationGroup(j); + auto legacyPosition = object->GetLegacyPosition(pag); + if (legacyPosition == RCT12PeepAnimationGroup::Invalid) continue; - table[legacyPosition] = { i, j }; + table[legacyPosition] = { i, pag }; } } @@ -2331,7 +2331,8 @@ static bool ConvertPeepAnimationType(TPeepType* peep, AnimObjectConversionTable& return false; // TODO: catch missings - auto conversion = table[peep->AnimationGroup]; + auto legacyPAG = RCT12PeepAnimationGroup(peep->AnimationGroup); + auto& conversion = table[legacyPAG]; peep->AnimationObjectIndex = conversion.first; peep->AnimationGroup = static_cast(conversion.second); return true; diff --git a/src/openrct2/peep/PeepAnimations.h b/src/openrct2/peep/PeepAnimations.h index 6db0209c34..e78af95f88 100644 --- a/src/openrct2/peep/PeepAnimations.h +++ b/src/openrct2/peep/PeepAnimations.h @@ -18,6 +18,7 @@ #include class PeepAnimationsObject; +enum class RCT12PeepAnimationGroup : uint8_t; namespace OpenRCT2 { @@ -50,8 +51,7 @@ namespace OpenRCT2 struct PeepAnimations { public: - // TODO: move type to RCT12? - PeepAnimationGroup legacyPosition = PeepAnimationGroup::Invalid; + RCT12PeepAnimationGroup legacyPosition; std::string scriptName{}; constexpr PeepAnimation& operator[](PeepAnimationType n) @@ -79,7 +79,7 @@ namespace OpenRCT2 { ObjectEntryIndex objectId; PeepAnimationGroup group; - PeepAnimationGroup legacyPosition; + RCT12PeepAnimationGroup legacyPosition; std::string_view scriptName; }; diff --git a/src/openrct2/scripting/bindings/entity/ScStaff.cpp b/src/openrct2/scripting/bindings/entity/ScStaff.cpp index 526f1520f3..d88c90a8f1 100644 --- a/src/openrct2/scripting/bindings/entity/ScStaff.cpp +++ b/src/openrct2/scripting/bindings/entity/ScStaff.cpp @@ -199,7 +199,7 @@ namespace OpenRCT2::Scripting else if (value.type() == DukValue::Type::NUMBER) { // Find the peep's current costume by legacy number - auto target = PeepAnimationGroup(value.as_uint() + EnumValue(PeepAnimationGroup::EntertainerPanda)); + auto target = RCT12PeepAnimationGroup(value.as_uint() + EnumValue(RCT12PeepAnimationGroup::EntertainerPanda)); costume = std::find_if( costumes.begin(), costumes.end(), [target](auto& candidate) { return candidate.legacyPosition == target; }); }