diff --git a/src/openrct2-ui/interface/LandTool.cpp b/src/openrct2-ui/interface/LandTool.cpp index a52541b77b24..aceeedf02d06 100644 --- a/src/openrct2-ui/interface/LandTool.cpp +++ b/src/openrct2-ui/interface/LandTool.cpp @@ -60,7 +60,7 @@ void LandTool::ShowSurfaceStyleDropdown(WindowBase* w, Widget* widget, ObjectEnt auto itemIndex = 0; for (size_t i = 0; i < kMaxTerrainSurfaceObjects; i++) { - const auto surfaceObj = static_cast(objManager.GetLoadedObject(ObjectType::TerrainSurface, i)); + const auto surfaceObj = objManager.GetLoadedObject(i); // If fallback images are loaded, the RCT1 styles will just look like copies of already existing styles, so hide them. if (surfaceObj != nullptr && !surfaceObj->UsesFallbackImages()) { @@ -92,7 +92,7 @@ ObjectEntryIndex LandTool::GetSurfaceStyleFromDropdownIndex(size_t index) auto itemIndex = 0U; for (size_t i = 0; i < kMaxTerrainSurfaceObjects; i++) { - const auto surfaceObj = static_cast(objManager.GetLoadedObject(ObjectType::TerrainSurface, i)); + const auto surfaceObj = objManager.GetLoadedObject(i); // If fallback images are loaded, the RCT1 styles will just look like copies of already existing styles, so hide them. if (surfaceObj != nullptr && !surfaceObj->UsesFallbackImages()) { @@ -114,7 +114,7 @@ void LandTool::ShowEdgeStyleDropdown(WindowBase* w, Widget* widget, ObjectEntryI auto itemIndex = 0; for (size_t i = 0; i < kMaxTerrainEdgeObjects; i++) { - const auto edgeObj = static_cast(objManager.GetLoadedObject(ObjectType::TerrainEdge, i)); + const auto edgeObj = objManager.GetLoadedObject(i); // If fallback images are loaded, the RCT1 styles will just look like copies of already existing styles, so hide them. if (edgeObj != nullptr && !edgeObj->UsesFallbackImages()) { @@ -143,7 +143,7 @@ ObjectEntryIndex LandTool::GetEdgeStyleFromDropdownIndex(size_t index) auto itemIndex = 0U; for (size_t i = 0; i < kMaxTerrainEdgeObjects; i++) { - const auto edgeObj = static_cast(objManager.GetLoadedObject(ObjectType::TerrainEdge, i)); + const auto edgeObj = objManager.GetLoadedObject(i); // If fallback images are loaded, the RCT1 styles will just look like copies of already existing styles, so hide them. if (edgeObj != nullptr && !edgeObj->UsesFallbackImages()) { diff --git a/src/openrct2-ui/windows/EditorParkEntrance.cpp b/src/openrct2-ui/windows/EditorParkEntrance.cpp index fcaa1fdd42ff..05108e445ee5 100644 --- a/src/openrct2-ui/windows/EditorParkEntrance.cpp +++ b/src/openrct2-ui/windows/EditorParkEntrance.cpp @@ -79,7 +79,7 @@ namespace OpenRCT2::Ui::Windows for (ObjectEntryIndex objectIndex = 0; objectIndex < kMaxParkEntranceObjects; objectIndex++) { auto& objManager = GetContext()->GetObjectManager(); - auto* object = static_cast(objManager.GetLoadedObject(ObjectType::ParkEntrance, objectIndex)); + auto* object = objManager.GetLoadedObject(objectIndex); if (object != nullptr) { const auto* legacyData = reinterpret_cast(object->GetLegacyData()); diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index 2cefec06363d..b6f0a551b681 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -715,7 +715,7 @@ namespace OpenRCT2::Ui::Windows for (ObjectEntryIndex i = 0; i < kMaxPathObjects; i++) { - auto* pathObj = static_cast(objManager.GetLoadedObject(ObjectType::Paths, i)); + auto* pathObj = objManager.GetLoadedObject(i); if (pathObj == nullptr) { continue; diff --git a/src/openrct2-ui/windows/NewRide.cpp b/src/openrct2-ui/windows/NewRide.cpp index 490f2efba34b..ef4043e3d99c 100644 --- a/src/openrct2-ui/windows/NewRide.cpp +++ b/src/openrct2-ui/windows/NewRide.cpp @@ -638,7 +638,7 @@ namespace OpenRCT2::Ui::Windows ImageIndex GetRideImage(RideSelection rideSelection) { auto& objMgr = OpenRCT2::GetContext()->GetObjectManager(); - auto obj = static_cast(objMgr.GetLoadedObject(ObjectType::Ride, rideSelection.EntryIndex)); + auto obj = objMgr.GetLoadedObject(rideSelection.EntryIndex); return obj == nullptr ? ImageIndexUndefined : obj->GetPreviewImage(rideSelection.Type); } @@ -683,7 +683,7 @@ namespace OpenRCT2::Ui::Windows // Ride entries auto& objMgr = OpenRCT2::GetContext()->GetObjectManager(); - auto rideObj = static_cast(objMgr.GetLoadedObject(ObjectType::Ride, rideEntryIndex)); + auto* rideObj = objMgr.GetLoadedObject(rideEntryIndex); // Skip if the vehicle isn't the preferred vehicle for this generic track type if (!Config::Get().interface.ListRideVehiclesSeparately @@ -918,7 +918,7 @@ namespace OpenRCT2::Ui::Windows void DrawRideInformation(DrawPixelInfo& dpi, RideSelection item, const ScreenCoordsXY& screenPos, int32_t textWidth) { auto& objMgr = OpenRCT2::GetContext()->GetObjectManager(); - auto rideObj = static_cast(objMgr.GetLoadedObject(ObjectType::Ride, item.EntryIndex)); + const auto* rideObj = objMgr.GetLoadedObject(item.EntryIndex); const auto& rideEntry = rideObj->GetEntry(); RideNaming rideNaming = GetRideNaming(item.Type, rideEntry); auto ft = Formatter(); diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index a8d1b8363cd1..90038c6eede2 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -2113,7 +2113,7 @@ namespace OpenRCT2::Ui::Windows for (ObjectEntryIndex i = 0; i < kMaxStationObjects; i++) { - auto stationObj = static_cast(objManager.GetLoadedObject(ObjectType::Station, i)); + auto stationObj = objManager.GetLoadedObject(i); if (stationObj != nullptr) { auto name = stationObj->NameStringId; @@ -5055,7 +5055,7 @@ namespace OpenRCT2::Ui::Windows static std::string GetMusicString(ObjectEntryIndex musicObjectIndex) { auto& objManager = GetContext()->GetObjectManager(); - auto musicObj = static_cast(objManager.GetLoadedObject(ObjectType::Music, musicObjectIndex)); + auto musicObj = objManager.GetLoadedObject(musicObjectIndex); return LanguageGetString(musicObj->NameStringId); } @@ -5080,7 +5080,7 @@ namespace OpenRCT2::Ui::Windows auto& objManager = GetContext()->GetObjectManager(); for (ObjectEntryIndex i = 0; i < kMaxMusicObjects; i++) { - auto musicObj = static_cast(objManager.GetLoadedObject(ObjectType::Music, i)); + auto musicObj = objManager.GetLoadedObject(i); if (musicObj != nullptr) { // Hide custom music if the WAV file does not exist @@ -5119,7 +5119,7 @@ namespace OpenRCT2::Ui::Windows auto numItems = musicOrder.size(); for (size_t i = 0; i < numItems; i++) { - auto musicObj = static_cast(objManager.GetLoadedObject(ObjectType::Music, musicOrder[i])); + auto musicObj = objManager.GetLoadedObject(musicOrder[i]); gDropdownItems[i].Format = STR_DROPDOWN_MENU_LABEL; gDropdownItems[i].Args = musicObj->NameStringId; } diff --git a/src/openrct2/actions/SurfaceSetStyleAction.cpp b/src/openrct2/actions/SurfaceSetStyleAction.cpp index ac39d49afae3..950f291521a9 100644 --- a/src/openrct2/actions/SurfaceSetStyleAction.cpp +++ b/src/openrct2/actions/SurfaceSetStyleAction.cpp @@ -67,7 +67,7 @@ GameActions::Result SurfaceSetStyleAction::Query() const if (_edgeStyle != OBJECT_ENTRY_INDEX_NULL) { - const auto edgeObj = static_cast(objManager.GetLoadedObject(ObjectType::TerrainEdge, _edgeStyle)); + const auto edgeObj = objManager.GetLoadedObject(_edgeStyle); if (edgeObj == nullptr) { diff --git a/src/openrct2/localisation/Formatting.cpp b/src/openrct2/localisation/Formatting.cpp index fd66a30c8d84..24df9fe32fff 100644 --- a/src/openrct2/localisation/Formatting.cpp +++ b/src/openrct2/localisation/Formatting.cpp @@ -292,7 +292,7 @@ namespace OpenRCT2 if (IsRealNameStringId(id)) { auto& objManager = GetContext()->GetObjectManager(); - auto* peepNamesObj = static_cast(objManager.GetLoadedObject(ObjectType::PeepNames, 0)); + auto* peepNamesObj = objManager.GetLoadedObject(0); if (peepNamesObj != nullptr) { auto realNameIndex = id - kRealNameStart; diff --git a/src/openrct2/object/AudioObject.h b/src/openrct2/object/AudioObject.h index edd9dcee36ce..32c7aef5ecfa 100644 --- a/src/openrct2/object/AudioObject.h +++ b/src/openrct2/object/AudioObject.h @@ -23,6 +23,8 @@ class AudioObject final : public Object AudioSampleTable _loadedSampleTable; public: + static constexpr ObjectType objectType = ObjectType::Audio; + void ReadJson(IReadObjectContext* context, json_t& root) override; void Load() override; void Unload() override; diff --git a/src/openrct2/object/BannerObject.h b/src/openrct2/object/BannerObject.h index 08df37497f2d..18c077a987f8 100644 --- a/src/openrct2/object/BannerObject.h +++ b/src/openrct2/object/BannerObject.h @@ -19,6 +19,8 @@ class BannerObject final : public SceneryObject BannerSceneryEntry _legacyType = {}; public: + static constexpr ObjectType objectType = ObjectType::Banners; + void* GetLegacyData() override { return &_legacyType; diff --git a/src/openrct2/object/EntranceObject.h b/src/openrct2/object/EntranceObject.h index 0abce30b8fba..ce5fb15f28c3 100644 --- a/src/openrct2/object/EntranceObject.h +++ b/src/openrct2/object/EntranceObject.h @@ -20,6 +20,8 @@ class EntranceObject final : public Object EntranceEntry _legacyType = {}; public: + static constexpr ObjectType objectType = ObjectType::ParkEntrance; + void* GetLegacyData() override { return &_legacyType; diff --git a/src/openrct2/object/FootpathObject.h b/src/openrct2/object/FootpathObject.h index b6aba5f6982a..cce65563fd30 100644 --- a/src/openrct2/object/FootpathObject.h +++ b/src/openrct2/object/FootpathObject.h @@ -22,6 +22,8 @@ class FootpathObject final : public Object PathRailingsDescriptor _pathRailingsDescriptor = {}; public: + static constexpr ObjectType objectType = ObjectType::Paths; + void* GetLegacyData() override { return &_legacyType; diff --git a/src/openrct2/object/FootpathRailingsObject.h b/src/openrct2/object/FootpathRailingsObject.h index 961d07c90ebb..028534f40457 100644 --- a/src/openrct2/object/FootpathRailingsObject.h +++ b/src/openrct2/object/FootpathRailingsObject.h @@ -26,6 +26,8 @@ class FootpathRailingsObject final : public Object PathRailingsDescriptor _descriptor = {}; public: + static constexpr ObjectType objectType = ObjectType::FootpathRailings; + void ReadJson(IReadObjectContext* context, json_t& root) override; void Load() override; void Unload() override; diff --git a/src/openrct2/object/FootpathSurfaceObject.h b/src/openrct2/object/FootpathSurfaceObject.h index 782b930d2394..08aea17fb694 100644 --- a/src/openrct2/object/FootpathSurfaceObject.h +++ b/src/openrct2/object/FootpathSurfaceObject.h @@ -22,6 +22,8 @@ class FootpathSurfaceObject final : public Object PathSurfaceDescriptor _descriptor = {}; public: + static constexpr ObjectType objectType = ObjectType::FootpathSurface; + void ReadJson(IReadObjectContext* context, json_t& root) override; void Load() override; void Unload() override; diff --git a/src/openrct2/object/LargeSceneryObject.h b/src/openrct2/object/LargeSceneryObject.h index bba6e815de44..f7174fc1ac63 100644 --- a/src/openrct2/object/LargeSceneryObject.h +++ b/src/openrct2/object/LargeSceneryObject.h @@ -24,6 +24,8 @@ class LargeSceneryObject final : public SceneryObject std::unique_ptr _3dFont; public: + static constexpr ObjectType objectType = ObjectType::LargeScenery; + void* GetLegacyData() override { return &_legacyType; diff --git a/src/openrct2/object/MusicObject.h b/src/openrct2/object/MusicObject.h index e71a81600e56..274353736c35 100644 --- a/src/openrct2/object/MusicObject.h +++ b/src/openrct2/object/MusicObject.h @@ -53,6 +53,8 @@ class MusicObject final : public Object uint32_t _previewImageId{}; public: + static constexpr ObjectType objectType = ObjectType::Music; + StringId NameStringId{}; void ReadJson(IReadObjectContext* context, json_t& root) override; diff --git a/src/openrct2/object/ObjectManager.h b/src/openrct2/object/ObjectManager.h index 64c2eda91874..98e0fb301e88 100644 --- a/src/openrct2/object/ObjectManager.h +++ b/src/openrct2/object/ObjectManager.h @@ -26,6 +26,10 @@ struct IObjectManager } virtual Object* GetLoadedObject(ObjectType objectType, size_t index) = 0; + template TClass* GetLoadedObject(size_t index) + { + return static_cast(GetLoadedObject(TClass::objectType, index)); + } virtual Object* GetLoadedObject(const ObjectEntryDescriptor& entry) = 0; virtual ObjectEntryIndex GetLoadedObjectEntryIndex(std::string_view identifier) = 0; virtual ObjectEntryIndex GetLoadedObjectEntryIndex(const ObjectEntryDescriptor& descriptor) = 0; diff --git a/src/openrct2/object/PathAdditionObject.h b/src/openrct2/object/PathAdditionObject.h index bb24cf25ecc1..505cdc08f8de 100644 --- a/src/openrct2/object/PathAdditionObject.h +++ b/src/openrct2/object/PathAdditionObject.h @@ -18,6 +18,8 @@ class PathAdditionObject final : public SceneryObject PathAdditionEntry _legacyType = {}; public: + static constexpr ObjectType objectType = ObjectType::PathAdditions; + void* GetLegacyData() override { return &_legacyType; diff --git a/src/openrct2/object/PeepNamesObject.h b/src/openrct2/object/PeepNamesObject.h index fc3fa120b152..919708c113f2 100644 --- a/src/openrct2/object/PeepNamesObject.h +++ b/src/openrct2/object/PeepNamesObject.h @@ -22,6 +22,8 @@ class PeepNamesObject final : public Object std::vector _surnames; public: + static constexpr ObjectType objectType = ObjectType::PeepNames; + void ReadJson(IReadObjectContext* context, json_t& root) override; void Load() override; void Unload() override; diff --git a/src/openrct2/object/RideObject.h b/src/openrct2/object/RideObject.h index bd3cea4dad03..110dc3fb0740 100644 --- a/src/openrct2/object/RideObject.h +++ b/src/openrct2/object/RideObject.h @@ -26,6 +26,8 @@ class RideObject final : public Object std::vector> _peepLoadingWaypoints[OpenRCT2::RCT2::ObjectLimits::MaxCarTypesPerRideEntry]; public: + static constexpr ObjectType objectType = ObjectType::Ride; + void* GetLegacyData() override { return &_legacyType; diff --git a/src/openrct2/object/SceneryGroupObject.h b/src/openrct2/object/SceneryGroupObject.h index a07c86c9be5e..91c270043e52 100644 --- a/src/openrct2/object/SceneryGroupObject.h +++ b/src/openrct2/object/SceneryGroupObject.h @@ -25,6 +25,8 @@ class SceneryGroupObject final : public Object std::vector _items; public: + static constexpr ObjectType objectType = ObjectType::SceneryGroup; + void* GetLegacyData() override { return &_legacyType; diff --git a/src/openrct2/object/SmallSceneryObject.h b/src/openrct2/object/SmallSceneryObject.h index fe2051bd18c5..906fa776a168 100644 --- a/src/openrct2/object/SmallSceneryObject.h +++ b/src/openrct2/object/SmallSceneryObject.h @@ -22,6 +22,8 @@ class SmallSceneryObject final : public SceneryObject std::vector _frameOffsets; public: + static constexpr ObjectType objectType = ObjectType::SmallScenery; + void* GetLegacyData() override { return &_legacyType; diff --git a/src/openrct2/object/StationObject.h b/src/openrct2/object/StationObject.h index 372204e18d62..ed119fd05f07 100644 --- a/src/openrct2/object/StationObject.h +++ b/src/openrct2/object/StationObject.h @@ -24,6 +24,8 @@ namespace OpenRCT2::STATION_OBJECT_FLAGS class StationObject final : public Object { public: + static constexpr ObjectType objectType = ObjectType::Station; + StringId NameStringId{}; ImageIndex BaseImageId = ImageIndexUndefined; ImageIndex ShelterImageId = ImageIndexUndefined; diff --git a/src/openrct2/object/TerrainEdgeObject.h b/src/openrct2/object/TerrainEdgeObject.h index 1eab9695f6c6..113b3464b236 100644 --- a/src/openrct2/object/TerrainEdgeObject.h +++ b/src/openrct2/object/TerrainEdgeObject.h @@ -15,6 +15,8 @@ class TerrainEdgeObject final : public Object { private: public: + static constexpr ObjectType objectType = ObjectType::TerrainEdge; + StringId NameStringId{}; uint32_t IconImageId{}; uint32_t BaseImageId{}; diff --git a/src/openrct2/object/TerrainSurfaceObject.h b/src/openrct2/object/TerrainSurfaceObject.h index 18d78e1d8f70..aebf3f96924a 100644 --- a/src/openrct2/object/TerrainSurfaceObject.h +++ b/src/openrct2/object/TerrainSurfaceObject.h @@ -35,6 +35,8 @@ class TerrainSurfaceObject final : public Object static constexpr auto kNumImagesInEntry = 19; public: + static constexpr ObjectType objectType = ObjectType::TerrainSurface; + static constexpr uint8_t kNoValue = 0xFF; StringId NameStringId{}; uint32_t IconImageId{}; diff --git a/src/openrct2/object/WallObject.h b/src/openrct2/object/WallObject.h index 6f90f14ad4c8..8b85548427e9 100644 --- a/src/openrct2/object/WallObject.h +++ b/src/openrct2/object/WallObject.h @@ -18,6 +18,8 @@ class WallObject final : public SceneryObject WallSceneryEntry _legacyType = {}; public: + static constexpr ObjectType objectType = ObjectType::Walls; + void* GetLegacyData() override { return &_legacyType; diff --git a/src/openrct2/object/WaterObject.h b/src/openrct2/object/WaterObject.h index ff7be845bdcb..096261f9d2eb 100644 --- a/src/openrct2/object/WaterObject.h +++ b/src/openrct2/object/WaterObject.h @@ -20,6 +20,8 @@ class WaterObject final : public Object WaterObjectEntry _legacyType = {}; public: + static constexpr ObjectType objectType = ObjectType::Water; + void* GetLegacyData() override { return &_legacyType; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 1275005c85d3..a239f4b4c28e 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -1981,7 +1981,7 @@ void DefaultMusicUpdate(Ride& ride) if (ride.music_tune_id == TUNE_ID_NULL) { auto& objManager = GetContext()->GetObjectManager(); - auto musicObj = static_cast(objManager.GetLoadedObject(ObjectType::Music, ride.music)); + auto musicObj = objManager.GetLoadedObject(ride.music); if (musicObj != nullptr) { auto numTracks = musicObj->GetTrackCount(); @@ -5543,13 +5543,13 @@ int32_t RideGetEntryIndex(int32_t rideType, int32_t rideSubType) const StationObject* Ride::GetStationObject() const { auto& objManager = GetContext()->GetObjectManager(); - return static_cast(objManager.GetLoadedObject(ObjectType::Station, entrance_style)); + return objManager.GetLoadedObject(entrance_style); } const MusicObject* Ride::GetMusicObject() const { auto& objManager = GetContext()->GetObjectManager(); - return static_cast(objManager.GetLoadedObject(ObjectType::Music, music)); + return objManager.GetLoadedObject(music); } // Normally, a station has at most one entrance and one exit, which are at the same height diff --git a/src/openrct2/ride/RideAudio.cpp b/src/openrct2/ride/RideAudio.cpp index e07610a1f218..a8f73ef962b1 100644 --- a/src/openrct2/ride/RideAudio.cpp +++ b/src/openrct2/ride/RideAudio.cpp @@ -170,7 +170,7 @@ namespace OpenRCT2::RideAudio { auto& objManager = GetContext()->GetObjectManager(); auto ride = GetRide(instance.RideId); - auto musicObj = static_cast(objManager.GetLoadedObject(ObjectType::Music, ride->music)); + auto musicObj = objManager.GetLoadedObject(ride->music); if (musicObj != nullptr) { auto shouldLoop = musicObj->GetTrackCount() == 1; @@ -276,7 +276,7 @@ namespace OpenRCT2::RideAudio std::pair RideMusicGetTrackOffsetLength_Default(const Ride& ride) { auto& objManager = GetContext()->GetObjectManager(); - auto musicObj = static_cast(objManager.GetLoadedObject(ObjectType::Music, ride.music)); + auto musicObj = objManager.GetLoadedObject(ride.music); if (musicObj != nullptr) { auto numTracks = musicObj->GetTrackCount(); diff --git a/src/openrct2/scripting/bindings/object/ScObject.hpp b/src/openrct2/scripting/bindings/object/ScObject.hpp index a7e09d08e573..d27095f051f4 100644 --- a/src/openrct2/scripting/bindings/object/ScObject.hpp +++ b/src/openrct2/scripting/bindings/object/ScObject.hpp @@ -491,7 +491,7 @@ namespace OpenRCT2::Scripting const RideObject* GetObject() const { auto& objManager = GetContext()->GetObjectManager(); - return static_cast(objManager.GetLoadedObject(_objectType, _objectIndex)); + return objManager.GetLoadedObject(_objectIndex); } const CarEntry* GetEntry() const diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 771050cb80ea..aca0df9433cf 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -1862,7 +1862,7 @@ static bool FootpathIsLegacyPathEntryOkay(ObjectEntryIndex index) { bool showEditorPaths = ((gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || GetGameState().Cheats.SandboxMode); auto& objManager = OpenRCT2::GetContext()->GetObjectManager(); - auto footpathObj = static_cast(objManager.GetLoadedObject(ObjectType::Paths, index)); + auto footpathObj = objManager.GetLoadedObject(index); if (footpathObj != nullptr) { auto pathEntry = reinterpret_cast(footpathObj->GetLegacyData()); diff --git a/src/openrct2/world/tile_element/EntranceElement.cpp b/src/openrct2/world/tile_element/EntranceElement.cpp index 385b26f0a483..60ffecc6c715 100644 --- a/src/openrct2/world/tile_element/EntranceElement.cpp +++ b/src/openrct2/world/tile_element/EntranceElement.cpp @@ -80,7 +80,7 @@ ObjectEntryIndex EntranceElement::GetLegacyPathEntryIndex() const const FootpathObject* EntranceElement::GetLegacyPathEntry() const { auto& objMgr = OpenRCT2::GetContext()->GetObjectManager(); - return static_cast(objMgr.GetLoadedObject(ObjectType::Paths, GetLegacyPathEntryIndex())); + return objMgr.GetLoadedObject(GetLegacyPathEntryIndex()); } void EntranceElement::SetLegacyPathEntryIndex(ObjectEntryIndex newPathType) @@ -100,7 +100,7 @@ ObjectEntryIndex EntranceElement::GetSurfaceEntryIndex() const const FootpathSurfaceObject* EntranceElement::GetSurfaceEntry() const { auto& objMgr = OpenRCT2::GetContext()->GetObjectManager(); - return static_cast(objMgr.GetLoadedObject(ObjectType::FootpathSurface, GetSurfaceEntryIndex())); + return objMgr.GetLoadedObject(GetSurfaceEntryIndex()); } void EntranceElement::SetSurfaceEntryIndex(ObjectEntryIndex newIndex) diff --git a/src/openrct2/world/tile_element/PathElement.cpp b/src/openrct2/world/tile_element/PathElement.cpp index 36ba91b3059d..1c8b058b00e2 100644 --- a/src/openrct2/world/tile_element/PathElement.cpp +++ b/src/openrct2/world/tile_element/PathElement.cpp @@ -254,7 +254,7 @@ ObjectEntryIndex PathElement::GetSurfaceEntryIndex() const const FootpathSurfaceObject* PathElement::GetSurfaceEntry() const { auto& objMgr = OpenRCT2::GetContext()->GetObjectManager(); - return static_cast(objMgr.GetLoadedObject(ObjectType::FootpathSurface, GetSurfaceEntryIndex())); + return objMgr.GetLoadedObject(GetSurfaceEntryIndex()); } void PathElement::SetSurfaceEntryIndex(ObjectEntryIndex newIndex) @@ -274,7 +274,7 @@ ObjectEntryIndex PathElement::GetRailingsEntryIndex() const const FootpathRailingsObject* PathElement::GetRailingsEntry() const { auto& objMgr = OpenRCT2::GetContext()->GetObjectManager(); - return static_cast(objMgr.GetLoadedObject(ObjectType::FootpathRailings, GetRailingsEntryIndex())); + return objMgr.GetLoadedObject(GetRailingsEntryIndex()); } void PathElement::SetRailingsEntryIndex(ObjectEntryIndex newEntryIndex) diff --git a/src/openrct2/world/tile_element/SurfaceElement.cpp b/src/openrct2/world/tile_element/SurfaceElement.cpp index aba3d1255369..1d5711ff5a31 100644 --- a/src/openrct2/world/tile_element/SurfaceElement.cpp +++ b/src/openrct2/world/tile_element/SurfaceElement.cpp @@ -26,7 +26,7 @@ ObjectEntryIndex SurfaceElement::GetSurfaceObjectIndex() const TerrainSurfaceObject* SurfaceElement::GetSurfaceObject() const { auto& objManager = OpenRCT2::GetContext()->GetObjectManager(); - return static_cast(objManager.GetLoadedObject(ObjectType::TerrainSurface, GetSurfaceObjectIndex())); + return objManager.GetLoadedObject(GetSurfaceObjectIndex()); } ObjectEntryIndex SurfaceElement::GetEdgeObjectIndex() const @@ -37,7 +37,7 @@ ObjectEntryIndex SurfaceElement::GetEdgeObjectIndex() const TerrainEdgeObject* SurfaceElement::GetEdgeObject() const { auto& objManager = OpenRCT2::GetContext()->GetObjectManager(); - return static_cast(objManager.GetLoadedObject(ObjectType::TerrainEdge, GetEdgeObjectIndex())); + return objManager.GetLoadedObject(GetEdgeObjectIndex()); } void SurfaceElement::SetSurfaceObjectIndex(ObjectEntryIndex newStyle)