From cb76165448fc4839879f868ca6943499f4ecd842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Fri, 26 Nov 2021 16:40:18 +0200 Subject: [PATCH] Move code from Entity.h into EntityRegistry.h --- src/openrct2/entity/Entity.h | 45 --------------------------- src/openrct2/entity/EntityRegistry.h | 46 +++++++++++++++++++++++----- src/openrct2/libopenrct2.vcxproj | 1 - 3 files changed, 39 insertions(+), 53 deletions(-) delete mode 100644 src/openrct2/entity/Entity.h diff --git a/src/openrct2/entity/Entity.h b/src/openrct2/entity/Entity.h deleted file mode 100644 index df933daa04..0000000000 --- a/src/openrct2/entity/Entity.h +++ /dev/null @@ -1,45 +0,0 @@ -/***************************************************************************** - * 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 "EntityBase.h" - -constexpr uint16_t MAX_ENTITIES = 65535; - -EntityBase* GetEntity(size_t sprite_idx); - -template T* GetEntity(size_t sprite_idx) -{ - auto spr = GetEntity(sprite_idx); - return spr != nullptr ? spr->As() : nullptr; -} - -EntityBase* TryGetEntity(size_t spriteIndex); - -template T* TryGetEntity(size_t sprite_idx) -{ - auto spr = TryGetEntity(sprite_idx); - return spr != nullptr ? spr->As() : nullptr; -} - -EntityBase* CreateEntity(EntityType type); - -template T* CreateEntity() -{ - return static_cast(CreateEntity(T::cEntityType)); -} - -// Use only with imports that must happen at a specified index -EntityBase* CreateEntityAt(const uint16_t index, const EntityType type); -// Use only with imports that must happen at a specified index -template T* CreateEntityAt(const uint16_t index) -{ - return static_cast(CreateEntityAt(index, T::cEntityType)); -} diff --git a/src/openrct2/entity/EntityRegistry.h b/src/openrct2/entity/EntityRegistry.h index affeb4b833..458129ca26 100644 --- a/src/openrct2/entity/EntityRegistry.h +++ b/src/openrct2/entity/EntityRegistry.h @@ -14,14 +14,38 @@ #include -#pragma pack(push, 1) -struct EntitiesChecksum -{ - std::array raw; +constexpr uint16_t MAX_ENTITIES = 65535; - std::string ToString() const; -}; -#pragma pack(pop) +EntityBase* GetEntity(size_t sprite_idx); + +template T* GetEntity(size_t sprite_idx) +{ + auto spr = GetEntity(sprite_idx); + return spr != nullptr ? spr->As() : nullptr; +} + +EntityBase* TryGetEntity(size_t spriteIndex); + +template T* TryGetEntity(size_t sprite_idx) +{ + auto spr = TryGetEntity(sprite_idx); + return spr != nullptr ? spr->As() : nullptr; +} + +EntityBase* CreateEntity(EntityType type); + +template T* CreateEntity() +{ + return static_cast(CreateEntity(T::cEntityType)); +} + +// Use only with imports that must happen at a specified index +EntityBase* CreateEntityAt(const uint16_t index, const EntityType type); +// Use only with imports that must happen at a specified index +template T* CreateEntityAt(const uint16_t index) +{ + return static_cast(CreateEntityAt(index, T::cEntityType)); +} void ResetAllEntities(); void ResetEntitySpatialIndices(); @@ -30,6 +54,14 @@ void EntitySetCoordinates(const CoordsXYZ& entityPos, EntityBase* entity); void EntityRemove(EntityBase* entity); uint16_t RemoveFloatingEntities(); +#pragma pack(push, 1) +struct EntitiesChecksum +{ + std::array raw; + + std::string ToString() const; +}; +#pragma pack(pop) EntitiesChecksum GetAllEntitiesChecksum(); void EntitySetFlashing(EntityBase* entity, bool flashing); diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 3d126ab9ab..c25edab8b9 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -207,7 +207,6 @@ -