diff --git a/src/openrct2-ui/windows/EditorBottomToolbar.cpp b/src/openrct2-ui/windows/EditorBottomToolbar.cpp index ec10436aaa..ea2934e76b 100644 --- a/src/openrct2-ui/windows/EditorBottomToolbar.cpp +++ b/src/openrct2-ui/windows/EditorBottomToolbar.cpp @@ -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; } diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index 9ac7f82c55..5e61d3fbf2 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 54d1ca3fc9..53448356c9 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -52,7 +52,9 @@ #include #include #include +#include #include +#include #include using namespace OpenRCT2; diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index f5de96e323..540ebebcbb 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index 3f1f685e76..130fc95eb9 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -64,6 +64,7 @@ #include "ui/WindowManager.h" #include "util/Util.h" #include "world/Park.h" +#include "world/Sprite.h" #include #include diff --git a/src/openrct2/Editor.cpp b/src/openrct2/Editor.cpp index 0ef3d751de..5976d7e031 100644 --- a/src/openrct2/Editor.cpp +++ b/src/openrct2/Editor.cpp @@ -38,6 +38,7 @@ #include "world/Footpath.h" #include "world/Park.h" #include "world/Scenery.h" +#include "world/Sprite.h" #include #include @@ -309,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(i); if (peep != nullptr) diff --git a/src/openrct2/EditorObjectSelectionSession.cpp b/src/openrct2/EditorObjectSelectionSession.cpp index 9e2c146dc5..ab99d9304c 100644 --- a/src/openrct2/EditorObjectSelectionSession.cpp +++ b/src/openrct2/EditorObjectSelectionSession.cpp @@ -21,6 +21,7 @@ #include "object/ObjectManager.h" #include "object/ObjectRepository.h" #include "ride/RideData.h" +#include "ride/Vehicle.h" #include "scenario/Scenario.h" #include "windows/Intent.h" #include "world/Footpath.h" diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 5b01c2f887..0301b2f91a 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -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) diff --git a/src/openrct2/GameState.cpp b/src/openrct2/GameState.cpp index 26f981b620..5d891f9e86 100644 --- a/src/openrct2/GameState.cpp +++ b/src/openrct2/GameState.cpp @@ -36,6 +36,7 @@ #include "world/MapAnimation.h" #include "world/Park.h" #include "world/Scenery.h" +#include "world/Sprite.h" #include #include diff --git a/src/openrct2/GameStateSnapshots.cpp b/src/openrct2/GameStateSnapshots.cpp index 9f5262d132..e1e9c3875c 100644 --- a/src/openrct2/GameStateSnapshots.cpp +++ b/src/openrct2/GameStateSnapshots.cpp @@ -11,6 +11,7 @@ #include "core/CircularBuffer.h" #include "peep/Peep.h" +#include "world/EntityList.h" #include "world/Sprite.h" static constexpr size_t MaximumGameStateSnapshots = 32; @@ -145,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(GetEntity(index)); }, MAX_SPRITES, true); + [](const size_t index) { return reinterpret_cast(GetEntity(index)); }, MAX_ENTITIES, true); // log_info("Snapshot size: %u bytes", static_cast(snapshot.storedSprites.GetLength())); } @@ -171,7 +172,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots std::vector BuildSpriteList(GameStateSnapshot_t& snapshot) const { std::vector spriteList; - spriteList.resize(MAX_SPRITES); + spriteList.resize(MAX_ENTITIES); for (auto& sprite : spriteList) { @@ -179,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; } diff --git a/src/openrct2/ReplayManager.cpp b/src/openrct2/ReplayManager.cpp index a45efa8a14..81c6746bd8 100644 --- a/src/openrct2/ReplayManager.cpp +++ b/src/openrct2/ReplayManager.cpp @@ -30,6 +30,7 @@ #include "object/ObjectRepository.h" #include "rct2/S6Exporter.h" #include "world/Park.h" +#include "world/Sprite.h" #include "zlib.h" #include diff --git a/src/openrct2/actions/BalloonPressAction.cpp b/src/openrct2/actions/BalloonPressAction.cpp index 053073965d..474722db35 100644 --- a/src/openrct2/actions/BalloonPressAction.cpp +++ b/src/openrct2/actions/BalloonPressAction.cpp @@ -9,6 +9,7 @@ #include "BalloonPressAction.h" +#include "../world/Sprite.h" #include "GameAction.h" BalloonPressAction::BalloonPressAction(uint16_t spriteIndex) diff --git a/src/openrct2/actions/BalloonPressAction.h b/src/openrct2/actions/BalloonPressAction.h index 88ce856389..0bf2ece5f9 100644 --- a/src/openrct2/actions/BalloonPressAction.h +++ b/src/openrct2/actions/BalloonPressAction.h @@ -9,7 +9,6 @@ #pragma once -#include "../world/Sprite.h" #include "GameAction.h" DEFINE_GAME_ACTION(BalloonPressAction, GameCommand::BalloonPress, GameActions::Result) diff --git a/src/openrct2/actions/GameAction.cpp b/src/openrct2/actions/GameAction.cpp index de3a3869cf..ccad0e2543 100644 --- a/src/openrct2/actions/GameAction.cpp +++ b/src/openrct2/actions/GameAction.cpp @@ -25,6 +25,7 @@ #include "../ui/WindowManager.h" #include "../world/Park.h" #include "../world/Scenery.h" +#include "../world/Sprite.h" #include #include diff --git a/src/openrct2/actions/GuestSetFlagsAction.cpp b/src/openrct2/actions/GuestSetFlagsAction.cpp index 82795c8f4f..9ecd1919eb 100644 --- a/src/openrct2/actions/GuestSetFlagsAction.cpp +++ b/src/openrct2/actions/GuestSetFlagsAction.cpp @@ -11,6 +11,7 @@ #include "../Context.h" #include "../OpenRCT2.h" +#include "../world/Entity.h" GuestSetFlagsAction::GuestSetFlagsAction(uint16_t peepId, uint32_t flags) : _peepId(peepId) diff --git a/src/openrct2/actions/GuestSetFlagsAction.h b/src/openrct2/actions/GuestSetFlagsAction.h index 2cf45ffa7c..f162e1216a 100644 --- a/src/openrct2/actions/GuestSetFlagsAction.h +++ b/src/openrct2/actions/GuestSetFlagsAction.h @@ -9,7 +9,6 @@ #pragma once -#include "../world/Sprite.h" #include "GameAction.h" DEFINE_GAME_ACTION(GuestSetFlagsAction, GameCommand::GuestSetFlags, GameActions::Result) diff --git a/src/openrct2/actions/GuestSetNameAction.cpp b/src/openrct2/actions/GuestSetNameAction.cpp index 82fa3d9b2c..5c504ebbbe 100644 --- a/src/openrct2/actions/GuestSetNameAction.cpp +++ b/src/openrct2/actions/GuestSetNameAction.cpp @@ -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::Status::InvalidParameters, STR_CANT_NAME_GUEST, STR_NONE); } diff --git a/src/openrct2/actions/GuestSetNameAction.h b/src/openrct2/actions/GuestSetNameAction.h index 5f2a9b025d..6611f075e2 100644 --- a/src/openrct2/actions/GuestSetNameAction.h +++ b/src/openrct2/actions/GuestSetNameAction.h @@ -9,7 +9,6 @@ #pragma once -#include "../world/Sprite.h" #include "GameAction.h" DEFINE_GAME_ACTION(GuestSetNameAction, GameCommand::SetGuestName, GameActions::Result) diff --git a/src/openrct2/actions/PeepPickupAction.cpp b/src/openrct2/actions/PeepPickupAction.cpp index 8cd6dee6a7..49b422cdcf 100644 --- a/src/openrct2/actions/PeepPickupAction.cpp +++ b/src/openrct2/actions/PeepPickupAction.cpp @@ -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); diff --git a/src/openrct2/actions/PeepPickupAction.h b/src/openrct2/actions/PeepPickupAction.h index 7aab1b2d65..5ff32e8d59 100644 --- a/src/openrct2/actions/PeepPickupAction.h +++ b/src/openrct2/actions/PeepPickupAction.h @@ -9,7 +9,6 @@ #pragma once -#include "../world/Sprite.h" #include "GameAction.h" enum class PeepPickupType : uint8_t diff --git a/src/openrct2/actions/RideDemolishAction.cpp b/src/openrct2/actions/RideDemolishAction.cpp index 6ad78b6611..d3c9074a8d 100644 --- a/src/openrct2/actions/RideDemolishAction.cpp +++ b/src/openrct2/actions/RideDemolishAction.cpp @@ -22,6 +22,7 @@ #include "../ui/UiContext.h" #include "../ui/WindowManager.h" #include "../world/Banner.h" +#include "../world/EntityList.h" #include "../world/Park.h" #include "../world/Sprite.h" #include "MazeSetTrackAction.h" diff --git a/src/openrct2/actions/StaffFireAction.cpp b/src/openrct2/actions/StaffFireAction.cpp index 620fbeadc9..f8138d93a8 100644 --- a/src/openrct2/actions/StaffFireAction.cpp +++ b/src/openrct2/actions/StaffFireAction.cpp @@ -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); diff --git a/src/openrct2/actions/StaffFireAction.h b/src/openrct2/actions/StaffFireAction.h index 1f19e8343c..2b74d256b6 100644 --- a/src/openrct2/actions/StaffFireAction.h +++ b/src/openrct2/actions/StaffFireAction.h @@ -9,7 +9,6 @@ #pragma once -#include "../world/Sprite.h" #include "GameAction.h" DEFINE_GAME_ACTION(StaffFireAction, GameCommand::FireStaffMember, GameActions::Result) diff --git a/src/openrct2/actions/StaffHireNewAction.h b/src/openrct2/actions/StaffHireNewAction.h index 56c18f3118..47c9d6bb4c 100644 --- a/src/openrct2/actions/StaffHireNewAction.h +++ b/src/openrct2/actions/StaffHireNewAction.h @@ -10,7 +10,6 @@ #pragma once #include "../peep/Staff.h" -#include "../world/Sprite.h" #include "GameAction.h" /* rct2: 0x009929FC */ diff --git a/src/openrct2/actions/StaffSetColourAction.cpp b/src/openrct2/actions/StaffSetColourAction.cpp index 4767da64d1..f41462a167 100644 --- a/src/openrct2/actions/StaffSetColourAction.cpp +++ b/src/openrct2/actions/StaffSetColourAction.cpp @@ -17,6 +17,7 @@ #include "../ui/UiContext.h" #include "../ui/WindowManager.h" #include "../windows/Intent.h" +#include "../world/EntityList.h" #include "../world/Sprite.h" StaffSetColourAction::StaffSetColourAction(StaffType staffType, uint8_t colour) diff --git a/src/openrct2/actions/StaffSetCostumeAction.cpp b/src/openrct2/actions/StaffSetCostumeAction.cpp index 641f927ddb..6f475563b5 100644 --- a/src/openrct2/actions/StaffSetCostumeAction.cpp +++ b/src/openrct2/actions/StaffSetCostumeAction.cpp @@ -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::Status::InvalidParameters, STR_NONE); } diff --git a/src/openrct2/actions/StaffSetCostumeAction.h b/src/openrct2/actions/StaffSetCostumeAction.h index 34b868f9aa..617f859140 100644 --- a/src/openrct2/actions/StaffSetCostumeAction.h +++ b/src/openrct2/actions/StaffSetCostumeAction.h @@ -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) diff --git a/src/openrct2/actions/StaffSetNameAction.cpp b/src/openrct2/actions/StaffSetNameAction.cpp index 4784b6e606..aa1b2feb92 100644 --- a/src/openrct2/actions/StaffSetNameAction.cpp +++ b/src/openrct2/actions/StaffSetNameAction.cpp @@ -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::Status::InvalidParameters, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE); diff --git a/src/openrct2/actions/StaffSetNameAction.h b/src/openrct2/actions/StaffSetNameAction.h index aa40e84ad1..7864677be7 100644 --- a/src/openrct2/actions/StaffSetNameAction.h +++ b/src/openrct2/actions/StaffSetNameAction.h @@ -9,7 +9,6 @@ #pragma once -#include "../world/Sprite.h" #include "GameAction.h" DEFINE_GAME_ACTION(StaffSetNameAction, GameCommand::SetStaffName, GameActions::Result) diff --git a/src/openrct2/actions/StaffSetOrdersAction.cpp b/src/openrct2/actions/StaffSetOrdersAction.cpp index 8492622beb..8ab821aa96 100644 --- a/src/openrct2/actions/StaffSetOrdersAction.cpp +++ b/src/openrct2/actions/StaffSetOrdersAction.cpp @@ -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::Status::InvalidParameters, STR_NONE); } diff --git a/src/openrct2/actions/StaffSetOrdersAction.h b/src/openrct2/actions/StaffSetOrdersAction.h index 63e325405e..b0a1f41cdb 100644 --- a/src/openrct2/actions/StaffSetOrdersAction.h +++ b/src/openrct2/actions/StaffSetOrdersAction.h @@ -9,7 +9,6 @@ #pragma once -#include "../world/Sprite.h" #include "GameAction.h" DEFINE_GAME_ACTION(StaffSetOrdersAction, GameCommand::SetStaffOrders, GameActions::Result) diff --git a/src/openrct2/actions/StaffSetPatrolAreaAction.cpp b/src/openrct2/actions/StaffSetPatrolAreaAction.cpp index cc035b029d..8f981a9468 100644 --- a/src/openrct2/actions/StaffSetPatrolAreaAction.cpp +++ b/src/openrct2/actions/StaffSetPatrolAreaAction.cpp @@ -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); diff --git a/src/openrct2/actions/StaffSetPatrolAreaAction.h b/src/openrct2/actions/StaffSetPatrolAreaAction.h index 36add3adb7..7d43239aa7 100644 --- a/src/openrct2/actions/StaffSetPatrolAreaAction.h +++ b/src/openrct2/actions/StaffSetPatrolAreaAction.h @@ -9,7 +9,6 @@ #pragma once -#include "../world/Sprite.h" #include "GameAction.h" DEFINE_GAME_ACTION(StaffSetPatrolAreaAction, GameCommand::SetStaffPatrol, GameActions::Result) diff --git a/src/openrct2/common.h b/src/openrct2/common.h index 21d4dacbc4..7b81c78ae6 100644 --- a/src/openrct2/common.h +++ b/src/openrct2/common.h @@ -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 \ { \ diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index d54f5406c1..6330c29197 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -46,6 +46,7 @@ #include "../util/Util.h" #include "../windows/Intent.h" #include "../world/Climate.h" +#include "../world/EntityList.h" #include "../world/Park.h" #include "../world/Scenery.h" #include "../world/Sprite.h" @@ -1265,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); @@ -1588,7 +1589,7 @@ static int32_t cc_mp_desync(InteractiveConsole& console, const arguments_t& argv std::vector 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) diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index f2e2106706..42bee34297 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -25,6 +25,7 @@ #include "../ui/UiContext.h" #include "../ui/WindowManager.h" #include "../world/Climate.h" +#include "../world/EntityList.h" #include "../world/Map.h" #include "../world/Sprite.h" #include "Colour.h" diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index dc44f90544..dd9a29a1b0 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -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(spriteIndex); } diff --git a/src/openrct2/interface/Window_internal.cpp b/src/openrct2/interface/Window_internal.cpp index a8518bdcaf..9b3140dee4 100644 --- a/src/openrct2/interface/Window_internal.cpp +++ b/src/openrct2/interface/Window_internal.cpp @@ -1,5 +1,6 @@ #include "Window_internal.h" +#include "../world/EntityList.h" #include "../world/Sprite.h" void rct_window::SetLocation(const CoordsXYZ& coords) diff --git a/src/openrct2/interface/Window_internal.h b/src/openrct2/interface/Window_internal.h index ab577334d0..60a4a01ffe 100644 --- a/src/openrct2/interface/Window_internal.h +++ b/src/openrct2/interface/Window_internal.h @@ -9,7 +9,6 @@ #pragma once -#include "../world/Sprite.h" #include "Window.h" #include diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index b2dc9918af..c0e0779121 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -24,7 +24,9 @@ #include "../ui/UiContext.h" #include "../ui/WindowManager.h" #include "../util/SawyerCoding.h" +#include "../world/EntityList.h" #include "../world/Location.hpp" +#include "../world/Sprite.h" #include "network.h" #include diff --git a/src/openrct2/network/NetworkPlayer.h b/src/openrct2/network/NetworkPlayer.h index 422fb5b1fd..c589900b56 100644 --- a/src/openrct2/network/NetworkPlayer.h +++ b/src/openrct2/network/NetworkPlayer.h @@ -13,7 +13,6 @@ #include "../common.h" #include "../peep/Peep.h" #include "../world/Map.h" -#include "../world/Sprite.h" #include #include diff --git a/src/openrct2/object/RideObject.cpp b/src/openrct2/object/RideObject.cpp index a49efe3c60..97127a2d32 100644 --- a/src/openrct2/object/RideObject.cpp +++ b/src/openrct2/object/RideObject.cpp @@ -24,6 +24,7 @@ #include "../ride/RideData.h" #include "../ride/ShopItem.h" #include "../ride/Track.h" +#include "../ride/Vehicle.h" #include "ObjectRepository.h" #include diff --git a/src/openrct2/paint/sprite/Paint.Sprite.cpp b/src/openrct2/paint/sprite/Paint.Sprite.cpp index be08dac38d..c27bb3c055 100644 --- a/src/openrct2/paint/sprite/Paint.Sprite.cpp +++ b/src/openrct2/paint/sprite/Paint.Sprite.cpp @@ -16,6 +16,7 @@ #include "../../ride/RideData.h" #include "../../ride/TrackDesign.h" #include "../../ride/VehiclePaint.h" +#include "../../world/EntityList.h" #include "../../world/Sprite.h" #include "../Paint.h" diff --git a/src/openrct2/paint/sprite/Paint.Sprite.h b/src/openrct2/paint/sprite/Paint.Sprite.h index 9638184780..c69b31b8ef 100644 --- a/src/openrct2/paint/sprite/Paint.Sprite.h +++ b/src/openrct2/paint/sprite/Paint.Sprite.h @@ -11,9 +11,11 @@ #define _PAINT_SPRITE_H #include "../../common.h" -#include "../../world/Sprite.h" struct paint_session; +struct Litter; +struct MiscEntity; +struct Peep; void sprite_paint_setup(paint_session* session, const uint16_t x, const uint16_t y); diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index 230ff10318..0feb0e1250 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -593,7 +593,7 @@ struct Peep : SpriteBase uint8_t Toilet; uint8_t Mass; uint8_t TimeToConsume; - IntensityRange Intensity; + IntensityRange Intensity{ 0 }; PeepNauseaTolerance NauseaTolerance; uint8_t WindowInvalidateFlags; money16 PaidOnDrink; diff --git a/src/openrct2/platform/Windows.cpp b/src/openrct2/platform/Windows.cpp index f4e33433a8..580662bb31 100644 --- a/src/openrct2/platform/Windows.cpp +++ b/src/openrct2/platform/Windows.cpp @@ -34,6 +34,7 @@ # include "platform.h" # include +# include # include # include # include diff --git a/src/openrct2/rct1/RCT1.h b/src/openrct2/rct1/RCT1.h index 4ccb9d2272..3f3c951144 100644 --- a/src/openrct2/rct1/RCT1.h +++ b/src/openrct2/rct1/RCT1.h @@ -18,7 +18,6 @@ #include "../world/Banner.h" #include "../world/Climate.h" #include "../world/MapAnimation.h" -#include "../world/Sprite.h" constexpr const uint16_t RCT1_MAX_TILE_ELEMENTS = 0xC000; constexpr const uint16_t RCT1_MAX_SPRITES = 5000; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 095a573882..f3c456a73e 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -50,6 +50,7 @@ #include "../world/Park.h" #include "../world/Scenery.h" #include "../world/SmallScenery.h" +#include "../world/Sprite.h" #include "../world/Surface.h" #include "../world/Wall.h" #include "RCT1.h" @@ -1355,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(i); if (vehicle != nullptr) diff --git a/src/openrct2/rct2/RCT2.h b/src/openrct2/rct2/RCT2.h index c8786193c9..17edab1aac 100644 --- a/src/openrct2/rct2/RCT2.h +++ b/src/openrct2/rct2/RCT2.h @@ -14,7 +14,7 @@ #include "../object/Object.h" #include "../rct12/RCT12.h" #include "../ride/RideRatings.h" -#include "../ride/Vehicle.h" +#include "../ride/VehicleColour.h" #include @@ -90,6 +90,8 @@ constexpr const int32_t rct2_object_entry_group_counts[] = { #pragma pack(push, 1) +struct rct_ride_entry; + /** * Ride structure. * size: 0x0260 diff --git a/src/openrct2/rct2/S6Exporter.h b/src/openrct2/rct2/S6Exporter.h index fc1d2e0155..59ae39c231 100644 --- a/src/openrct2/rct2/S6Exporter.h +++ b/src/openrct2/rct2/S6Exporter.h @@ -23,8 +23,10 @@ namespace OpenRCT2 struct IStream; } +struct Litter; struct ObjectRepositoryItem; struct RCT12SpriteBase; +union rct_sprite; struct SpriteBase; /** diff --git a/src/openrct2/ride/CableLift.cpp b/src/openrct2/ride/CableLift.cpp index 118b3c96e0..fa1d5c6b7f 100644 --- a/src/openrct2/ride/CableLift.cpp +++ b/src/openrct2/ride/CableLift.cpp @@ -12,6 +12,7 @@ #include "../audio/audio.h" #include "../rct12/RCT12.h" #include "../util/Util.h" +#include "../world/EntityList.h" #include "../world/Sprite.h" #include "Ride.h" #include "RideData.h" diff --git a/src/openrct2/ride/CableLift.h b/src/openrct2/ride/CableLift.h index 6d773d0d9e..2c1ec083bd 100644 --- a/src/openrct2/ride/CableLift.h +++ b/src/openrct2/ride/CableLift.h @@ -11,7 +11,9 @@ #define _CABLE_LIFT_H_ #include "../common.h" -#include "Vehicle.h" +#include "Ride.h" + +struct Vehicle; Vehicle* cable_lift_segment_create( Ride& ride, int32_t x, int32_t y, int32_t z, int32_t direction, uint16_t var_44, int32_t remaining_distance, bool head); diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 7268a2267a..239b4e1700 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -63,6 +63,7 @@ #include "Track.h" #include "TrackData.h" #include "TrackDesign.h" +#include "Vehicle.h" #include #include diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index a2894272c5..3b7a2640de 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -18,7 +18,7 @@ #include "RideRatings.h" #include "RideTypes.h" #include "ShopItem.h" -#include "Vehicle.h" +#include "VehicleEntry.h" #include #include @@ -30,6 +30,7 @@ struct Peep; struct Ride; struct RideTypeDescriptor; struct Staff; +struct Vehicle; #define MAX_RIDE_TYPES_PER_RIDE_ENTRY 3 // The max number of different types of vehicle. diff --git a/src/openrct2/ride/RideData.cpp b/src/openrct2/ride/RideData.cpp index a0851f3133..4c592c26b1 100644 --- a/src/openrct2/ride/RideData.cpp +++ b/src/openrct2/ride/RideData.cpp @@ -28,6 +28,7 @@ #include "Ride.h" #include "ShopItem.h" #include "Track.h" +#include "Vehicle.h" #include "coaster/meta/AirPoweredVerticalCoaster.h" #include "coaster/meta/BobsleighCoaster.h" #include "coaster/meta/ClassicMiniRollerCoaster.h" diff --git a/src/openrct2/ride/RideData.h b/src/openrct2/ride/RideData.h index bc855ccd36..1a28f8d4e0 100644 --- a/src/openrct2/ride/RideData.h +++ b/src/openrct2/ride/RideData.h @@ -20,6 +20,7 @@ #define DEFAULT_FLAT_RIDE_COLOUR_PRESET TRACK_COLOUR_PRESETS({ COLOUR_BRIGHT_RED, COLOUR_LIGHT_BLUE, COLOUR_YELLOW }) #define DEFAULT_STALL_COLOUR_PRESET TRACK_COLOUR_PRESETS({ COLOUR_BRIGHT_RED, COLOUR_BRIGHT_RED, COLOUR_BRIGHT_RED }) +#include "../audio/audio.h" #include "../common.h" #include "../localisation/StringIds.h" #include "../sprites.h" diff --git a/src/openrct2/ride/ShopItem.cpp b/src/openrct2/ride/ShopItem.cpp index 4f9ccf55d0..8b1192592d 100644 --- a/src/openrct2/ride/ShopItem.cpp +++ b/src/openrct2/ride/ShopItem.cpp @@ -12,6 +12,7 @@ #include "../common.h" #include "../localisation/StringIds.h" #include "../sprites.h" +#include "../world/Sprite.h" ShopItem& operator++(ShopItem& d, int) { diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index b8d652b98f..c956d1025e 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -57,6 +57,7 @@ #include "Track.h" #include "TrackData.h" #include "TrackDesignRepository.h" +#include "Vehicle.h" #include #include diff --git a/src/openrct2/ride/TrackDesign.h b/src/openrct2/ride/TrackDesign.h index 6c1d08be29..a1161469c0 100644 --- a/src/openrct2/ride/TrackDesign.h +++ b/src/openrct2/ride/TrackDesign.h @@ -15,7 +15,6 @@ #include "../rct12/RCT12.h" #include "../rct2/RCT2.h" #include "../world/Map.h" -#include "Vehicle.h" struct Ride; diff --git a/src/openrct2/ride/Vehicle.h b/src/openrct2/ride/Vehicle.h index db97d5c6ef..25eb39bd3c 100644 --- a/src/openrct2/ride/Vehicle.h +++ b/src/openrct2/ride/Vehicle.h @@ -16,6 +16,9 @@ #include "../world/Location.hpp" #include "../world/SpriteBase.h" #include "Station.h" +#include "VehicleColour.h" +#include "VehicleEntry.h" +#include "VehicleSubpositionData.h" #include #include @@ -23,118 +26,6 @@ using track_type_t = uint16_t; -struct rct_vehicle_colour -{ - uint8_t body_colour; - uint8_t trim_colour; -}; - -struct VehicleColour -{ - uint8_t Body; - uint8_t Trim; - uint8_t Ternary; -}; - -#ifdef __TESTPAINT__ -# pragma pack(push, 1) -#endif // __TESTPAINT__ -/** - * Ride type vehicle structure. - * size: 0x65 - */ -struct rct_ride_entry_vehicle -{ - uint16_t rotation_frame_mask; // 0x00 , 0x1A - uint8_t num_vertical_frames; // 0x02 , 0x1C, Appears to be unused, except as a temporary variable in RCT2 (not needed for - // OpenRCT2) - uint8_t num_horizontal_frames; // 0x03 , 0x1D, Appears to be unused, except as a temporary variable in RCT2 (not needed for - // OpenRCT2) - uint32_t spacing; // 0x04 , 0x1E - uint16_t car_mass; // 0x08 , 0x22 - int8_t tab_height; // 0x0A , 0x24 - uint8_t num_seats; // 0x0B , 0x25 - uint16_t sprite_flags; // 0x0C , 0x26 - uint8_t sprite_width; // 0x0E , 0x28 - uint8_t sprite_height_negative; // 0x0F , 0x29 - uint8_t sprite_height_positive; // 0x10 , 0x2A - uint8_t animation; // 0x11 , 0x2B - uint32_t flags; // 0x12 , 0x2C - uint16_t base_num_frames; // 0x16 , 0x30, The number of sprites for a flat non-banked track piece. - uint32_t base_image_id; // 0x18 , 0x32, Following image_id's populated during loading - uint32_t restraint_image_id; // 0x1C , 0x36 - uint32_t gentle_slope_image_id; // 0x20 , 0x3A - uint32_t steep_slope_image_id; // 0x24 , 0x3E - uint32_t vertical_slope_image_id; // 0x28 , 0x42 - uint32_t diagonal_slope_image_id; // 0x2C , 0x46 - uint32_t banked_image_id; // 0x30 , 0x4A - uint32_t inline_twist_image_id; // 0x34 , 0x4E - uint32_t flat_to_gentle_bank_image_id; // 0x38 , 0x52 - uint32_t diagonal_to_gentle_slope_bank_image_id; // 0x3C , 0x56 - uint32_t gentle_slope_to_bank_image_id; // 0x40 , 0x5A - uint32_t gentle_slope_bank_turn_image_id; // 0x44 , 0x5E - uint32_t flat_bank_to_gentle_slope_image_id; // 0x48 , 0x62 - union - { - uint32_t curved_lift_hill_image_id; // 0x4C , 0x66 - uint32_t corkscrew_image_id; // 0x4C , 0x66 - }; - uint32_t no_vehicle_images; // 0x50 , 0x6A - uint8_t no_seating_rows; // 0x54 , 0x6E - uint8_t spinning_inertia; // 0x55 , 0x6F - uint8_t spinning_friction; // 0x56 , 0x70 - OpenRCT2::Audio::SoundId friction_sound_id; // 0x57 , 0x71 - uint8_t log_flume_reverser_vehicle_type; // 0x58 , 0x72 - uint8_t sound_range; // 0x59 , 0x73 - uint8_t - double_sound_frequency; // 0x5A , 0x74 (Doubles the velocity when working out the sound frequency {used on go karts}) - uint8_t powered_acceleration; // 0x5B , 0x75 - uint8_t powered_max_speed; // 0x5C , 0x76 - uint8_t car_visual; // 0x5D , 0x77 - uint8_t effect_visual; - uint8_t draw_order; - uint8_t num_vertical_frames_override; // 0x60 , 0x7A, A custom number that can be used rather than letting RCT2 determine - // it. Needs the VEHICLE_ENTRY_FLAG_OVERRIDE_NUM_VERTICAL_FRAMES flag to be set. - uint8_t peep_loading_waypoint_segments; // 0x61 new - uint8_t pad_62[6] = {}; // 0x62 , 0x7B - std::vector> peep_loading_waypoints = {}; - std::vector peep_loading_positions = {}; // previously 0x61 , 0x7B -}; -#ifdef __TESTPAINT__ -# pragma pack(pop) -#endif // __TESTPAINT__ -#ifdef PLATFORM_32BIT -static_assert(sizeof(rct_ride_entry_vehicle) % 4 == 0, "Invalid struct size"); -#else -static_assert(sizeof(rct_ride_entry_vehicle) % 8 == 0, "Invalid struct size"); -#endif - -enum class VehicleTrackSubposition : uint8_t -{ - Default, - // Going out means "moving away from the start". Viewed from Station 1, this is the left hand side of the track. - ChairliftGoingOut, - ChairliftGoingBack, - // End and start bullwheel as viewed from Station 1. - ChairliftEndBullwheel, - ChairliftStartBullwheel, - GoKartsLeftLane, - GoKartsRightLane, - GoKartsMovingToRightLane, - GoKartsMovingToLeftLane, - MiniGolfStart9 = 9, - MiniGolfPathA9 = 9, - MiniGolfBallPathA10, - MiniGolfPathB11, - MiniGolfBallPathB12, - MiniGolfPathC13, - MiniGolfBallPathC14, - ReverserRCFrontBogie, - ReverserRCRearBogie, - - Count, -}; - struct Ride; struct rct_ride_entry; diff --git a/src/openrct2/ride/VehicleColour.h b/src/openrct2/ride/VehicleColour.h new file mode 100644 index 0000000000..c1fdc67df5 --- /dev/null +++ b/src/openrct2/ride/VehicleColour.h @@ -0,0 +1,25 @@ +/***************************************************************************** + * Copyright (c) 2014-2021 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../common.h" + +struct rct_vehicle_colour +{ + uint8_t body_colour; + uint8_t trim_colour; +}; + +struct VehicleColour +{ + uint8_t Body; + uint8_t Trim; + uint8_t Ternary; +}; diff --git a/src/openrct2/ride/VehicleEntry.h b/src/openrct2/ride/VehicleEntry.h new file mode 100644 index 0000000000..d354729f5f --- /dev/null +++ b/src/openrct2/ride/VehicleEntry.h @@ -0,0 +1,89 @@ +/***************************************************************************** + * Copyright (c) 2014-2021 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../audio/AudioMixer.h" +#include "../common.h" + +#include +#include + +#ifdef __TESTPAINT__ +# pragma pack(push, 1) +#endif // __TESTPAINT__ +/** + * Ride type vehicle structure. + * size: 0x65 + */ +struct rct_ride_entry_vehicle +{ + uint16_t rotation_frame_mask; // 0x00 , 0x1A + uint8_t num_vertical_frames; // 0x02 , 0x1C, Appears to be unused, except as a temporary variable in RCT2 (not needed for + // OpenRCT2) + uint8_t num_horizontal_frames; // 0x03 , 0x1D, Appears to be unused, except as a temporary variable in RCT2 (not needed for + // OpenRCT2) + uint32_t spacing; // 0x04 , 0x1E + uint16_t car_mass; // 0x08 , 0x22 + int8_t tab_height; // 0x0A , 0x24 + uint8_t num_seats; // 0x0B , 0x25 + uint16_t sprite_flags; // 0x0C , 0x26 + uint8_t sprite_width; // 0x0E , 0x28 + uint8_t sprite_height_negative; // 0x0F , 0x29 + uint8_t sprite_height_positive; // 0x10 , 0x2A + uint8_t animation; // 0x11 , 0x2B + uint32_t flags; // 0x12 , 0x2C + uint16_t base_num_frames; // 0x16 , 0x30, The number of sprites for a flat non-banked track piece. + uint32_t base_image_id; // 0x18 , 0x32, Following image_id's populated during loading + uint32_t restraint_image_id; // 0x1C , 0x36 + uint32_t gentle_slope_image_id; // 0x20 , 0x3A + uint32_t steep_slope_image_id; // 0x24 , 0x3E + uint32_t vertical_slope_image_id; // 0x28 , 0x42 + uint32_t diagonal_slope_image_id; // 0x2C , 0x46 + uint32_t banked_image_id; // 0x30 , 0x4A + uint32_t inline_twist_image_id; // 0x34 , 0x4E + uint32_t flat_to_gentle_bank_image_id; // 0x38 , 0x52 + uint32_t diagonal_to_gentle_slope_bank_image_id; // 0x3C , 0x56 + uint32_t gentle_slope_to_bank_image_id; // 0x40 , 0x5A + uint32_t gentle_slope_bank_turn_image_id; // 0x44 , 0x5E + uint32_t flat_bank_to_gentle_slope_image_id; // 0x48 , 0x62 + union + { + uint32_t curved_lift_hill_image_id; // 0x4C , 0x66 + uint32_t corkscrew_image_id; // 0x4C , 0x66 + }; + uint32_t no_vehicle_images; // 0x50 , 0x6A + uint8_t no_seating_rows; // 0x54 , 0x6E + uint8_t spinning_inertia; // 0x55 , 0x6F + uint8_t spinning_friction; // 0x56 , 0x70 + OpenRCT2::Audio::SoundId friction_sound_id; // 0x57 , 0x71 + uint8_t log_flume_reverser_vehicle_type; // 0x58 , 0x72 + uint8_t sound_range; // 0x59 , 0x73 + uint8_t + double_sound_frequency; // 0x5A , 0x74 (Doubles the velocity when working out the sound frequency {used on go karts}) + uint8_t powered_acceleration; // 0x5B , 0x75 + uint8_t powered_max_speed; // 0x5C , 0x76 + uint8_t car_visual; // 0x5D , 0x77 + uint8_t effect_visual; + uint8_t draw_order; + uint8_t num_vertical_frames_override; // 0x60 , 0x7A, A custom number that can be used rather than letting RCT2 determine + // it. Needs the VEHICLE_ENTRY_FLAG_OVERRIDE_NUM_VERTICAL_FRAMES flag to be set. + uint8_t peep_loading_waypoint_segments; // 0x61 new + uint8_t pad_62[6] = {}; // 0x62 , 0x7B + std::vector> peep_loading_waypoints = {}; + std::vector peep_loading_positions = {}; // previously 0x61 , 0x7B +}; +#ifdef __TESTPAINT__ +# pragma pack(pop) +#endif // __TESTPAINT__ +#ifdef PLATFORM_32BIT +static_assert(sizeof(rct_ride_entry_vehicle) % 4 == 0, "Invalid struct size"); +#else +static_assert(sizeof(rct_ride_entry_vehicle) % 8 == 0, "Invalid struct size"); +#endif diff --git a/src/openrct2/ride/VehicleSubpositionData.cpp b/src/openrct2/ride/VehicleSubpositionData.cpp index 8e93e109d8..66d99434e9 100644 --- a/src/openrct2/ride/VehicleSubpositionData.cpp +++ b/src/openrct2/ride/VehicleSubpositionData.cpp @@ -9,6 +9,8 @@ #include "VehicleSubpositionData.h" +#include "Vehicle.h" + #define CREATE_VEHICLE_INFO(VAR, ...) \ static constexpr const rct_vehicle_info VAR##_data[] = __VA_ARGS__; \ static constexpr const rct_vehicle_info_list VAR = { static_cast(std::size(VAR##_data)), VAR##_data }; diff --git a/src/openrct2/ride/VehicleSubpositionData.h b/src/openrct2/ride/VehicleSubpositionData.h index f32488a0a2..6c647086e7 100644 --- a/src/openrct2/ride/VehicleSubpositionData.h +++ b/src/openrct2/ride/VehicleSubpositionData.h @@ -9,14 +9,40 @@ #pragma once -#include "../world/Location.hpp" #include "Track.h" -#include "Vehicle.h" #include constexpr const size_t VehicleTrackSubpositionSizeDefault = TrackElemType::Count * NumOrthogonalDirections; +struct rct_vehicle_info; + +enum class VehicleTrackSubposition : uint8_t +{ + Default, + // Going out means "moving away from the start". Viewed from Station 1, this is the left hand side of the track. + ChairliftGoingOut, + ChairliftGoingBack, + // End and start bullwheel as viewed from Station 1. + ChairliftEndBullwheel, + ChairliftStartBullwheel, + GoKartsLeftLane, + GoKartsRightLane, + GoKartsMovingToRightLane, + GoKartsMovingToLeftLane, + MiniGolfStart9 = 9, + MiniGolfPathA9 = 9, + MiniGolfBallPathA10, + MiniGolfPathB11, + MiniGolfBallPathB12, + MiniGolfPathC13, + MiniGolfBallPathC14, + ReverserRCFrontBogie, + ReverserRCRearBogie, + + Count, +}; + struct rct_vehicle_info_list { uint16_t size; diff --git a/src/openrct2/ride/coaster/VirginiaReel.cpp b/src/openrct2/ride/coaster/VirginiaReel.cpp index 231c43fa16..e559de03b5 100644 --- a/src/openrct2/ride/coaster/VirginiaReel.cpp +++ b/src/openrct2/ride/coaster/VirginiaReel.cpp @@ -13,6 +13,7 @@ #include "../../paint/Supports.h" #include "../Track.h" #include "../TrackPaint.h" +#include "../Vehicle.h" #include "../VehiclePaint.h" // 0x009927E6: diff --git a/src/openrct2/ride/gentle/ObservationTower.cpp b/src/openrct2/ride/gentle/ObservationTower.cpp index 121916215e..e04c4fc1f7 100644 --- a/src/openrct2/ride/gentle/ObservationTower.cpp +++ b/src/openrct2/ride/gentle/ObservationTower.cpp @@ -14,6 +14,7 @@ #include "../../world/Map.h" #include "../Track.h" #include "../TrackPaint.h" +#include "../Vehicle.h" #include "../VehiclePaint.h" enum diff --git a/src/openrct2/ride/thrill/RotoDrop.cpp b/src/openrct2/ride/thrill/RotoDrop.cpp index de6adf00e5..e2fc9ada3e 100644 --- a/src/openrct2/ride/thrill/RotoDrop.cpp +++ b/src/openrct2/ride/thrill/RotoDrop.cpp @@ -13,6 +13,7 @@ #include "../../paint/Supports.h" #include "../Track.h" #include "../TrackPaint.h" +#include "../Vehicle.h" #include "../VehiclePaint.h" #include diff --git a/src/openrct2/ride/water/SubmarineRide.cpp b/src/openrct2/ride/water/SubmarineRide.cpp index 666ae317e6..a8a2174d63 100644 --- a/src/openrct2/ride/water/SubmarineRide.cpp +++ b/src/openrct2/ride/water/SubmarineRide.cpp @@ -13,6 +13,7 @@ #include "../RideData.h" #include "../Track.h" #include "../TrackPaint.h" +#include "../Vehicle.h" #include "../VehiclePaint.h" #ifndef NO_VEHICLES diff --git a/src/openrct2/scenario/Scenario.h b/src/openrct2/scenario/Scenario.h index be881c5a52..5174ab3518 100644 --- a/src/openrct2/scenario/Scenario.h +++ b/src/openrct2/scenario/Scenario.h @@ -21,9 +21,9 @@ #include "../ride/RideRatings.h" #include "../world/Banner.h" #include "../world/Climate.h" +#include "../world/EntityList.h" #include "../world/Map.h" #include "../world/MapAnimation.h" -#include "../world/Sprite.h" using random_engine_t = Random::Rct2::Engine; diff --git a/src/openrct2/scripting/ScEntity.hpp b/src/openrct2/scripting/ScEntity.hpp index f4effa176a..c9aded3b04 100644 --- a/src/openrct2/scripting/ScEntity.hpp +++ b/src/openrct2/scripting/ScEntity.hpp @@ -16,6 +16,7 @@ # include "../peep/Peep.h" # include "../peep/Staff.h" # include "../util/Util.h" +# include "../world/EntityList.h" # include "../world/Sprite.h" # include "Duktape.hpp" # include "ScRide.hpp" diff --git a/src/openrct2/scripting/ScMap.hpp b/src/openrct2/scripting/ScMap.hpp index 3d7ac0de6f..870c266dd4 100644 --- a/src/openrct2/scripting/ScMap.hpp +++ b/src/openrct2/scripting/ScMap.hpp @@ -13,6 +13,7 @@ # include "../common.h" # include "../ride/Ride.h" +# include "../world/EntityList.h" # include "../world/Map.h" # include "Duktape.hpp" # include "ScEntity.hpp" @@ -50,7 +51,7 @@ namespace OpenRCT2::Scripting int32_t numEntities_get() const { - return MAX_SPRITES; + return MAX_ENTITIES; } std::vector> rides_get() const @@ -83,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(id); auto sprite = GetEntity(spriteId); diff --git a/src/openrct2/world/Entity.h b/src/openrct2/world/Entity.h new file mode 100644 index 0000000000..2259d47bcd --- /dev/null +++ b/src/openrct2/world/Entity.h @@ -0,0 +1,29 @@ +/***************************************************************************** + * Copyright (c) 2014-2021 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "SpriteBase.h" + +constexpr uint16_t MAX_ENTITIES = 10000; + +SpriteBase* try_get_sprite(size_t spriteIndex); +SpriteBase* get_sprite(size_t sprite_idx); + +template T* GetEntity(size_t sprite_idx) +{ + auto spr = get_sprite(sprite_idx); + return spr != nullptr ? spr->As() : nullptr; +} + +template T* TryGetEntity(size_t sprite_idx) +{ + auto spr = try_get_sprite(sprite_idx); + return spr != nullptr ? spr->As() : nullptr; +} diff --git a/src/openrct2/world/EntityList.h b/src/openrct2/world/EntityList.h new file mode 100644 index 0000000000..6f2d61ea7c --- /dev/null +++ b/src/openrct2/world/EntityList.h @@ -0,0 +1,238 @@ +/***************************************************************************** + * Copyright (c) 2014-2021 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../common.h" +#include "../rct12/RCT12.h" +#include "Entity.h" +#include "Location.hpp" +#include "SpriteBase.h" + +#include +#include + +enum class EntityListId : uint8_t +{ + Free, + TrainHead, + Peep, + Misc, + Litter, + Vehicle, + Count, +}; + +const std::list& GetEntityList(const EntityListId id); + +uint16_t GetEntityListCount(EntityListId list); +uint16_t GetNumFreeEntities(); +void RebuildEntityLists(); +const std::vector& GetEntityTileList(const CoordsXY& spritePos); + +template class EntityIterator +{ +private: + T* Entity = nullptr; + uint16_t NextEntityId = SPRITE_INDEX_NULL; + +public: + EntityIterator(const uint16_t _EntityId) + : NextEntityId(_EntityId) + { + ++(*this); + } + EntityIterator& operator++() + { + Entity = nullptr; + + while (NextEntityId != SPRITE_INDEX_NULL && Entity == nullptr) + { + auto baseEntity = GetEntity(NextEntityId); + if (!baseEntity) + { + NextEntityId = SPRITE_INDEX_NULL; + continue; + } + NextEntityId = baseEntity->*NextList; + Entity = baseEntity->template As(); + } + return *this; + } + + EntityIterator operator++(int) + { + EntityIterator retval = *this; + ++(*this); + return retval; + } + bool operator==(EntityIterator other) const + { + return Entity == other.Entity; + } + bool operator!=(EntityIterator other) const + { + return !(*this == other); + } + T* operator*() + { + return Entity; + } + // iterator traits + using difference_type = std::ptrdiff_t; + using value_type = T; + using pointer = const T*; + using reference = const T&; + using iterator_category = std::forward_iterator_tag; +}; + +template class EntityTileIterator +{ +private: + std::vector::const_iterator iter; + std::vector::const_iterator end; + T* Entity = nullptr; + +public: + EntityTileIterator(std::vector::const_iterator _iter, std::vector::const_iterator _end) + : iter(_iter) + , end(_end) + { + ++(*this); + } + EntityTileIterator& operator++() + { + Entity = nullptr; + + while (iter != end && Entity == nullptr) + { + Entity = GetEntity(*iter++); + } + return *this; + } + + EntityTileIterator operator++(int) + { + EntityTileIterator retval = *this; + ++(*this); + return *iter; + } + bool operator==(EntityTileIterator other) const + { + return Entity == other.Entity; + } + bool operator!=(EntityTileIterator other) const + { + return !(*this == other); + } + T* operator*() + { + return Entity; + } + // iterator traits + using difference_type = std::ptrdiff_t; + using value_type = T; + using pointer = const T*; + using reference = const T&; + using iterator_category = std::forward_iterator_tag; +}; + +template class EntityTileList +{ +private: + const std::vector& vec; + +public: + EntityTileList(const CoordsXY& loc) + : vec(GetEntityTileList(loc)) + { + } + + EntityTileIterator begin() + { + return EntityTileIterator(std::begin(vec), std::end(vec)); + } + EntityTileIterator end() + { + return EntityTileIterator(std::end(vec), std::end(vec)); + } +}; + +template class EntityListIterator +{ +private: + std::list::const_iterator iter; + std::list::const_iterator end; + T* Entity = nullptr; + +public: + EntityListIterator(std::list::const_iterator _iter, std::list::const_iterator _end) + : iter(_iter) + , end(_end) + { + ++(*this); + } + EntityListIterator& operator++() + { + Entity = nullptr; + + while (iter != end && Entity == nullptr) + { + Entity = GetEntity(*iter++); + } + return *this; + } + + EntityListIterator operator++(int) + { + EntityListIterator retval = *this; + ++(*this); + return *iter; + } + bool operator==(EntityListIterator other) const + { + return Entity == other.Entity; + } + bool operator!=(EntityListIterator other) const + { + return !(*this == other); + } + T* operator*() + { + return Entity; + } + // iterator traits + using difference_type = std::ptrdiff_t; + using value_type = T; + using pointer = const T*; + using reference = const T&; + using iterator_category = std::forward_iterator_tag; +}; + +template class EntityList +{ +private: + using EntityListIterator_t = EntityListIterator; + const std::list& vec; + +public: + EntityList(EntityListId type) + : vec(GetEntityList(type)) + { + } + + EntityListIterator_t begin() + { + return EntityListIterator_t(std::cbegin(vec), std::cend(vec)); + } + EntityListIterator_t end() + { + return EntityListIterator_t(std::cend(vec), std::cend(vec)); + } +}; diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 2fe6083bba..9c420a0c66 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -28,6 +28,7 @@ #include "../ride/Track.h" #include "../ride/TrackData.h" #include "../util/Util.h" +#include "EntityList.h" #include "Map.h" #include "MapAnimation.h" #include "Park.h" diff --git a/src/openrct2/world/MapAnimation.cpp b/src/openrct2/world/MapAnimation.cpp index d6c901cda4..cc86e52e00 100644 --- a/src/openrct2/world/MapAnimation.cpp +++ b/src/openrct2/world/MapAnimation.cpp @@ -18,6 +18,7 @@ #include "../ride/Track.h" #include "../world/Wall.h" #include "Banner.h" +#include "EntityList.h" #include "Footpath.h" #include "LargeScenery.h" #include "Map.h" diff --git a/src/openrct2/world/Sprite.cpp b/src/openrct2/world/Sprite.cpp index add25cadfa..2bba77688d 100644 --- a/src/openrct2/world/Sprite.cpp +++ b/src/openrct2/world/Sprite.cpp @@ -26,11 +26,11 @@ #include #include -static rct_sprite _spriteList[MAX_SPRITES]; +static rct_sprite _spriteList[MAX_ENTITIES]; static std::array, EnumValue(EntityListId::Count)> gEntityLists; static std::vector _freeIdList; -static bool _spriteFlashingList[MAX_SPRITES]; +static bool _spriteFlashingList[MAX_ENTITIES]; static std::array, 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(_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]; } diff --git a/src/openrct2/world/Sprite.h b/src/openrct2/world/Sprite.h index 2e872f6cbc..0058633787 100644 --- a/src/openrct2/world/Sprite.h +++ b/src/openrct2/world/Sprite.h @@ -13,14 +13,10 @@ #include "../common.h" #include "../peep/Peep.h" #include "../ride/Vehicle.h" +#include "Entity.h" #include "Fountain.h" #include "SpriteBase.h" -#include - -#define SPRITE_INDEX_NULL 0xFFFF -#define MAX_SPRITES 10000 - enum class SpriteIdentifier : uint8_t { Vehicle = 0, @@ -30,17 +26,6 @@ enum class SpriteIdentifier : uint8_t Null = 255 }; -enum class EntityListId : uint8_t -{ - Free, - TrainHead, - Peep, - Misc, - Litter, - Vehicle, - Count, -}; - enum LitterType : uint8_t; struct Litter : SpriteBase @@ -213,23 +198,6 @@ enum LitterType : uint8_t LITTER_TYPE_EMPTY_BOWL_BLUE, }; -SpriteBase* try_get_sprite(size_t spriteIndex); -SpriteBase* get_sprite(size_t sprite_idx); -template T* GetEntity(size_t sprite_idx) -{ - auto spr = get_sprite(sprite_idx); - return spr != nullptr ? spr->As() : nullptr; -} - -template T* TryGetEntity(size_t sprite_idx) -{ - auto spr = try_get_sprite(sprite_idx); - return spr != nullptr ? spr->As() : nullptr; -} - -uint16_t GetEntityListCount(EntityListId list); -uint16_t GetNumFreeEntities(); - constexpr const uint32_t SPATIAL_INDEX_SIZE = (MAXIMUM_MAP_SIZE_TECHNICAL * MAXIMUM_MAP_SIZE_TECHNICAL) + 1; constexpr const uint32_t SPATIAL_INDEX_LOCATION_NULL = SPATIAL_INDEX_SIZE - 1; @@ -237,7 +205,6 @@ extern const rct_string_id litterNames[12]; rct_sprite* create_sprite(SpriteIdentifier spriteIdentifier); rct_sprite* create_sprite(SpriteIdentifier spriteIdentifier, EntityListId linkedListIndex); -void RebuildEntityLists(); void reset_sprite_list(); void reset_sprite_spatial_index(); void sprite_clear_all_unused(); @@ -249,7 +216,6 @@ void litter_remove_at(const CoordsXYZ& litterPos); uint16_t remove_floating_sprites(); void sprite_misc_explosion_cloud_create(const CoordsXYZ& cloudPos); void sprite_misc_explosion_flare_create(const CoordsXYZ& flarePos); -const std::vector& GetEntityTileList(const CoordsXY& spritePos); /////////////////////////////////////////////////////////////// // Balloon @@ -275,209 +241,6 @@ rct_sprite_checksum sprite_checksum(); void sprite_set_flashing(SpriteBase* sprite, bool flashing); bool sprite_get_flashing(SpriteBase* sprite); -const std::list& GetEntityList(const EntityListId id); - -template class EntityIterator -{ -private: - T* Entity = nullptr; - uint16_t NextEntityId = SPRITE_INDEX_NULL; - -public: - EntityIterator(const uint16_t _EntityId) - : NextEntityId(_EntityId) - { - ++(*this); - } - EntityIterator& operator++() - { - Entity = nullptr; - - while (NextEntityId != SPRITE_INDEX_NULL && Entity == nullptr) - { - auto baseEntity = GetEntity(NextEntityId); - if (!baseEntity) - { - NextEntityId = SPRITE_INDEX_NULL; - continue; - } - NextEntityId = baseEntity->*NextList; - Entity = baseEntity->template As(); - } - return *this; - } - - EntityIterator operator++(int) - { - EntityIterator retval = *this; - ++(*this); - return retval; - } - bool operator==(EntityIterator other) const - { - return Entity == other.Entity; - } - bool operator!=(EntityIterator other) const - { - return !(*this == other); - } - T* operator*() - { - return Entity; - } - // iterator traits - using difference_type = std::ptrdiff_t; - using value_type = T; - using pointer = const T*; - using reference = const T&; - using iterator_category = std::forward_iterator_tag; -}; - -template class EntityTileIterator -{ -private: - std::vector::const_iterator iter; - std::vector::const_iterator end; - T* Entity = nullptr; - -public: - EntityTileIterator(std::vector::const_iterator _iter, std::vector::const_iterator _end) - : iter(_iter) - , end(_end) - { - ++(*this); - } - EntityTileIterator& operator++() - { - Entity = nullptr; - - while (iter != end && Entity == nullptr) - { - Entity = GetEntity(*iter++); - } - return *this; - } - - EntityTileIterator operator++(int) - { - EntityTileIterator retval = *this; - ++(*this); - return *iter; - } - bool operator==(EntityTileIterator other) const - { - return Entity == other.Entity; - } - bool operator!=(EntityTileIterator other) const - { - return !(*this == other); - } - T* operator*() - { - return Entity; - } - // iterator traits - using difference_type = std::ptrdiff_t; - using value_type = T; - using pointer = const T*; - using reference = const T&; - using iterator_category = std::forward_iterator_tag; -}; - -template class EntityTileList -{ -private: - const std::vector& vec; - -public: - EntityTileList(const CoordsXY& loc) - : vec(GetEntityTileList(loc)) - { - } - - EntityTileIterator begin() - { - return EntityTileIterator(std::begin(vec), std::end(vec)); - } - EntityTileIterator end() - { - return EntityTileIterator(std::end(vec), std::end(vec)); - } -}; - -template class EntityListIterator -{ -private: - std::list::const_iterator iter; - std::list::const_iterator end; - T* Entity = nullptr; - -public: - EntityListIterator(std::list::const_iterator _iter, std::list::const_iterator _end) - : iter(_iter) - , end(_end) - { - ++(*this); - } - EntityListIterator& operator++() - { - Entity = nullptr; - - while (iter != end && Entity == nullptr) - { - Entity = GetEntity(*iter++); - } - return *this; - } - - EntityListIterator operator++(int) - { - EntityListIterator retval = *this; - ++(*this); - return *iter; - } - bool operator==(EntityListIterator other) const - { - return Entity == other.Entity; - } - bool operator!=(EntityListIterator other) const - { - return !(*this == other); - } - T* operator*() - { - return Entity; - } - // iterator traits - using difference_type = std::ptrdiff_t; - using value_type = T; - using pointer = const T*; - using reference = const T&; - using iterator_category = std::forward_iterator_tag; -}; - -template class EntityList -{ -private: - using EntityListIterator_t = EntityListIterator; - const std::list& vec; - -public: - EntityList(EntityListId type) - : vec(GetEntityList(type)) - { - } - - EntityListIterator_t begin() - { - return EntityListIterator_t(std::cbegin(vec), std::cend(vec)); - } - EntityListIterator_t end() - { - return EntityListIterator_t(std::cend(vec), std::cend(vec)); - } -}; - class EntityTweener { std::vector Entities; diff --git a/test/testpaint/Compat.cpp b/test/testpaint/Compat.cpp index 235f64668a..1cf1895b92 100644 --- a/test/testpaint/Compat.cpp +++ b/test/testpaint/Compat.cpp @@ -170,7 +170,7 @@ template<> bool SpriteBase::Is() const SpriteBase* get_sprite(size_t sprite_idx) { - assert(sprite_idx < MAX_SPRITES); + assert(sprite_idx < MAX_ENTITIES); return reinterpret_cast(&sprite_list[sprite_idx]); } diff --git a/test/tests/S6ImportExportTests.cpp b/test/tests/S6ImportExportTests.cpp index 04bfce0bb9..3ea6af2704 100644 --- a/test/tests/S6ImportExportTests.cpp +++ b/test/tests/S6ImportExportTests.cpp @@ -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& context) static std::unique_ptr GetGameState(std::unique_ptr& context) { std::unique_ptr res = std::make_unique(); - for (size_t spriteIdx = 0; spriteIdx < MAX_SPRITES; spriteIdx++) + for (size_t spriteIdx = 0; spriteIdx < MAX_ENTITIES; spriteIdx++) { rct_sprite* sprite = reinterpret_cast(GetEntity(spriteIdx)); if (sprite == nullptr) @@ -461,7 +461,7 @@ static void CompareStates( static_cast(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)