From 496fdfd3ebe13c61099ffcd18c87e8b221445871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Sat, 27 Nov 2021 15:12:57 +0200 Subject: [PATCH] Move remaining EntityBase functions to EntityBase.cpp --- src/openrct2/entity/EntityBase.cpp | 56 +++++++++++++++++++ src/openrct2/entity/EntityRegistry.cpp | 76 -------------------------- src/openrct2/entity/Litter.cpp | 5 ++ src/openrct2/entity/Particle.cpp | 15 +++++ 4 files changed, 76 insertions(+), 76 deletions(-) diff --git a/src/openrct2/entity/EntityBase.cpp b/src/openrct2/entity/EntityBase.cpp index 0555f4b672..9914b4901b 100644 --- a/src/openrct2/entity/EntityBase.cpp +++ b/src/openrct2/entity/EntityBase.cpp @@ -11,6 +11,62 @@ #include "../core/DataSerialiser.h" +// Required for GetEntity to return a default +template<> bool EntityBase::Is() const +{ + return true; +} + +CoordsXYZ EntityBase::GetLocation() const +{ + return { x, y, z }; +} + +void EntityBase::SetLocation(const CoordsXYZ& newLocation) +{ + x = newLocation.x; + y = newLocation.y; + z = newLocation.z; +} + +void EntityBase::Invalidate() +{ + if (x == LOCATION_NULL) + return; + + int32_t maxZoom = 0; + switch (Type) + { + case EntityType::Vehicle: + case EntityType::Guest: + case EntityType::Staff: + maxZoom = 2; + break; + case EntityType::CrashedVehicleParticle: + case EntityType::JumpingFountain: + maxZoom = 0; + break; + case EntityType::Duck: + maxZoom = 1; + break; + case EntityType::SteamParticle: + case EntityType::MoneyEffect: + case EntityType::ExplosionCloud: + case EntityType::CrashSplash: + case EntityType::ExplosionFlare: + case EntityType::Balloon: + maxZoom = 2; + break; + case EntityType::Litter: + maxZoom = 0; + break; + default: + break; + } + + viewports_invalidate(SpriteRect, maxZoom); +} + void EntityBase::Serialise(DataSerialiser& stream) { stream << Type; diff --git a/src/openrct2/entity/EntityRegistry.cpp b/src/openrct2/entity/EntityRegistry.cpp index 5492c52909..5c661222e0 100644 --- a/src/openrct2/entity/EntityRegistry.cpp +++ b/src/openrct2/entity/EntityRegistry.cpp @@ -72,17 +72,6 @@ static constexpr size_t GetSpatialIndexOffset(const CoordsXY& loc) return tileX * MAXIMUM_MAP_SIZE_TECHNICAL + tileY; } -// Required for GetEntity to return a default -template<> bool EntityBase::Is() const -{ - return true; -} - -template<> bool EntityBase::Is() const -{ - return Type == EntityType::Litter; -} - constexpr bool EntityTypeIsMiscEntity(const EntityType type) { switch (type) @@ -102,21 +91,6 @@ constexpr bool EntityTypeIsMiscEntity(const EntityType type) } } -template<> bool EntityBase::Is() const -{ - return Type == EntityType::SteamParticle; -} - -template<> bool EntityBase::Is() const -{ - return Type == EntityType::ExplosionFlare; -} - -template<> bool EntityBase::Is() const -{ - return Type == EntityType::ExplosionCloud; -} - uint16_t GetEntityListCount(EntityType type) { return static_cast(gEntityLists[EnumValue(type)].size()); @@ -162,44 +136,6 @@ const std::vector& GetEntityTileList(const CoordsXY& spritePos) return gEntitySpatialIndex[GetSpatialIndexOffset(spritePos)]; } -void EntityBase::Invalidate() -{ - if (x == LOCATION_NULL) - return; - - int32_t maxZoom = 0; - switch (Type) - { - case EntityType::Vehicle: - case EntityType::Guest: - case EntityType::Staff: - maxZoom = 2; - break; - case EntityType::CrashedVehicleParticle: - case EntityType::JumpingFountain: - maxZoom = 0; - break; - case EntityType::Duck: - maxZoom = 1; - break; - case EntityType::SteamParticle: - case EntityType::MoneyEffect: - case EntityType::ExplosionCloud: - case EntityType::CrashSplash: - case EntityType::ExplosionFlare: - case EntityType::Balloon: - maxZoom = 2; - break; - case EntityType::Litter: - maxZoom = 0; - break; - default: - break; - } - - viewports_invalidate(SpriteRect, maxZoom); -} - static void ResetEntityLists() { for (auto& list : gEntityLists) @@ -529,18 +465,6 @@ void EntityBase::MoveTo(const CoordsXYZ& newLocation) } } -CoordsXYZ EntityBase::GetLocation() const -{ - return { x, y, z }; -} - -void EntityBase::SetLocation(const CoordsXYZ& newLocation) -{ - x = newLocation.x; - y = newLocation.y; - z = newLocation.z; -} - void EntitySetCoordinates(const CoordsXYZ& entityPos, EntityBase* entity) { auto screenCoords = translate_3d_to_2d_with_z(get_current_rotation(), entityPos); diff --git a/src/openrct2/entity/Litter.cpp b/src/openrct2/entity/Litter.cpp index 9c6d32c5eb..8a94d6e3f0 100644 --- a/src/openrct2/entity/Litter.cpp +++ b/src/openrct2/entity/Litter.cpp @@ -8,6 +8,11 @@ #include "EntityList.h" #include "EntityRegistry.h" +template<> bool EntityBase::Is() const +{ + return Type == EntityType::Litter; +} + static bool isLocationLitterable(const CoordsXYZ& mapPos) { TileElement* tileElement; diff --git a/src/openrct2/entity/Particle.cpp b/src/openrct2/entity/Particle.cpp index f2182c3072..a5518e8992 100644 --- a/src/openrct2/entity/Particle.cpp +++ b/src/openrct2/entity/Particle.cpp @@ -16,6 +16,21 @@ #include +template<> bool EntityBase::Is() const +{ + return Type == EntityType::SteamParticle; +} + +template<> bool EntityBase::Is() const +{ + return Type == EntityType::ExplosionFlare; +} + +template<> bool EntityBase::Is() const +{ + return Type == EntityType::ExplosionCloud; +} + template<> bool EntityBase::Is() const { return Type == EntityType::CrashedVehicleParticle;