mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Move SPRITE_INDEX_NULL, MAX_SPRITES to their new homes
This commit is contained in:
@@ -286,7 +286,7 @@ static void window_editor_bottom_toolbar_mouseup([[maybe_unused]] rct_window* w,
|
||||
if (widgetIndex == WIDX_PREVIOUS_STEP_BUTTON)
|
||||
{
|
||||
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
|
||||
|| (GetNumFreeEntities() == MAX_SPRITES && !(gParkFlags & PARK_FLAGS_SPRITES_INITIALISED)))
|
||||
|| (GetNumFreeEntities() == MAX_ENTITIES && !(gParkFlags & PARK_FLAGS_SPRITES_INITIALISED)))
|
||||
{
|
||||
previous_button_mouseup_events[EnumValue(gS6Info.editor_step)]();
|
||||
}
|
||||
@@ -346,7 +346,7 @@ void window_editor_bottom_toolbar_invalidate(rct_window* w)
|
||||
}
|
||||
else if (!(gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER))
|
||||
{
|
||||
if (GetNumFreeEntities() != MAX_SPRITES || gParkFlags & PARK_FLAGS_SPRITES_INITIALISED)
|
||||
if (GetNumFreeEntities() != MAX_ENTITIES || gParkFlags & PARK_FLAGS_SPRITES_INITIALISED)
|
||||
{
|
||||
hide_previous_step_button();
|
||||
}
|
||||
@@ -371,7 +371,7 @@ void window_editor_bottom_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
{
|
||||
drawPreviousButton = true;
|
||||
}
|
||||
else if (GetNumFreeEntities() != MAX_SPRITES)
|
||||
else if (GetNumFreeEntities() != MAX_ENTITIES)
|
||||
{
|
||||
drawNextButton = true;
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ namespace Editor
|
||||
ride_init_all();
|
||||
|
||||
//
|
||||
for (int32_t i = 0; i < MAX_SPRITES; i++)
|
||||
for (int32_t i = 0; i < MAX_ENTITIES; i++)
|
||||
{
|
||||
auto peep = GetEntity<Peep>(i);
|
||||
if (peep != nullptr)
|
||||
|
||||
@@ -588,7 +588,7 @@ void game_unload_scripts()
|
||||
*/
|
||||
void reset_all_sprite_quadrant_placements()
|
||||
{
|
||||
for (size_t i = 0; i < MAX_SPRITES; i++)
|
||||
for (size_t i = 0; i < MAX_ENTITIES; i++)
|
||||
{
|
||||
auto* spr = GetEntity(i);
|
||||
if (spr != nullptr && spr->sprite_identifier != SpriteIdentifier::Null)
|
||||
|
||||
@@ -146,7 +146,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots
|
||||
virtual void Capture(GameStateSnapshot_t& snapshot) override final
|
||||
{
|
||||
snapshot.SerialiseSprites(
|
||||
[](const size_t index) { return reinterpret_cast<rct_sprite*>(GetEntity(index)); }, MAX_SPRITES, true);
|
||||
[](const size_t index) { return reinterpret_cast<rct_sprite*>(GetEntity(index)); }, MAX_ENTITIES, true);
|
||||
|
||||
// log_info("Snapshot size: %u bytes", static_cast<uint32_t>(snapshot.storedSprites.GetLength()));
|
||||
}
|
||||
@@ -172,7 +172,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots
|
||||
std::vector<rct_sprite> BuildSpriteList(GameStateSnapshot_t& snapshot) const
|
||||
{
|
||||
std::vector<rct_sprite> spriteList;
|
||||
spriteList.resize(MAX_SPRITES);
|
||||
spriteList.resize(MAX_ENTITIES);
|
||||
|
||||
for (auto& sprite : spriteList)
|
||||
{
|
||||
@@ -180,7 +180,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots
|
||||
sprite.misc.sprite_identifier = SpriteIdentifier::Null;
|
||||
}
|
||||
|
||||
snapshot.SerialiseSprites([&spriteList](const size_t index) { return &spriteList[index]; }, MAX_SPRITES, false);
|
||||
snapshot.SerialiseSprites([&spriteList](const size_t index) { return &spriteList[index]; }, MAX_ENTITIES, false);
|
||||
|
||||
return spriteList;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "../Context.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../world/Entity.h"
|
||||
|
||||
GuestSetFlagsAction::GuestSetFlagsAction(uint16_t peepId, uint32_t flags)
|
||||
: _peepId(peepId)
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../world/Sprite.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
DEFINE_GAME_ACTION(GuestSetFlagsAction, GameCommand::GuestSetFlags, GameActions::Result)
|
||||
|
||||
@@ -56,7 +56,7 @@ void GuestSetNameAction::Serialise(DataSerialiser& stream)
|
||||
|
||||
GameActions::Result::Ptr GuestSetNameAction::Query() const
|
||||
{
|
||||
if (_spriteIndex >= MAX_SPRITES)
|
||||
if (_spriteIndex >= MAX_ENTITIES)
|
||||
{
|
||||
return std::make_unique<GameActions::Result>(GameActions::Status::InvalidParameters, STR_CANT_NAME_GUEST, STR_NONE);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../world/Sprite.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
DEFINE_GAME_ACTION(GuestSetNameAction, GameCommand::SetGuestName, GameActions::Result)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "../Input.h"
|
||||
#include "../network/network.h"
|
||||
#include "../util/Util.h"
|
||||
#include "../world/Sprite.h"
|
||||
|
||||
PeepPickupAction::PeepPickupAction(PeepPickupType type, uint32_t spriteId, const CoordsXYZ& loc, NetworkPlayerId_t owner)
|
||||
: _type(type)
|
||||
@@ -35,7 +36,7 @@ void PeepPickupAction::Serialise(DataSerialiser& stream)
|
||||
|
||||
GameActions::Result::Ptr PeepPickupAction::Query() const
|
||||
{
|
||||
if (_spriteId >= MAX_SPRITES || _spriteId == SPRITE_INDEX_NULL)
|
||||
if (_spriteId >= MAX_ENTITIES || _spriteId == SPRITE_INDEX_NULL)
|
||||
{
|
||||
log_error("Failed to pick up peep for sprite %d", _spriteId);
|
||||
return MakeResult(GameActions::Status::InvalidParameters, STR_ERR_CANT_PLACE_PERSON_HERE);
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../world/Sprite.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
enum class PeepPickupType : uint8_t
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "../interface/Window.h"
|
||||
#include "../peep/Peep.h"
|
||||
#include "../world/Entity.h"
|
||||
|
||||
StaffFireAction::StaffFireAction(uint16_t spriteId)
|
||||
: _spriteId(spriteId)
|
||||
@@ -30,7 +31,7 @@ void StaffFireAction::Serialise(DataSerialiser& stream)
|
||||
|
||||
GameActions::Result::Ptr StaffFireAction::Query() const
|
||||
{
|
||||
if (_spriteId >= MAX_SPRITES)
|
||||
if (_spriteId >= MAX_ENTITIES)
|
||||
{
|
||||
log_error("Invalid spriteId. spriteId = %u", _spriteId);
|
||||
return MakeResult(GameActions::Status::InvalidParameters, STR_NONE);
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../world/Sprite.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
DEFINE_GAME_ACTION(StaffFireAction, GameCommand::FireStaffMember, GameActions::Result)
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../peep/Staff.h"
|
||||
#include "../world/Sprite.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
/* rct2: 0x009929FC */
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "../localisation/Localisation.h"
|
||||
#include "../localisation/StringIds.h"
|
||||
#include "../windows/Intent.h"
|
||||
#include "../world/Entity.h"
|
||||
|
||||
/** rct2: 0x00982134 */
|
||||
constexpr const bool peep_slow_walking_types[] = {
|
||||
@@ -55,7 +56,7 @@ void StaffSetCostumeAction::Serialise(DataSerialiser& stream)
|
||||
|
||||
GameActions::Result::Ptr StaffSetCostumeAction::Query() const
|
||||
{
|
||||
if (_spriteIndex >= MAX_SPRITES)
|
||||
if (_spriteIndex >= MAX_ENTITIES)
|
||||
{
|
||||
return std::make_unique<GameActions::Result>(GameActions::Status::InvalidParameters, STR_NONE);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../peep/Staff.h"
|
||||
#include "../world/Sprite.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
DEFINE_GAME_ACTION(StaffSetCostumeAction, GameCommand::SetStaffCostume, GameActions::Result)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "../localisation/StringIds.h"
|
||||
#include "../peep/Staff.h"
|
||||
#include "../windows/Intent.h"
|
||||
#include "../world/Entity.h"
|
||||
#include "../world/Park.h"
|
||||
|
||||
StaffSetNameAction::StaffSetNameAction(uint16_t spriteIndex, const std::string& name)
|
||||
@@ -40,7 +41,7 @@ void StaffSetNameAction::Serialise(DataSerialiser& stream)
|
||||
|
||||
GameActions::Result::Ptr StaffSetNameAction::Query() const
|
||||
{
|
||||
if (_spriteIndex >= MAX_SPRITES)
|
||||
if (_spriteIndex >= MAX_ENTITIES)
|
||||
{
|
||||
return std::make_unique<GameActions::Result>(
|
||||
GameActions::Status::InvalidParameters, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE);
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../world/Sprite.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
DEFINE_GAME_ACTION(StaffSetNameAction, GameCommand::SetStaffName, GameActions::Result)
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "../localisation/StringIds.h"
|
||||
#include "../peep/Staff.h"
|
||||
#include "../windows/Intent.h"
|
||||
#include "../world/Entity.h"
|
||||
|
||||
StaffSetOrdersAction::StaffSetOrdersAction(uint16_t spriteIndex, uint8_t ordersId)
|
||||
: _spriteIndex(spriteIndex)
|
||||
@@ -36,7 +37,7 @@ void StaffSetOrdersAction::Serialise(DataSerialiser& stream)
|
||||
|
||||
GameActions::Result::Ptr StaffSetOrdersAction::Query() const
|
||||
{
|
||||
if (_spriteIndex >= MAX_SPRITES)
|
||||
if (_spriteIndex >= MAX_ENTITIES)
|
||||
{
|
||||
return std::make_unique<GameActions::Result>(GameActions::Status::InvalidParameters, STR_NONE);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../world/Sprite.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
DEFINE_GAME_ACTION(StaffSetOrdersAction, GameCommand::SetStaffOrders, GameActions::Result)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "../interface/Window.h"
|
||||
#include "../peep/Peep.h"
|
||||
#include "../peep/Staff.h"
|
||||
#include "../world/Entity.h"
|
||||
|
||||
StaffSetPatrolAreaAction::StaffSetPatrolAreaAction(uint16_t spriteId, const CoordsXY& loc)
|
||||
: _spriteId(spriteId)
|
||||
@@ -32,7 +33,7 @@ void StaffSetPatrolAreaAction::Serialise(DataSerialiser& stream)
|
||||
|
||||
GameActions::Result::Ptr StaffSetPatrolAreaAction::Query() const
|
||||
{
|
||||
if (_spriteId >= MAX_SPRITES)
|
||||
if (_spriteId >= MAX_ENTITIES)
|
||||
{
|
||||
log_error("Invalid spriteId. spriteId = %u", _spriteId);
|
||||
return MakeResult(GameActions::Status::InvalidParameters, STR_NONE);
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../world/Sprite.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
DEFINE_GAME_ACTION(StaffSetPatrolAreaAction, GameCommand::SetStaffPatrol, GameActions::Result)
|
||||
|
||||
@@ -145,6 +145,8 @@ using money64 = fixed64_1dp;
|
||||
using EMPTY_ARGS_VOID_POINTER = void();
|
||||
using rct_string_id = uint16_t;
|
||||
|
||||
constexpr uint16_t SPRITE_INDEX_NULL = 0xFFFF;
|
||||
|
||||
#define SafeFree(x) \
|
||||
do \
|
||||
{ \
|
||||
|
||||
@@ -1266,7 +1266,7 @@ static int32_t cc_show_limits(InteractiveConsole& console, [[maybe_unused]] cons
|
||||
}
|
||||
}
|
||||
|
||||
console.WriteFormatLine("Sprites: %d/%d", spriteCount, MAX_SPRITES);
|
||||
console.WriteFormatLine("Sprites: %d/%d", spriteCount, MAX_ENTITIES);
|
||||
console.WriteFormatLine("Map Elements: %d/%d", tileElementCount, MAX_TILE_ELEMENTS);
|
||||
console.WriteFormatLine("Banners: %d/%zu", bannerCount, MAX_BANNERS);
|
||||
console.WriteFormatLine("Rides: %d/%d", rideCount, MAX_RIDES);
|
||||
@@ -1589,7 +1589,7 @@ static int32_t cc_mp_desync(InteractiveConsole& console, const arguments_t& argv
|
||||
|
||||
std::vector<Peep*> peeps;
|
||||
|
||||
for (int i = 0; i < MAX_SPRITES; i++)
|
||||
for (int i = 0; i < MAX_ENTITIES; i++)
|
||||
{
|
||||
auto* sprite = GetEntity(i);
|
||||
if (sprite == nullptr || sprite->sprite_identifier == SpriteIdentifier::Null)
|
||||
|
||||
@@ -2141,7 +2141,7 @@ void window_init_all()
|
||||
|
||||
void window_follow_sprite(rct_window* w, size_t spriteIndex)
|
||||
{
|
||||
if (spriteIndex < MAX_SPRITES || spriteIndex == SPRITE_INDEX_NULL)
|
||||
if (spriteIndex < MAX_ENTITIES || spriteIndex == SPRITE_INDEX_NULL)
|
||||
{
|
||||
w->viewport_smart_follow_sprite = static_cast<uint16_t>(spriteIndex);
|
||||
}
|
||||
|
||||
@@ -1356,7 +1356,7 @@ private:
|
||||
ImportPeep(peep, srcPeep);
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < MAX_SPRITES; i++)
|
||||
for (size_t i = 0; i < MAX_ENTITIES; i++)
|
||||
{
|
||||
auto vehicle = GetEntity<Vehicle>(i);
|
||||
if (vehicle != nullptr)
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace OpenRCT2::Scripting
|
||||
|
||||
int32_t numEntities_get() const
|
||||
{
|
||||
return MAX_SPRITES;
|
||||
return MAX_ENTITIES;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<ScRide>> rides_get() const
|
||||
@@ -84,7 +84,7 @@ namespace OpenRCT2::Scripting
|
||||
|
||||
DukValue getEntity(int32_t id) const
|
||||
{
|
||||
if (id >= 0 && id < MAX_SPRITES)
|
||||
if (id >= 0 && id < MAX_ENTITIES)
|
||||
{
|
||||
auto spriteId = static_cast<uint16_t>(id);
|
||||
auto sprite = GetEntity(spriteId);
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include "SpriteBase.h"
|
||||
|
||||
constexpr uint16_t MAX_ENTITIES = 10000;
|
||||
|
||||
SpriteBase* try_get_sprite(size_t spriteIndex);
|
||||
SpriteBase* get_sprite(size_t sprite_idx);
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
static rct_sprite _spriteList[MAX_SPRITES];
|
||||
static rct_sprite _spriteList[MAX_ENTITIES];
|
||||
static std::array<std::list<uint16_t>, EnumValue(EntityListId::Count)> gEntityLists;
|
||||
static std::vector<uint16_t> _freeIdList;
|
||||
|
||||
static bool _spriteFlashingList[MAX_SPRITES];
|
||||
static bool _spriteFlashingList[MAX_ENTITIES];
|
||||
|
||||
static std::array<std::vector<uint16_t>, SPATIAL_INDEX_SIZE> gSpriteSpatialIndex;
|
||||
|
||||
@@ -128,7 +128,7 @@ std::string rct_sprite_checksum::ToString() const
|
||||
|
||||
SpriteBase* try_get_sprite(size_t spriteIndex)
|
||||
{
|
||||
return spriteIndex >= MAX_SPRITES ? nullptr : &_spriteList[spriteIndex].misc;
|
||||
return spriteIndex >= MAX_ENTITIES ? nullptr : &_spriteList[spriteIndex].misc;
|
||||
}
|
||||
|
||||
SpriteBase* get_sprite(size_t spriteIndex)
|
||||
@@ -137,7 +137,7 @@ SpriteBase* get_sprite(size_t spriteIndex)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
openrct2_assert(spriteIndex < MAX_SPRITES, "Tried getting sprite %u", spriteIndex);
|
||||
openrct2_assert(spriteIndex < MAX_ENTITIES, "Tried getting sprite %u", spriteIndex);
|
||||
return try_get_sprite(spriteIndex);
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ void reset_sprite_list()
|
||||
{
|
||||
gSavedAge = 0;
|
||||
std::memset(static_cast<void*>(_spriteList), 0, sizeof(_spriteList));
|
||||
for (int32_t i = 0; i < MAX_SPRITES; ++i)
|
||||
for (int32_t i = 0; i < MAX_ENTITIES; ++i)
|
||||
{
|
||||
auto* spr = GetEntity(i);
|
||||
if (spr == nullptr)
|
||||
@@ -290,7 +290,7 @@ void reset_sprite_spatial_index()
|
||||
{
|
||||
vec.clear();
|
||||
}
|
||||
for (size_t i = 0; i < MAX_SPRITES; i++)
|
||||
for (size_t i = 0; i < MAX_ENTITIES; i++)
|
||||
{
|
||||
auto* spr = GetEntity(i);
|
||||
if (spr != nullptr && spr->sprite_identifier != SpriteIdentifier::Null)
|
||||
@@ -320,7 +320,7 @@ rct_sprite_checksum sprite_checksum()
|
||||
}
|
||||
|
||||
_spriteHashAlg->Clear();
|
||||
for (size_t i = 0; i < MAX_SPRITES; i++)
|
||||
for (size_t i = 0; i < MAX_ENTITIES; i++)
|
||||
{
|
||||
// TODO create a way to copy only the specific type
|
||||
auto sprite = GetEntity(i);
|
||||
@@ -945,12 +945,12 @@ EntityTweener& EntityTweener::Get()
|
||||
|
||||
void sprite_set_flashing(SpriteBase* sprite, bool flashing)
|
||||
{
|
||||
assert(sprite->sprite_index < MAX_SPRITES);
|
||||
assert(sprite->sprite_index < MAX_ENTITIES);
|
||||
_spriteFlashingList[sprite->sprite_index] = flashing;
|
||||
}
|
||||
|
||||
bool sprite_get_flashing(SpriteBase* sprite)
|
||||
{
|
||||
assert(sprite->sprite_index < MAX_SPRITES);
|
||||
assert(sprite->sprite_index < MAX_ENTITIES);
|
||||
return _spriteFlashingList[sprite->sprite_index];
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ template<> bool SpriteBase::Is<Vehicle>() const
|
||||
|
||||
SpriteBase* get_sprite(size_t sprite_idx)
|
||||
{
|
||||
assert(sprite_idx < MAX_SPRITES);
|
||||
assert(sprite_idx < MAX_ENTITIES);
|
||||
return reinterpret_cast<SpriteBase*>(&sprite_list[sprite_idx]);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ using namespace OpenRCT2;
|
||||
|
||||
struct GameState_t
|
||||
{
|
||||
rct_sprite sprites[MAX_SPRITES];
|
||||
rct_sprite sprites[MAX_ENTITIES];
|
||||
};
|
||||
|
||||
static bool LoadFileToBuffer(MemoryStream& stream, const std::string& filePath)
|
||||
@@ -106,7 +106,7 @@ static bool ExportSave(MemoryStream& stream, std::unique_ptr<IContext>& context)
|
||||
static std::unique_ptr<GameState_t> GetGameState(std::unique_ptr<IContext>& context)
|
||||
{
|
||||
std::unique_ptr<GameState_t> res = std::make_unique<GameState_t>();
|
||||
for (size_t spriteIdx = 0; spriteIdx < MAX_SPRITES; spriteIdx++)
|
||||
for (size_t spriteIdx = 0; spriteIdx < MAX_ENTITIES; spriteIdx++)
|
||||
{
|
||||
rct_sprite* sprite = reinterpret_cast<rct_sprite*>(GetEntity(spriteIdx));
|
||||
if (sprite == nullptr)
|
||||
@@ -461,7 +461,7 @@ static void CompareStates(
|
||||
static_cast<unsigned long long>(exportBuffer.GetLength()));
|
||||
}
|
||||
|
||||
for (size_t spriteIdx = 0; spriteIdx < MAX_SPRITES; ++spriteIdx)
|
||||
for (size_t spriteIdx = 0; spriteIdx < MAX_ENTITIES; ++spriteIdx)
|
||||
{
|
||||
if (importedState->sprites[spriteIdx].misc.sprite_identifier == SpriteIdentifier::Null
|
||||
&& exportedState->sprites[spriteIdx].misc.sprite_identifier == SpriteIdentifier::Null)
|
||||
|
||||
Reference in New Issue
Block a user