1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 03:23:15 +01:00

Remove AsPeep

This commit is contained in:
duncanspumpkin
2020-06-06 10:55:01 +01:00
parent 7ba795e96c
commit 5c48e5f0bb
10 changed files with 10 additions and 21 deletions

View File

@@ -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<Peep>();
if (peep == nullptr)
return;

View File

@@ -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<Peep>();
if (peep == nullptr)
break;

View File

@@ -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<Peep>();
if (peep != nullptr)
{
peep->SetName({});

View File

@@ -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<Peep>();
if (peep != nullptr)
peeps.push_back(peep);
}

View File

@@ -274,7 +274,7 @@ std::optional<CoordsXYZ> news_item_get_subject_location(int32_t type, int32_t su
if (sprite == nullptr)
break;
auto peep = sprite->AsPeep();
auto peep = sprite->generic.As<Peep>();
if (peep == nullptr)
break;
@@ -314,7 +314,7 @@ std::optional<CoordsXYZ> 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<Peep>();
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<Peep>();
if (peep != nullptr)
{
auto intent = Intent(WC_PEEP);

View File

@@ -328,16 +328,6 @@ template<> bool SpriteBase::Is<Peep>() const
return sprite_identifier == SPRITE_IDENTIFIER_PEEP;
}
Peep* rct_sprite::AsPeep()
{
Peep* result = nullptr;
if (generic.Is<Peep>())
{
return reinterpret_cast<Peep*>(this);
}
return result;
}
Guest* Peep::AsGuest()
{
return type == PEEP_TYPE_GUEST ? static_cast<Guest*>(this) : nullptr;

View File

@@ -834,7 +834,7 @@ size_t Ride::FormatStatusTo(void* argsV) const
auto sprite = get_sprite(race_winner);
if (sprite != nullptr && sprite->generic.Is<Peep>())
{
auto peep = sprite->AsPeep();
auto peep = sprite->generic.As<Peep>();
ft.Add<rct_string_id>(STR_RACE_WON_BY);
peep->FormatNameTo(ft);
}

View File

@@ -333,7 +333,7 @@ namespace OpenRCT2::Scripting
protected:
Peep* GetPeep() const
{
return get_sprite(_id)->AsPeep();
return get_sprite(_id)->generic.As<Peep>();
}
};

View File

@@ -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<rct_sprite*>(sprite))->AsPeep();
auto peep = sprite->As<Peep>();
if (peep != nullptr)
{
peep->SetName({});

View File

@@ -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()