forked from rosebudai/OpenRCT2-Web
More renaming
This commit is contained in:
28 files changed
+135
-135
No files matched your search
@@ -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);
|
||||
|
||||
@@ -620,14 +620,14 @@ public:
|
||||
|
||||
for (auto peep : EntityList<Guest>())
|
||||
{
|
||||
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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -191,10 +191,10 @@ public:
|
||||
gWindowMapFlashingFlags |= MapFlashingFlags::StaffListOpen;
|
||||
for (auto peep : EntityList<Staff>())
|
||||
{
|
||||
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<Staff>())
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -56,7 +56,7 @@ struct GameStateSnapshot_t
|
||||
}
|
||||
|
||||
// Must pass a function that can access the sprite.
|
||||
void SerialiseSprites(std::function<rct_sprite*(const size_t)> getEntity, const size_t numSprites, bool saving)
|
||||
void SerialiseSprites(std::function<Entity*(const size_t)> 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<rct_sprite*>(GetEntity(index)); }, MAX_ENTITIES, true);
|
||||
[](const size_t index) { return reinterpret_cast<Entity*>(GetEntity(index)); }, MAX_ENTITIES, true);
|
||||
|
||||
// log_info("Snapshot size: %u bytes", static_cast<uint32_t>(snapshot.storedSprites.GetLength()));
|
||||
}
|
||||
@@ -194,9 +194,9 @@ struct GameStateSnapshots final : public IGameStateSnapshots
|
||||
ds << snapshot.parkParameters;
|
||||
}
|
||||
|
||||
std::vector<rct_sprite> BuildSpriteList(GameStateSnapshot_t& snapshot) const
|
||||
std::vector<Entity> BuildSpriteList(GameStateSnapshot_t& snapshot) const
|
||||
{
|
||||
std::vector<rct_sprite> spriteList;
|
||||
std::vector<Entity> 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<rct_sprite> spritesBase = BuildSpriteList(const_cast<GameStateSnapshot_t&>(base));
|
||||
std::vector<rct_sprite> spritesCmp = BuildSpriteList(const_cast<GameStateSnapshot_t&>(cmp));
|
||||
std::vector<Entity> spritesBase = BuildSpriteList(const_cast<GameStateSnapshot_t&>(base));
|
||||
std::vector<Entity> spritesCmp = BuildSpriteList(const_cast<GameStateSnapshot_t&>(cmp));
|
||||
|
||||
for (uint32_t i = 0; i < static_cast<uint32_t>(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;
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace OpenRCT2
|
||||
uint32_t tickStart; // First tick of replay.
|
||||
uint32_t tickEnd; // Last tick of replay.
|
||||
std::multiset<ReplayCommand> commands;
|
||||
std::vector<std::pair<uint32_t, rct_sprite_checksum>> checksums;
|
||||
std::vector<std::pair<uint32_t, EntitiesChecksum>> 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;
|
||||
|
||||
@@ -415,7 +415,7 @@ void SetCheatAction::RemoveLitter() const
|
||||
{
|
||||
for (auto litter : EntityList<Litter>())
|
||||
{
|
||||
sprite_remove(litter);
|
||||
EntityRemove(litter);
|
||||
}
|
||||
|
||||
tile_element_iterator it{};
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -29,7 +29,7 @@ void Balloon::Update()
|
||||
frame++;
|
||||
if (frame >= 5)
|
||||
{
|
||||
sprite_remove(this);
|
||||
EntityRemove(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -80,7 +80,7 @@ bool Duck::IsFlying()
|
||||
void Duck::Remove()
|
||||
{
|
||||
Invalidate();
|
||||
sprite_remove(this);
|
||||
EntityRemove(this);
|
||||
}
|
||||
|
||||
void Duck::UpdateFlyToWater()
|
||||
|
||||
@@ -85,7 +85,7 @@ void EntityTweener::Tween(float alpha)
|
||||
if (posA == posB)
|
||||
continue;
|
||||
|
||||
sprite_set_coordinates(
|
||||
EntitySetCoordinates(
|
||||
{ static_cast<int32_t>(std::round(posB.x * alpha + posA.x * inv)),
|
||||
static_cast<int32_t>(std::round(posB.y * alpha + posA.y * inv)),
|
||||
static_cast<int32_t>(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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ void footpath_remove_litter(const CoordsXYZ& footpathPos)
|
||||
for (auto* litter : removals)
|
||||
{
|
||||
litter->Invalidate();
|
||||
sprite_remove(litter);
|
||||
EntityRemove(litter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ void JumpingFountain::Update()
|
||||
|
||||
if (frame == 16)
|
||||
{
|
||||
sprite_remove(this);
|
||||
EntityRemove(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ void MoneyEffect::Update()
|
||||
return;
|
||||
}
|
||||
|
||||
sprite_remove(this);
|
||||
EntityRemove(this);
|
||||
}
|
||||
|
||||
std::pair<rct_string_id, money64> MoneyEffect::GetStringId() const
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -34,11 +34,11 @@
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
|
||||
static rct_sprite _spriteList[MAX_ENTITIES];
|
||||
static Entity _entities[MAX_ENTITIES];
|
||||
static std::array<std::list<uint16_t>, EnumValue(EntityType::Count)> gEntityLists;
|
||||
static std::vector<uint16_t> _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<uint16_t>(_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<uint16_t>& 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<typename... T> void NetworkSerialiseEntityTypes(DataSerialiser& ds)
|
||||
(NetworkSerialseEntityType<T>(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<rct_sprite*>(sprite);
|
||||
*spr = rct_sprite();
|
||||
Entity* spr = reinterpret_cast<Entity*>(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<typename... T> 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<int16_t>(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<Balloon>())
|
||||
{
|
||||
sprite_remove(balloon);
|
||||
EntityRemove(balloon);
|
||||
removed++;
|
||||
}
|
||||
for (auto* duck : EntityList<Duck>())
|
||||
{
|
||||
if (duck->IsFlying())
|
||||
{
|
||||
sprite_remove(duck);
|
||||
EntityRemove(duck);
|
||||
removed++;
|
||||
}
|
||||
}
|
||||
for (auto* money : EntityList<MoneyEffect>())
|
||||
{
|
||||
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];
|
||||
}
|
||||
+14
-14
@@ -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<std::byte, 20> 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);
|
||||
@@ -49,7 +49,7 @@ static std::unique_ptr<IContext> 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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user