1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Part of #21193: move entities to GameState_t

This commit is contained in:
Michael Steenbeek
2024-03-15 00:22:18 +01:00
committed by GitHub
parent 0f927d720b
commit 2181f1b09e
3 changed files with 22 additions and 14 deletions

View File

@@ -95,6 +95,7 @@ namespace OpenRCT2
std::string ScenarioCompletedBy;
std::vector<Banner> Banners;
Entity_t Entities[MAX_ENTITIES]{};
// Ride storage for all the rides in the park, rides with RideId::Null are considered free.
std::array<Ride, OpenRCT2::Limits::MaxRidesInPark> Rides{};
::RideRatingUpdateStates RideRatingUpdateStates;

View File

@@ -10,6 +10,7 @@
#include "EntityRegistry.h"
#include "../Game.h"
#include "../GameState.h"
#include "../core/Algorithm.hpp"
#include "../core/ChecksumStream.h"
#include "../core/Crypt.h"
@@ -36,17 +37,8 @@
#include <numeric>
#include <vector>
union Entity
{
uint8_t Pad00[0x200];
EntityBase base;
Entity()
: Pad00()
{
}
};
using namespace OpenRCT2;
static Entity _entities[MAX_ENTITIES]{};
static std::array<std::list<EntityId>, EnumValue(EntityType::Count)> gEntityLists;
static std::vector<EntityId> _freeIdList;
@@ -120,8 +112,9 @@ std::string EntitiesChecksum::ToString() const
EntityBase* TryGetEntity(EntityId entityIndex)
{
auto& gameState = GetGameState();
const auto idx = entityIndex.ToUnderlying();
return idx >= MAX_ENTITIES ? nullptr : &_entities[idx].base;
return idx >= MAX_ENTITIES ? nullptr : &gameState.Entities[idx].base;
}
EntityBase* GetEntity(EntityId entityIndex)
@@ -182,7 +175,8 @@ void ResetAllEntities()
FreeEntity(*spr);
}
std::fill(std::begin(_entities), std::end(_entities), Entity());
auto& gameState = GetGameState();
std::fill(std::begin(gameState.Entities), std::end(gameState.Entities), Entity_t());
OpenRCT2::RideUse::GetHistory().Clear();
OpenRCT2::RideUse::GetTypeHistory().Clear();
for (int32_t i = 0; i < MAX_ENTITIES; ++i)
@@ -266,8 +260,8 @@ static void EntityReset(EntityBase* entity)
auto entityIndex = entity->Id;
_entityFlashingList[entityIndex.ToUnderlying()] = false;
Entity* spr = reinterpret_cast<Entity*>(entity);
*spr = Entity();
Entity_t* tempEntity = reinterpret_cast<Entity_t*>(entity);
*tempEntity = Entity_t();
entity->Id = entityIndex;
entity->Type = EntityType::Null;

View File

@@ -14,6 +14,19 @@
#include <array>
namespace OpenRCT2
{
union Entity_t
{
uint8_t Pad00[0x200];
EntityBase base;
Entity_t()
: Pad00()
{
}
};
} // namespace OpenRCT2
constexpr uint16_t MAX_ENTITIES = 65535;
EntityBase* GetEntity(EntityId sprite_idx);