diff --git a/src/openrct2-ui/title/TitleSequencePlayer.cpp b/src/openrct2-ui/title/TitleSequencePlayer.cpp index e9271b8212..d0e954a21f 100644 --- a/src/openrct2-ui/title/TitleSequencePlayer.cpp +++ b/src/openrct2-ui/title/TitleSequencePlayer.cpp @@ -456,7 +456,7 @@ private: { auto windowManager = GetContext()->GetUiContext()->GetWindowManager(); windowManager->SetMainView(gSavedView, gSavedViewZoom, gSavedViewRotation); - reset_sprite_spatial_index(); + ResetEntitySpatialIndices(); reset_all_sprite_quadrant_placements(); auto intent = Intent(INTENT_ACTION_REFRESH_NEW_RIDES); context_broadcast_intent(&intent); diff --git a/src/openrct2-ui/windows/GuestList.cpp b/src/openrct2-ui/windows/GuestList.cpp index d26fc6ac55..6c9cf7c723 100644 --- a/src/openrct2-ui/windows/GuestList.cpp +++ b/src/openrct2-ui/windows/GuestList.cpp @@ -620,14 +620,14 @@ public: for (auto peep : EntityList()) { - sprite_set_flashing(peep, false); + EntitySetFlashing(peep, false); if (peep->OutsideOfPark) continue; if (_selectedFilter) { if (!IsPeepInFilter(*peep)) continue; - sprite_set_flashing(peep, true); + EntitySetFlashing(peep, true); } if (!GuestShouldBeVisible(*peep)) continue; diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index 530bdc8fa6..a04abb06da 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -1055,7 +1055,7 @@ static void DrawMapPeepPixel(Peep* peep, const uint8_t flashColour, rct_drawpixe auto leftTop = ScreenCoordsXY{ c.x, c.y }; auto rightBottom = leftTop; uint8_t colour = DefaultPeepMapColour; - if (sprite_get_flashing(peep)) + if (EntityGetFlashing(peep)) { colour = flashColour; // If flashing then map peep pixel size is increased (by moving left top downwards) diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index 5004cf4cac..64758ff7f1 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -191,10 +191,10 @@ public: gWindowMapFlashingFlags |= MapFlashingFlags::StaffListOpen; for (auto peep : EntityList()) { - sprite_set_flashing(peep, false); + EntitySetFlashing(peep, false); if (peep->AssignedStaffType == GetSelectedStaffType()) { - sprite_set_flashing(peep, true); + EntitySetFlashing(peep, true); } } } @@ -485,10 +485,10 @@ public: for (auto peep : EntityList()) { - sprite_set_flashing(peep, false); + EntitySetFlashing(peep, false); if (peep->AssignedStaffType == GetSelectedStaffType()) { - sprite_set_flashing(peep, true); + EntitySetFlashing(peep, true); _staffList.push_back(peep->sprite_index); } } diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 7113a7e4e7..938d384056 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -462,7 +462,7 @@ void game_fix_save_vars() if (!peepsToRemove.empty()) { // Some broken saves have broken spatial indexes - reset_sprite_spatial_index(); + ResetEntitySpatialIndices(); } for (auto ptr : peepsToRemove) @@ -543,7 +543,7 @@ void game_load_init() { GameActions::ClearQueue(); } - reset_sprite_spatial_index(); + ResetEntitySpatialIndices(); reset_all_sprite_quadrant_placements(); scenery_set_default_placement_configuration(); diff --git a/src/openrct2/GameState.cpp b/src/openrct2/GameState.cpp index 148a78fcf5..a5b540a498 100644 --- a/src/openrct2/GameState.cpp +++ b/src/openrct2/GameState.cpp @@ -326,7 +326,7 @@ void GameState::UpdateLogic(LogicTimings* timings) report_time(LogicTimePart::MapRestoreProvisionalElements); vehicle_update_all(); report_time(LogicTimePart::Vehicle); - sprite_misc_update_all(); + UpdateAllMiscEntities(); report_time(LogicTimePart::Misc); Ride::UpdateAll(); report_time(LogicTimePart::Ride); diff --git a/src/openrct2/GameStateSnapshots.cpp b/src/openrct2/GameStateSnapshots.cpp index 801b42a385..0f507702bd 100644 --- a/src/openrct2/GameStateSnapshots.cpp +++ b/src/openrct2/GameStateSnapshots.cpp @@ -56,7 +56,7 @@ struct GameStateSnapshot_t } // Must pass a function that can access the sprite. - void SerialiseSprites(std::function getEntity, const size_t numSprites, bool saving) + void SerialiseSprites(std::function getEntity, const size_t numSprites, bool saving) { const bool loading = !saving; @@ -99,7 +99,7 @@ struct GameStateSnapshot_t ds << indexTable[i]; const uint32_t spriteIdx = indexTable[i]; - rct_sprite* entity = getEntity(spriteIdx); + Entity* entity = getEntity(spriteIdx); if (entity == nullptr) { log_error("Entity index corrupted!"); @@ -171,7 +171,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_ENTITIES, true); + [](const size_t index) { return reinterpret_cast(GetEntity(index)); }, MAX_ENTITIES, true); // log_info("Snapshot size: %u bytes", static_cast(snapshot.storedSprites.GetLength())); } @@ -194,9 +194,9 @@ struct GameStateSnapshots final : public IGameStateSnapshots ds << snapshot.parkParameters; } - std::vector BuildSpriteList(GameStateSnapshot_t& snapshot) const + std::vector BuildSpriteList(GameStateSnapshot_t& snapshot) const { - std::vector spriteList; + std::vector spriteList; spriteList.resize(MAX_ENTITIES); for (auto& sprite : spriteList) @@ -536,7 +536,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots COMPARE_FIELD(ExplosionFlare, frame); } - void CompareSpriteData(const rct_sprite& spriteBase, const rct_sprite& spriteCmp, GameStateSpriteChange_t& changeData) const + void CompareSpriteData(const Entity& spriteBase, const Entity& spriteCmp, GameStateSpriteChange_t& changeData) const { CompareSpriteDataCommon(spriteBase.base, spriteCmp.base, changeData); if (spriteBase.base.Type == spriteCmp.base.Type) @@ -618,16 +618,16 @@ struct GameStateSnapshots final : public IGameStateSnapshots res.srand0Left = base.srand0; res.srand0Right = cmp.srand0; - std::vector spritesBase = BuildSpriteList(const_cast(base)); - std::vector spritesCmp = BuildSpriteList(const_cast(cmp)); + std::vector spritesBase = BuildSpriteList(const_cast(base)); + std::vector spritesCmp = BuildSpriteList(const_cast(cmp)); for (uint32_t i = 0; i < static_cast(spritesBase.size()); i++) { GameStateSpriteChange_t changeData; changeData.spriteIndex = i; - const rct_sprite& spriteBase = spritesBase[i]; - const rct_sprite& spriteCmp = spritesCmp[i]; + const Entity& spriteBase = spritesBase[i]; + const Entity& spriteCmp = spritesCmp[i]; changeData.entityType = spriteBase.base.Type; diff --git a/src/openrct2/ReplayManager.cpp b/src/openrct2/ReplayManager.cpp index 11ce4acfa5..8846137cbc 100644 --- a/src/openrct2/ReplayManager.cpp +++ b/src/openrct2/ReplayManager.cpp @@ -92,7 +92,7 @@ namespace OpenRCT2 uint32_t tickStart; // First tick of replay. uint32_t tickEnd; // Last tick of replay. std::multiset commands; - std::vector> checksums; + std::vector> checksums; uint32_t checksumIndex; OpenRCT2::MemoryStream gameStateSnapshots; }; @@ -148,7 +148,7 @@ namespace OpenRCT2 _currentRecording->commands.emplace(gCurrentTicks, std::move(ga), _commandId++); } - void AddChecksum(uint32_t tick, rct_sprite_checksum&& checksum) + void AddChecksum(uint32_t tick, EntitiesChecksum&& checksum) { _currentRecording->checksums.emplace_back(std::make_pair(tick, std::move(checksum))); } @@ -161,7 +161,7 @@ namespace OpenRCT2 if ((_mode == ReplayMode::RECORDING || _mode == ReplayMode::NORMALISATION) && gCurrentTicks == _nextChecksumTick) { - rct_sprite_checksum checksum = sprite_checksum(); + EntitiesChecksum checksum = GetAllEntitiesChecksum(); AddChecksum(gCurrentTicks, std::move(checksum)); _nextChecksumTick = gCurrentTicks + ChecksumTicksDelta(); @@ -286,7 +286,7 @@ namespace OpenRCT2 _currentRecording->tickEnd = gCurrentTicks; { - rct_sprite_checksum checksum = sprite_checksum(); + EntitiesChecksum checksum = GetAllEntitiesChecksum(); AddChecksum(gCurrentTicks, std::move(checksum)); } @@ -793,7 +793,7 @@ namespace OpenRCT2 { _currentReplay->checksumIndex++; - rct_sprite_checksum checksum = sprite_checksum(); + EntitiesChecksum checksum = GetAllEntitiesChecksum(); if (savedChecksum.second.raw != checksum.raw) { uint32_t replayTick = gCurrentTicks - _currentReplay->tickStart; diff --git a/src/openrct2/actions/SetCheatAction.cpp b/src/openrct2/actions/SetCheatAction.cpp index 6685325d60..4666db5718 100644 --- a/src/openrct2/actions/SetCheatAction.cpp +++ b/src/openrct2/actions/SetCheatAction.cpp @@ -415,7 +415,7 @@ void SetCheatAction::RemoveLitter() const { for (auto litter : EntityList()) { - sprite_remove(litter); + EntityRemove(litter); } tile_element_iterator it{}; diff --git a/src/openrct2/actions/StaffHireNewAction.cpp b/src/openrct2/actions/StaffHireNewAction.cpp index a6957bb12a..1758b70c93 100644 --- a/src/openrct2/actions/StaffHireNewAction.cpp +++ b/src/openrct2/actions/StaffHireNewAction.cpp @@ -121,7 +121,7 @@ GameActions::Result::Ptr StaffHireNewAction::QueryExecute(bool execute) const if (execute == false) { // In query we just want to see if we can obtain a sprite slot. - sprite_remove(newPeep); + EntityRemove(newPeep); res->SetData(StaffHireNewActionResult{ SPRITE_INDEX_NULL }); } diff --git a/src/openrct2/cmdline/SimulateCommands.cpp b/src/openrct2/cmdline/SimulateCommands.cpp index a060c5ac73..9709e41634 100644 --- a/src/openrct2/cmdline/SimulateCommands.cpp +++ b/src/openrct2/cmdline/SimulateCommands.cpp @@ -63,7 +63,7 @@ static exitcode_t HandleSimulate(CommandLineArgEnumerator* argEnumerator) { context->GetGameState()->UpdateLogic(); } - Console::WriteLine("Completed: %s", sprite_checksum().ToString().c_str()); + Console::WriteLine("Completed: %s", GetAllEntitiesChecksum().ToString().c_str()); } else { diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index 035fa04e07..e16124a409 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -1242,7 +1242,7 @@ static int32_t cc_remove_unused_objects(InteractiveConsole& console, [[maybe_unu static int32_t cc_remove_floating_objects(InteractiveConsole& console, const arguments_t& argv) { - uint16_t result = remove_floating_sprites(); + uint16_t result = RemoveFloatingEntities(); console.WriteFormatLine("Removed %d flying objects", result); return 0; } diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index af976afaa2..8f96dd2e95 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -753,7 +753,7 @@ bool NetworkBase::CheckSRAND(uint32_t tick, uint32_t srand0) if (!storedTick.spriteHash.empty()) { - rct_sprite_checksum checksum = sprite_checksum(); + EntitiesChecksum checksum = GetAllEntitiesChecksum(); std::string clientSpriteHash = checksum.ToString(); if (clientSpriteHash != storedTick.spriteHash) { @@ -1520,7 +1520,7 @@ void NetworkBase::Server_Send_TICK() packet << flags; if (flags & NETWORK_TICK_FLAG_CHECKSUMS) { - rct_sprite_checksum checksum = sprite_checksum(); + EntitiesChecksum checksum = GetAllEntitiesChecksum(); packet.WriteString(checksum.ToString().c_str()); } diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 4666fb0db8..3193b8d151 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -660,7 +660,7 @@ void peep_sprite_remove(Peep* peep) News::DisableNewsItems(News::ItemType::Peep, staff->sprite_index); } - sprite_remove(peep); + EntityRemove(peep); auto intent = Intent(wasGuest ? INTENT_ACTION_REFRESH_GUEST_LIST : INTENT_ACTION_REFRESH_STAFF_LIST); context_broadcast_intent(&intent); diff --git a/src/openrct2/ride/RideConstruction.cpp b/src/openrct2/ride/RideConstruction.cpp index 54fa013b39..ef3211f1f0 100644 --- a/src/openrct2/ride/RideConstruction.cpp +++ b/src/openrct2/ride/RideConstruction.cpp @@ -168,7 +168,7 @@ static void ride_remove_cable_lift(Ride* ride) } vehicle->Invalidate(); spriteIndex = vehicle->next_vehicle_on_train; - sprite_remove(vehicle); + EntityRemove(vehicle); } while (spriteIndex != SPRITE_INDEX_NULL); } } @@ -196,7 +196,7 @@ void Ride::RemoveVehicles() } vehicle->Invalidate(); spriteIndex = vehicle->next_vehicle_on_train; - sprite_remove(vehicle); + EntityRemove(vehicle); } vehicles[i] = SPRITE_INDEX_NULL; @@ -211,7 +211,7 @@ void Ride::RemoveVehicles() if (vehicle->ride == id) { vehicle->Invalidate(); - sprite_remove(vehicle); + EntityRemove(vehicle); } } } diff --git a/src/openrct2/scripting/bindings/entity/ScEntity.hpp b/src/openrct2/scripting/bindings/entity/ScEntity.hpp index 55053439bd..3877eee64f 100644 --- a/src/openrct2/scripting/bindings/entity/ScEntity.hpp +++ b/src/openrct2/scripting/bindings/entity/ScEntity.hpp @@ -178,7 +178,7 @@ namespace OpenRCT2::Scripting case EntityType::Balloon: case EntityType::Duck: case EntityType::Litter: - sprite_remove(entity); + EntityRemove(entity); break; case EntityType::Null: break; diff --git a/src/openrct2/world/Balloon.cpp b/src/openrct2/world/Balloon.cpp index 1c7f2e1541..05d41729ca 100644 --- a/src/openrct2/world/Balloon.cpp +++ b/src/openrct2/world/Balloon.cpp @@ -29,7 +29,7 @@ void Balloon::Update() frame++; if (frame >= 5) { - sprite_remove(this); + EntityRemove(this); } } else diff --git a/src/openrct2/world/Duck.cpp b/src/openrct2/world/Duck.cpp index f376846eca..440ee09412 100644 --- a/src/openrct2/world/Duck.cpp +++ b/src/openrct2/world/Duck.cpp @@ -80,7 +80,7 @@ bool Duck::IsFlying() void Duck::Remove() { Invalidate(); - sprite_remove(this); + EntityRemove(this); } void Duck::UpdateFlyToWater() diff --git a/src/openrct2/world/EntityTweener.cpp b/src/openrct2/world/EntityTweener.cpp index 63c033019e..721c2b715c 100644 --- a/src/openrct2/world/EntityTweener.cpp +++ b/src/openrct2/world/EntityTweener.cpp @@ -85,7 +85,7 @@ void EntityTweener::Tween(float alpha) if (posA == posB) continue; - sprite_set_coordinates( + EntitySetCoordinates( { static_cast(std::round(posB.x * alpha + posA.x * inv)), static_cast(std::round(posB.y * alpha + posA.y * inv)), static_cast(std::round(posB.z * alpha + posA.z * inv)) }, @@ -102,7 +102,7 @@ void EntityTweener::Restore() if (ent == nullptr) continue; - sprite_set_coordinates(PostPos[i], ent); + EntitySetCoordinates(PostPos[i], ent); ent->Invalidate(); } } diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index b514ec864d..0e048cedd6 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -413,7 +413,7 @@ void footpath_remove_litter(const CoordsXYZ& footpathPos) for (auto* litter : removals) { litter->Invalidate(); - sprite_remove(litter); + EntityRemove(litter); } } diff --git a/src/openrct2/world/Fountain.cpp b/src/openrct2/world/Fountain.cpp index 2bf539ea20..6da08d9e63 100644 --- a/src/openrct2/world/Fountain.cpp +++ b/src/openrct2/world/Fountain.cpp @@ -187,7 +187,7 @@ void JumpingFountain::Update() if (frame == 16) { - sprite_remove(this); + EntityRemove(this); } } diff --git a/src/openrct2/world/Litter.cpp b/src/openrct2/world/Litter.cpp index 236f0150af..19b8bb87a8 100644 --- a/src/openrct2/world/Litter.cpp +++ b/src/openrct2/world/Litter.cpp @@ -63,7 +63,7 @@ void Litter::Create(const CoordsXYZD& litterPos, Type type) if (newestLitter != nullptr) { newestLitter->Invalidate(); - sprite_remove(newestLitter); + EntityRemove(newestLitter); } } @@ -100,7 +100,7 @@ void Litter::RemoveAt(const CoordsXYZ& litterPos) for (auto* litter : removals) { litter->Invalidate(); - sprite_remove(litter); + EntityRemove(litter); } } diff --git a/src/openrct2/world/MoneyEffect.cpp b/src/openrct2/world/MoneyEffect.cpp index 1e57a997fa..aa474fd10e 100644 --- a/src/openrct2/world/MoneyEffect.cpp +++ b/src/openrct2/world/MoneyEffect.cpp @@ -135,7 +135,7 @@ void MoneyEffect::Update() return; } - sprite_remove(this); + EntityRemove(this); } std::pair MoneyEffect::GetStringId() const diff --git a/src/openrct2/world/Particle.cpp b/src/openrct2/world/Particle.cpp index 9626b82802..1c711420a1 100644 --- a/src/openrct2/world/Particle.cpp +++ b/src/openrct2/world/Particle.cpp @@ -62,7 +62,7 @@ void VehicleCrashParticle::Update() time_to_live--; if (time_to_live == 0) { - sprite_remove(this); + EntityRemove(this); return; } @@ -94,7 +94,7 @@ void VehicleCrashParticle::Update() // Splash OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Water2, { x, y, waterZ }); CrashSplashParticle::Create({ x, y, waterZ }); - sprite_remove(this); + EntityRemove(this); return; } @@ -140,7 +140,7 @@ void CrashSplashParticle::Update() frame += 85; if (frame >= 7168) { - sprite_remove(this); + EntityRemove(this); } } @@ -183,7 +183,7 @@ void SteamParticle::Update() frame += 64; if (frame >= (56 * 64)) { - sprite_remove(this); + EntityRemove(this); } } @@ -214,7 +214,7 @@ void ExplosionCloud::Update() frame += 128; if (frame >= (36 * 128)) { - sprite_remove(this); + EntityRemove(this); } } @@ -245,6 +245,6 @@ void ExplosionFlare::Update() frame += 64; if (frame >= (124 * 64)) { - sprite_remove(this); + EntityRemove(this); } } diff --git a/src/openrct2/world/Sprite.cpp b/src/openrct2/world/Sprite.cpp index 7b2fd74e0f..016be80088 100644 --- a/src/openrct2/world/Sprite.cpp +++ b/src/openrct2/world/Sprite.cpp @@ -34,11 +34,11 @@ #include #include -static rct_sprite _spriteList[MAX_ENTITIES]; +static Entity _entities[MAX_ENTITIES]; static std::array, EnumValue(EntityType::Count)> gEntityLists; static std::vector _freeIdList; -static bool _spriteFlashingList[MAX_ENTITIES]; +static bool _entityFlashingList[MAX_ENTITIES]; 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; @@ -117,7 +117,7 @@ uint16_t GetNumFreeEntities() return static_cast(_freeIdList.size()); } -std::string rct_sprite_checksum::ToString() const +std::string EntitiesChecksum::ToString() const { std::string result; @@ -132,19 +132,19 @@ std::string rct_sprite_checksum::ToString() const return result; } -EntityBase* TryGetEntity(size_t spriteIndex) +EntityBase* TryGetEntity(size_t entityIndex) { - return spriteIndex >= MAX_ENTITIES ? nullptr : &_spriteList[spriteIndex].base; + return entityIndex >= MAX_ENTITIES ? nullptr : &_entities[entityIndex].base; } -EntityBase* GetEntity(size_t spriteIndex) +EntityBase* GetEntity(size_t entityIndex) { - if (spriteIndex == SPRITE_INDEX_NULL) + if (entityIndex == SPRITE_INDEX_NULL) { return nullptr; } - openrct2_assert(spriteIndex < MAX_ENTITIES, "Tried getting sprite %u", spriteIndex); - return TryGetEntity(spriteIndex); + openrct2_assert(entityIndex < MAX_ENTITIES, "Tried getting sprite %u", entityIndex); + return TryGetEntity(entityIndex); } const std::vector& GetEntityTileList(const CoordsXY& spritePos) @@ -231,7 +231,7 @@ void ResetAllEntities() FreeEntity(*spr); } - std::fill(std::begin(_spriteList), std::end(_spriteList), rct_sprite()); + std::fill(std::begin(_entities), std::end(_entities), Entity()); OpenRCT2::RideUse::GetHistory().Clear(); OpenRCT2::RideUse::GetTypeHistory().Clear(); for (int32_t i = 0; i < MAX_ENTITIES; ++i) @@ -244,14 +244,14 @@ void ResetAllEntities() spr->Type = EntityType::Null; spr->sprite_index = i; - _spriteFlashingList[i] = false; + _entityFlashingList[i] = false; } ResetEntityLists(); ResetFreeIds(); - reset_sprite_spatial_index(); + ResetEntitySpatialIndices(); } -static void SpriteSpatialInsert(EntityBase* sprite, const CoordsXY& newLoc); +static void EntitySpatialInsert(EntityBase* entity, const CoordsXY& newLoc); /** * @@ -259,7 +259,7 @@ static void SpriteSpatialInsert(EntityBase* sprite, const CoordsXY& newLoc); * This function looks as though it sets some sort of order for sprites. * Sprites can share their position if this is the case. */ -void reset_sprite_spatial_index() +void ResetEntitySpatialIndices() { for (auto& vec : gEntitySpatialIndex) { @@ -270,7 +270,7 @@ void reset_sprite_spatial_index() auto* spr = GetEntity(i); if (spr != nullptr && spr->Type != EntityType::Null) { - SpriteSpatialInsert(spr, { spr->x, spr->y }); + EntitySpatialInsert(spr, { spr->x, spr->y }); } } } @@ -290,9 +290,9 @@ template void NetworkSerialiseEntityTypes(DataSerialiser& ds) (NetworkSerialseEntityType(ds), ...); } -rct_sprite_checksum sprite_checksum() +EntitiesChecksum GetAllEntitiesChecksum() { - rct_sprite_checksum checksum{}; + EntitiesChecksum checksum{}; OpenRCT2::ChecksumStream ms(checksum.raw); DataSerialiser ds(true, ms); @@ -302,24 +302,24 @@ rct_sprite_checksum sprite_checksum() } #else -rct_sprite_checksum sprite_checksum() +EntitiesChecksum GetAllEntitiesChecksum() { - return rct_sprite_checksum{}; + return EntitiesChecksum{}; } #endif // DISABLE_NETWORK -static void sprite_reset(EntityBase* sprite) +static void EntityReset(EntityBase* entity) { // Need to retain how the sprite is linked in lists - uint16_t sprite_index = sprite->sprite_index; - _spriteFlashingList[sprite_index] = false; + uint16_t entityIndex = entity->sprite_index; + _entityFlashingList[entityIndex] = false; - rct_sprite* spr = reinterpret_cast(sprite); - *spr = rct_sprite(); + Entity* spr = reinterpret_cast(entity); + *spr = Entity(); - sprite->sprite_index = sprite_index; - sprite->Type = EntityType::Null; + entity->sprite_index = entityIndex; + entity->Type = EntityType::Null; } static constexpr uint16_t MAX_MISC_SPRITES = 300; @@ -362,7 +362,7 @@ static void PrepareNewEntity(EntityBase* base, const EntityType type) { // Need to reset all sprite data, as the uninitialised values // may contain garbage and cause a desync later on. - sprite_reset(base); + EntityReset(base); base->Type = type; AddToEntityList(base); @@ -375,7 +375,7 @@ static void PrepareNewEntity(EntityBase* base, const EntityType type) base->sprite_height_positive = 0x8; base->SpriteRect = {}; - SpriteSpatialInsert(base, { LOCATION_NULL, 0 }); + EntitySpatialInsert(base, { LOCATION_NULL, 0 }); } EntityBase* CreateEntity(EntityType type) @@ -447,7 +447,7 @@ template void MiscUpdateAllTypes() * * rct2: 0x00672AA4 */ -void sprite_misc_update_all() +void UpdateAllMiscEntities() { MiscUpdateAllTypes< SteamParticle, MoneyEffect, VehicleCrashParticle, ExplosionCloud, CrashSplashParticle, ExplosionFlare, JumpingFountain, @@ -455,39 +455,39 @@ void sprite_misc_update_all() } // Performs a search to ensure that insert keeps next_in_quadrant in sprite_index order -static void SpriteSpatialInsert(EntityBase* sprite, const CoordsXY& newLoc) +static void EntitySpatialInsert(EntityBase* entity, const CoordsXY& newLoc) { size_t newIndex = GetSpatialIndexOffset(newLoc); auto& spatialVector = gEntitySpatialIndex[newIndex]; - auto index = std::lower_bound(std::begin(spatialVector), std::end(spatialVector), sprite->sprite_index); - spatialVector.insert(index, sprite->sprite_index); + auto index = std::lower_bound(std::begin(spatialVector), std::end(spatialVector), entity->sprite_index); + spatialVector.insert(index, entity->sprite_index); } -static void SpriteSpatialRemove(EntityBase* sprite) +static void EntitySpatialRemove(EntityBase* entity) { - size_t currentIndex = GetSpatialIndexOffset({ sprite->x, sprite->y }); + size_t currentIndex = GetSpatialIndexOffset({ entity->x, entity->y }); auto& spatialVector = gEntitySpatialIndex[currentIndex]; - auto index = std::lower_bound(std::begin(spatialVector), std::end(spatialVector), sprite->sprite_index); - if (index != std::end(spatialVector) && *index == sprite->sprite_index) + auto index = std::lower_bound(std::begin(spatialVector), std::end(spatialVector), entity->sprite_index); + if (index != std::end(spatialVector) && *index == entity->sprite_index) { spatialVector.erase(index, index + 1); } else { log_warning("Bad sprite spatial index. Rebuilding the spatial index..."); - reset_sprite_spatial_index(); + ResetEntitySpatialIndices(); } } -static void SpriteSpatialMove(EntityBase* sprite, const CoordsXY& newLoc) +static void EntitySpatialMove(EntityBase* entity, const CoordsXY& newLoc) { size_t newIndex = GetSpatialIndexOffset(newLoc); - size_t currentIndex = GetSpatialIndexOffset({ sprite->x, sprite->y }); + size_t currentIndex = GetSpatialIndexOffset({ entity->x, entity->y }); if (newIndex == currentIndex) return; - SpriteSpatialRemove(sprite); - SpriteSpatialInsert(sprite, newLoc); + EntitySpatialRemove(entity); + EntitySpatialInsert(entity, newLoc); } void EntityBase::MoveTo(const CoordsXYZ& newLocation) @@ -504,7 +504,7 @@ void EntityBase::MoveTo(const CoordsXYZ& newLocation) loc.x = LOCATION_NULL; } - SpriteSpatialMove(this, loc); + EntitySpatialMove(this, loc); if (loc.x == LOCATION_NULL) { @@ -514,7 +514,7 @@ void EntityBase::MoveTo(const CoordsXYZ& newLocation) } else { - sprite_set_coordinates(loc, this); + EntitySetCoordinates(loc, this); Invalidate(); // Invalidate new position. } } @@ -531,14 +531,14 @@ void EntityBase::SetLocation(const CoordsXYZ& newLocation) z = static_cast(newLocation.z); } -void sprite_set_coordinates(const CoordsXYZ& spritePos, EntityBase* sprite) +void EntitySetCoordinates(const CoordsXYZ& entityPos, EntityBase* entity) { - auto screenCoords = translate_3d_to_2d_with_z(get_current_rotation(), spritePos); + auto screenCoords = translate_3d_to_2d_with_z(get_current_rotation(), entityPos); - sprite->SpriteRect = ScreenRect( - screenCoords - ScreenCoordsXY{ sprite->sprite_width, sprite->sprite_height_negative }, - screenCoords + ScreenCoordsXY{ sprite->sprite_width, sprite->sprite_height_positive }); - sprite->SetLocation(spritePos); + entity->SpriteRect = ScreenRect( + screenCoords - ScreenCoordsXY{ entity->sprite_width, entity->sprite_height_negative }, + screenCoords + ScreenCoordsXY{ entity->sprite_width, entity->sprite_height_positive }); + entity->SetLocation(entityPos); } /** @@ -565,54 +565,54 @@ static void FreeEntity(EntityBase& entity) * * rct2: 0x0069EDB6 */ -void sprite_remove(EntityBase* sprite) +void EntityRemove(EntityBase* entity) { - FreeEntity(*sprite); + FreeEntity(*entity); - EntityTweener::Get().RemoveEntity(sprite); - RemoveFromEntityList(sprite); // remove from existing list - AddToFreeList(sprite->sprite_index); + EntityTweener::Get().RemoveEntity(entity); + RemoveFromEntityList(entity); // remove from existing list + AddToFreeList(entity->sprite_index); - SpriteSpatialRemove(sprite); - sprite_reset(sprite); + EntitySpatialRemove(entity); + EntityReset(entity); } /** - * Loops through all sprites, finds floating objects and removes them. + * Loops through all floating entities and removes them. * Returns the amount of removed objects as feedback. */ -uint16_t remove_floating_sprites() +uint16_t RemoveFloatingEntities() { uint16_t removed = 0; for (auto* balloon : EntityList()) { - sprite_remove(balloon); + EntityRemove(balloon); removed++; } for (auto* duck : EntityList()) { if (duck->IsFlying()) { - sprite_remove(duck); + EntityRemove(duck); removed++; } } for (auto* money : EntityList()) { - sprite_remove(money); + EntityRemove(money); removed++; } return removed; } -void sprite_set_flashing(EntityBase* sprite, bool flashing) +void EntitySetFlashing(EntityBase* entity, bool flashing) { - assert(sprite->sprite_index < MAX_ENTITIES); - _spriteFlashingList[sprite->sprite_index] = flashing; + assert(entity->sprite_index < MAX_ENTITIES); + _entityFlashingList[entity->sprite_index] = flashing; } -bool sprite_get_flashing(EntityBase* sprite) +bool EntityGetFlashing(EntityBase* entity) { - assert(sprite->sprite_index < MAX_ENTITIES); - return _spriteFlashingList[sprite->sprite_index]; + assert(entity->sprite_index < MAX_ENTITIES); + return _entityFlashingList[entity->sprite_index]; } diff --git a/src/openrct2/world/Sprite.h b/src/openrct2/world/Sprite.h index ec0309b452..a1740b6c4d 100644 --- a/src/openrct2/world/Sprite.h +++ b/src/openrct2/world/Sprite.h @@ -16,22 +16,22 @@ #pragma pack(push, 1) /** - * Sprite structure. + * Entity structure. * size: 0x0200 */ -union rct_sprite +union Entity { uint8_t pad_00[0x200]; EntityBase base; - // Provide a constructor as EntityBase is not trivialy constructable - rct_sprite() + // Provide a constructor as EntityBase is not trivially constructible + Entity() : pad_00() { } }; -assert_struct_size(rct_sprite, 0x200); +assert_struct_size(Entity, 0x200); -struct rct_sprite_checksum +struct EntitiesChecksum { std::array raw; @@ -41,13 +41,13 @@ struct rct_sprite_checksum #pragma pack(pop) void ResetAllEntities(); -void reset_sprite_spatial_index(); -void sprite_misc_update_all(); -void sprite_set_coordinates(const CoordsXYZ& spritePos, EntityBase* sprite); -void sprite_remove(EntityBase* sprite); -uint16_t remove_floating_sprites(); +void ResetEntitySpatialIndices(); +void UpdateAllMiscEntities(); +void EntitySetCoordinates(const CoordsXYZ& entityPos, EntityBase* entity); +void EntityRemove(EntityBase* entity); +uint16_t RemoveFloatingEntities(); -rct_sprite_checksum sprite_checksum(); +EntitiesChecksum GetAllEntitiesChecksum(); -void sprite_set_flashing(EntityBase* sprite, bool flashing); -bool sprite_get_flashing(EntityBase* sprite); +void EntitySetFlashing(EntityBase* entity, bool flashing); +bool EntityGetFlashing(EntityBase* entity); diff --git a/test/tests/PlayTests.cpp b/test/tests/PlayTests.cpp index 55b5695373..8d6bbd9e53 100644 --- a/test/tests/PlayTests.cpp +++ b/test/tests/PlayTests.cpp @@ -49,7 +49,7 @@ static std::unique_ptr localStartGame(const std::string& parkPath) context->GetObjectManager().LoadObjects(loadResult.RequiredObjects); importer->Import(); - reset_sprite_spatial_index(); + ResetEntitySpatialIndices(); reset_all_sprite_quadrant_placements(); scenery_set_default_placement_configuration(); diff --git a/test/tests/S6ImportExportTests.cpp b/test/tests/S6ImportExportTests.cpp index dcd5093325..2a8285229b 100644 --- a/test/tests/S6ImportExportTests.cpp +++ b/test/tests/S6ImportExportTests.cpp @@ -60,7 +60,7 @@ static bool LoadFileToBuffer(MemoryStream& stream, const std::string& filePath) static void GameInit(bool retainSpatialIndices) { if (!retainSpatialIndices) - reset_sprite_spatial_index(); + ResetEntitySpatialIndices(); reset_all_sprite_quadrant_placements(); scenery_set_default_placement_configuration();