diff --git a/src/openrct2-ui/windows/GameBottomToolbar.cpp b/src/openrct2-ui/windows/GameBottomToolbar.cpp index 718b315dd1..a1d8d0864e 100644 --- a/src/openrct2-ui/windows/GameBottomToolbar.cpp +++ b/src/openrct2-ui/windows/GameBottomToolbar.cpp @@ -612,7 +612,7 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo* dpi, rc if (sprite == nullptr) break; - auto peep = sprite->AsPeep(); + auto peep = sprite->generic.As(); if (peep == nullptr) return; diff --git a/src/openrct2-ui/windows/News.cpp b/src/openrct2-ui/windows/News.cpp index 6599443f27..929030a64c 100644 --- a/src/openrct2-ui/windows/News.cpp +++ b/src/openrct2-ui/windows/News.cpp @@ -327,7 +327,7 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32 if (sprite == nullptr) break; - auto peep = sprite->AsPeep(); + auto peep = sprite->generic.As(); if (peep == nullptr) break; diff --git a/src/openrct2/Editor.cpp b/src/openrct2/Editor.cpp index 2d060f9dee..2e7e6a2c82 100644 --- a/src/openrct2/Editor.cpp +++ b/src/openrct2/Editor.cpp @@ -309,7 +309,7 @@ namespace Editor // for (int32_t i = 0; i < MAX_SPRITES; i++) { - auto peep = get_sprite(i)->AsPeep(); + auto peep = get_sprite(i)->generic.As(); if (peep != nullptr) { peep->SetName({}); diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index 04711eeed8..9acc3d9307 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -1574,7 +1574,7 @@ static int32_t cc_mp_desync(InteractiveConsole& console, const arguments_t& argv if (sprite->generic.sprite_identifier == SPRITE_IDENTIFIER_NULL) continue; - auto peep = sprite->AsPeep(); + auto peep = sprite->generic.As(); if (peep != nullptr) peeps.push_back(peep); } diff --git a/src/openrct2/management/NewsItem.cpp b/src/openrct2/management/NewsItem.cpp index cd264c428c..2851d824e1 100644 --- a/src/openrct2/management/NewsItem.cpp +++ b/src/openrct2/management/NewsItem.cpp @@ -274,7 +274,7 @@ std::optional news_item_get_subject_location(int32_t type, int32_t su if (sprite == nullptr) break; - auto peep = sprite->AsPeep(); + auto peep = sprite->generic.As(); if (peep == nullptr) break; @@ -314,7 +314,7 @@ std::optional news_item_get_subject_location(int32_t type, int32_t su auto sprite = try_get_sprite(subject); if (sprite != nullptr) { - auto peep = sprite->AsPeep(); + auto peep = sprite->generic.As(); if (peep != nullptr) { subjectLoc = CoordsXYZ{ peep->x, peep->y, peep->z }; @@ -410,7 +410,7 @@ void news_item_open_subject(int32_t type, int32_t subject) auto sprite = try_get_sprite(subject); if (sprite != nullptr) { - auto peep = sprite->AsPeep(); + auto peep = sprite->generic.As(); if (peep != nullptr) { auto intent = Intent(WC_PEEP); diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index f46a5eef88..190676c6c8 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -328,16 +328,6 @@ template<> bool SpriteBase::Is() const return sprite_identifier == SPRITE_IDENTIFIER_PEEP; } -Peep* rct_sprite::AsPeep() -{ - Peep* result = nullptr; - if (generic.Is()) - { - return reinterpret_cast(this); - } - return result; -} - Guest* Peep::AsGuest() { return type == PEEP_TYPE_GUEST ? static_cast(this) : nullptr; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 1d6ab02f48..0bc178dd59 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -834,7 +834,7 @@ size_t Ride::FormatStatusTo(void* argsV) const auto sprite = get_sprite(race_winner); if (sprite != nullptr && sprite->generic.Is()) { - auto peep = sprite->AsPeep(); + auto peep = sprite->generic.As(); ft.Add(STR_RACE_WON_BY); peep->FormatNameTo(ft); } diff --git a/src/openrct2/scripting/ScEntity.hpp b/src/openrct2/scripting/ScEntity.hpp index 09f036a46e..d75a358c04 100644 --- a/src/openrct2/scripting/ScEntity.hpp +++ b/src/openrct2/scripting/ScEntity.hpp @@ -333,7 +333,7 @@ namespace OpenRCT2::Scripting protected: Peep* GetPeep() const { - return get_sprite(_id)->AsPeep(); + return get_sprite(_id)->generic.As(); } }; diff --git a/src/openrct2/world/Sprite.cpp b/src/openrct2/world/Sprite.cpp index 250bcab652..fa1a811abe 100644 --- a/src/openrct2/world/Sprite.cpp +++ b/src/openrct2/world/Sprite.cpp @@ -745,7 +745,7 @@ void sprite_set_coordinates(int16_t x, int16_t y, int16_t z, SpriteBase* sprite) */ void sprite_remove(SpriteBase* sprite) { - auto peep = (reinterpret_cast(sprite))->AsPeep(); + auto peep = sprite->As(); if (peep != nullptr) { peep->SetName({}); diff --git a/src/openrct2/world/Sprite.h b/src/openrct2/world/Sprite.h index bd2c97384f..5d1bd83a86 100644 --- a/src/openrct2/world/Sprite.h +++ b/src/openrct2/world/Sprite.h @@ -137,7 +137,6 @@ union rct_sprite CrashSplashParticle crash_splash; SteamParticle steam_particle; - Peep* AsPeep(); // Default constructor to prevent non trivial construction issues rct_sprite() : pad_00()