Refactor g_peep_animation_entries into kPeepAnimationEntries

This commit is contained in:
Aaron van Geffen 2024-04-04 22:34:00 +02:00
parent b52bf40a20
commit 642162853f
15 changed files with 1038 additions and 5482 deletions

View File

@ -26,6 +26,7 @@
#include <openrct2/localisation/Localisation.h>
#include <openrct2/management/Finance.h>
#include <openrct2/management/NewsItem.h>
#include <openrct2/peep/PeepData.h>
#include <openrct2/sprites.h>
#include <openrct2/world/Park.h>

View File

@ -27,6 +27,7 @@
#include <openrct2/localisation/Localisation.h>
#include <openrct2/management/Marketing.h>
#include <openrct2/network/network.h>
#include <openrct2/peep/PeepData.h>
#include <openrct2/ride/RideData.h>
#include <openrct2/ride/ShopItem.h>
#include <openrct2/scenario/Scenario.h>

View File

@ -21,6 +21,7 @@
#include <openrct2/localisation/Formatter.h>
#include <openrct2/localisation/Formatting.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/peep/PeepData.h>
#include <openrct2/ride/RideData.h>
#include <openrct2/scenario/Scenario.h>
#include <openrct2/sprites.h>

View File

@ -20,6 +20,7 @@
#include <openrct2/localisation/Formatter.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/management/NewsItem.h>
#include <openrct2/peep/PeepData.h>
#include <openrct2/sprites.h>
namespace OpenRCT2::Ui::Windows

View File

@ -30,6 +30,7 @@
#include <openrct2/localisation/Formatter.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/management/Award.h>
#include <openrct2/peep/PeepData.h>
#include <openrct2/ride/RideData.h>
#include <openrct2/scenario/Scenario.h>
#include <openrct2/util/Util.h>

View File

@ -48,6 +48,7 @@
#include <openrct2/object/ObjectManager.h>
#include <openrct2/object/ObjectRepository.h>
#include <openrct2/object/StationObject.h>
#include <openrct2/peep/PeepData.h>
#include <openrct2/rct1/RCT1.h>
#include <openrct2/rct2/T6Exporter.h>
#include <openrct2/ride/RideConstruction.h>

View File

@ -30,6 +30,7 @@
#include <openrct2/localisation/Localisation.h>
#include <openrct2/management/Finance.h>
#include <openrct2/network/network.h>
#include <openrct2/peep/PeepData.h>
#include <openrct2/sprites.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/world/Footpath.h>

View File

@ -29,6 +29,7 @@
#include <openrct2/localisation/Formatter.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/management/Finance.h>
#include <openrct2/peep/PeepData.h>
#include <openrct2/sprites.h>
#include <openrct2/util/Util.h>
#include <openrct2/windows/Intent.h>

View File

@ -20,6 +20,7 @@
#include "../localisation/Localisation.h"
#include "../localisation/StringIds.h"
#include "../management/Finance.h"
#include "../peep/PeepData.h"
#include "../ride/Ride.h"
#include "../scenario/Scenario.h"
#include "../ui/UiContext.h"

View File

@ -36,6 +36,7 @@
#include "../object/PathAdditionEntry.h"
#include "../object/WallSceneryEntry.h"
#include "../peep/GuestPathfinding.h"
#include "../peep/PeepData.h"
#include "../peep/RideUseSystem.h"
#include "../rct2/RCT2.h"
#include "../ride/Ride.h"

View File

@ -35,6 +35,7 @@
#include "../network/network.h"
#include "../paint/Paint.h"
#include "../peep/GuestPathfinding.h"
#include "../peep/PeepData.h"
#include "../profiling/Profiling.h"
#include "../ride/Ride.h"
#include "../ride/RideData.h"
@ -333,7 +334,7 @@ PeepActionSpriteType Peep::GetActionSpriteType()
*/
void Peep::UpdateCurrentActionSpriteType()
{
if (EnumValue(SpriteType) >= std::size(g_peep_animation_entries))
if (EnumValue(SpriteType) >= EnumValue(PeepSpriteType::Count))
{
return;
}
@ -438,32 +439,34 @@ std::optional<CoordsXY> Peep::UpdateAction(int16_t& xy_distance)
nextDirection = 0;
}
}
Orientation = nextDirection;
CoordsXY loc = { x, y };
loc += word_981D7C[nextDirection / 8];
WalkingFrameNum++;
const PeepAnimation* peepAnimation = &GetPeepAnimation(SpriteType);
const uint8_t* imageOffset = peepAnimation[EnumValue(ActionSpriteType)].frame_offsets;
if (WalkingFrameNum >= peepAnimation[EnumValue(ActionSpriteType)].num_frames)
const PeepAnimation& peepAnimation = GetPeepAnimation(SpriteType, ActionSpriteType);
if (WalkingFrameNum >= peepAnimation.frame_offsets.size())
{
WalkingFrameNum = 0;
}
ActionSpriteImageOffset = imageOffset[WalkingFrameNum];
ActionSpriteImageOffset = peepAnimation.frame_offsets[WalkingFrameNum];
return loc;
}
const PeepAnimation* peepAnimation = &GetPeepAnimation(SpriteType);
const PeepAnimation& peepAnimation = GetPeepAnimation(SpriteType, ActionSpriteType);
ActionFrame++;
// If last frame of action
if (ActionFrame >= peepAnimation[EnumValue(ActionSpriteType)].num_frames)
if (ActionFrame >= peepAnimation.frame_offsets.size())
{
ActionSpriteImageOffset = 0;
Action = PeepActionType::Walking;
UpdateCurrentActionSpriteType();
return { { x, y } };
}
ActionSpriteImageOffset = peepAnimation[EnumValue(ActionSpriteType)].frame_offsets[ActionFrame];
ActionSpriteImageOffset = peepAnimation.frame_offsets[ActionFrame];
auto* guest = As<Guest>();
// If not throwing up and not at the frame where sick appears.

View File

@ -427,26 +427,6 @@ private:
void UpdatePicked();
};
struct SpriteBounds
{
uint8_t sprite_width; // 0x00
uint8_t sprite_height_negative; // 0x01
uint8_t sprite_height_positive; // 0x02
};
struct PeepAnimation
{
uint32_t base_image; // 0x00
size_t num_frames;
const uint8_t* frame_offsets;
};
struct PeepAnimationEntry
{
const PeepAnimation* sprite_animation; // 0x00
const SpriteBounds* sprite_bounds; // 0x04
};
enum
{
PATHING_DESTINATION_REACHED = 1 << 0,
@ -455,8 +435,6 @@ enum
PATHING_RIDE_ENTRANCE = 1 << 3,
};
// rct2: 0x00982708
extern const PeepAnimationEntry g_peep_animation_entries[EnumValue(PeepSpriteType::Count)];
extern const bool gSpriteTypeToSlowWalkMap[48];
int32_t PeepGetStaffCount();
@ -479,15 +457,3 @@ int32_t PeepCompare(const EntityId sprite_index_a, const EntityId sprite_index_b
void PeepUpdateNames(bool realNames);
StringId GetRealNameStringIDFromPeepID(uint32_t id);
inline const PeepAnimation& GetPeepAnimation(
PeepSpriteType spriteType, PeepActionSpriteType actionSpriteType = PeepActionSpriteType::None)
{
return g_peep_animation_entries[EnumValue(spriteType)].sprite_animation[EnumValue(actionSpriteType)];
};
inline const SpriteBounds& GetSpriteBounds(
PeepSpriteType spriteType, PeepActionSpriteType actionSpriteType = PeepActionSpriteType::None)
{
return g_peep_animation_entries[EnumValue(spriteType)].sprite_bounds[EnumValue(actionSpriteType)];
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,43 @@
#pragma once
#include "../entity/Peep.h"
#include <span>
namespace OpenRCT2
{
struct SpriteBounds
{
uint8_t sprite_width; // 0x00
uint8_t sprite_height_negative; // 0x01
uint8_t sprite_height_positive; // 0x02
};
struct PeepAnimation
{
uint32_t base_image;
SpriteBounds bounds;
std::span<const uint8_t> frame_offsets;
};
struct PeepAnimationGroup
{
public:
constexpr PeepAnimation& operator[](PeepActionSpriteType n)
{
return animations[EnumValue(n)];
}
constexpr const PeepAnimation& operator[](PeepActionSpriteType n) const
{
return animations[EnumValue(n)];
}
private:
PeepAnimation animations[37]{};
};
const PeepAnimation& GetPeepAnimation(
PeepSpriteType spriteType, PeepActionSpriteType actionSpriteType = PeepActionSpriteType::None);
const SpriteBounds& GetSpriteBounds(
PeepSpriteType spriteType, PeepActionSpriteType actionSpriteType = PeepActionSpriteType::None);
} // namespace OpenRCT2

View File

@ -46,6 +46,7 @@
#include "../object/ObjectList.h"
#include "../object/ObjectManager.h"
#include "../object/ObjectRepository.h"
#include "../peep/PeepData.h"
#include "../peep/RideUseSystem.h"
#include "../rct12/EntryList.h"
#include "../ride/RideData.h"