diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index ce248e84ed..a9b6a9c1f3 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -1596,7 +1596,7 @@ static int32_t cc_mp_desync(InteractiveConsole& console, const arguments_t& argv if (peeps.size() > 1) peep = peeps[util_rand() % peeps.size() - 1]; peep->TshirtColour = util_rand() & 0xFF; - invalidate_sprite_0(peep); + peep->Invalidate0(); } break; } diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 9c60ba6a28..f7a494f216 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -340,7 +340,7 @@ Staff* Peep::AsStaff() void Peep::Invalidate() { - invalidate_sprite_2(this); + Invalidate2(); } void Peep::MoveTo(const CoordsXYZ& newLocation) diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 892299c15b..1961158c29 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1405,7 +1405,7 @@ private: dst->sprite_height_positive = spriteBounds[dst->ActionSpriteType].sprite_height_positive; dst->MoveTo({ src->x, src->y, src->z }); - invalidate_sprite_2(dst); + dst->Invalidate2(); dst->sprite_direction = src->sprite_direction; @@ -1646,7 +1646,7 @@ private: litter->sprite_height_negative = srcLitter->sprite_height_negative; litter->MoveTo({ srcLitter->x, srcLitter->y, srcLitter->z }); - invalidate_sprite_2(litter); + litter->Invalidate2(); } } } @@ -1698,7 +1698,7 @@ private: } dst->MoveTo({ src->x, src->y, src->z }); - invalidate_sprite_2(dst); + dst->Invalidate2(); } } } diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index add63c14b9..64c790c952 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -813,7 +813,7 @@ Vehicle* try_get_vehicle(uint16_t spriteIndex) void Vehicle::Invalidate() { - invalidate_sprite_2(this); + Invalidate2(); } namespace diff --git a/src/openrct2/scripting/ScEntity.hpp b/src/openrct2/scripting/ScEntity.hpp index 6e76441da7..daecef03c7 100644 --- a/src/openrct2/scripting/ScEntity.hpp +++ b/src/openrct2/scripting/ScEntity.hpp @@ -83,9 +83,9 @@ namespace OpenRCT2::Scripting auto entity = GetEntity(); if (entity != nullptr) { - invalidate_sprite_2(entity); + entity->Invalidate2(); entity->MoveTo({ value, entity->y, entity->z }); - invalidate_sprite_2(entity); + entity->Invalidate2(); } } @@ -101,9 +101,9 @@ namespace OpenRCT2::Scripting auto entity = GetEntity(); if (entity != nullptr) { - invalidate_sprite_2(entity); + entity->Invalidate2(); entity->MoveTo({ entity->x, value, entity->z }); - invalidate_sprite_2(entity); + entity->Invalidate2(); } } @@ -119,9 +119,9 @@ namespace OpenRCT2::Scripting auto entity = GetEntity(); if (entity != nullptr) { - invalidate_sprite_2(entity); + entity->Invalidate2(); entity->MoveTo({ entity->x, entity->y, value }); - invalidate_sprite_2(entity); + entity->Invalidate2(); } } @@ -131,7 +131,7 @@ namespace OpenRCT2::Scripting auto entity = GetEntity(); if (entity != nullptr) { - invalidate_sprite_2(entity); + entity->Invalidate2(); switch (entity->sprite_identifier) { case SPRITE_IDENTIFIER_VEHICLE: diff --git a/src/openrct2/world/Balloon.cpp b/src/openrct2/world/Balloon.cpp index c4e708242b..86b618e160 100644 --- a/src/openrct2/world/Balloon.cpp +++ b/src/openrct2/world/Balloon.cpp @@ -21,7 +21,7 @@ template<> bool SpriteBase::Is() const void Balloon::Update() { - invalidate_sprite_2(this); + Invalidate2(); if (popped == 1) { frame++; diff --git a/src/openrct2/world/Duck.cpp b/src/openrct2/world/Duck.cpp index 264d4f4feb..2be9f11739 100644 --- a/src/openrct2/world/Duck.cpp +++ b/src/openrct2/world/Duck.cpp @@ -81,7 +81,7 @@ template<> bool SpriteBase::Is() const void Duck::Invalidate() { - invalidate_sprite_1(this); + Invalidate1(); } bool Duck::IsFlying() @@ -371,7 +371,7 @@ void duck_remove_all() nextSpriteIndex = sprite->next; if (sprite->type == SPRITE_MISC_DUCK) { - invalidate_sprite_1(sprite); + sprite->Invalidate1(); sprite_remove(sprite); } } diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 7a4414094a..8cd13e63e5 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -400,7 +400,7 @@ void footpath_remove_litter(const CoordsXYZ& footpathPos) int32_t distanceZ = abs(sprite->z - footpathPos.z); if (distanceZ <= 32) { - invalidate_sprite_0(sprite); + sprite->Invalidate0(); sprite_remove(sprite); } } diff --git a/src/openrct2/world/Fountain.cpp b/src/openrct2/world/Fountain.cpp index 03b34fbb7d..11bd5f38ea 100644 --- a/src/openrct2/world/Fountain.cpp +++ b/src/openrct2/world/Fountain.cpp @@ -158,7 +158,7 @@ void JumpingFountain::Update() return; } - invalidate_sprite_0(this); + Invalidate0(); frame++; switch (type) diff --git a/src/openrct2/world/MapAnimation.cpp b/src/openrct2/world/MapAnimation.cpp index 9137db0da1..3f00f93747 100644 --- a/src/openrct2/world/MapAnimation.cpp +++ b/src/openrct2/world/MapAnimation.cpp @@ -217,7 +217,7 @@ static bool map_animation_invalidate_small_scenery(const CoordsXYZ& loc) peep->ActionFrame = 0; peep->ActionSpriteImageOffset = 0; peep->UpdateCurrentActionSpriteType(); - invalidate_sprite_1(peep); + peep->Invalidate1(); break; } } diff --git a/src/openrct2/world/MoneyEffect.cpp b/src/openrct2/world/MoneyEffect.cpp index 0125caac6c..0f723d6b52 100644 --- a/src/openrct2/world/MoneyEffect.cpp +++ b/src/openrct2/world/MoneyEffect.cpp @@ -98,7 +98,7 @@ void MoneyEffect::Create(money32 value, CoordsXYZ loc) */ void MoneyEffect::Update() { - invalidate_sprite_2(this); + Invalidate2(); Wiggle++; if (Wiggle >= 22) { diff --git a/src/openrct2/world/Particle.cpp b/src/openrct2/world/Particle.cpp index b7735dda1a..b13693552c 100644 --- a/src/openrct2/world/Particle.cpp +++ b/src/openrct2/world/Particle.cpp @@ -59,7 +59,7 @@ void crashed_vehicle_particle_create(rct_vehicle_colour colours, int32_t x, int3 */ void crashed_vehicle_particle_update(VehicleCrashParticle* particle) { - invalidate_sprite_0(particle); + particle->Invalidate0(); particle->time_to_live--; if (particle->time_to_live == 0) { @@ -108,7 +108,7 @@ void crashed_vehicle_particle_update(VehicleCrashParticle* particle) z = landZ; } particle->MoveTo({ x, y, z }); - invalidate_sprite_0(particle); + particle->Invalidate0(); particle->frame += 85; if (particle->frame >= 3072) @@ -142,7 +142,7 @@ void crash_splash_create(int32_t x, int32_t y, int32_t z) */ void crash_splash_update(CrashSplashParticle* splash) { - invalidate_sprite_2(splash); + splash->Invalidate2(); splash->frame += 85; if (splash->frame >= 7168) { diff --git a/src/openrct2/world/Sprite.cpp b/src/openrct2/world/Sprite.cpp index 1aabe18bf0..cc7bef4857 100644 --- a/src/openrct2/world/Sprite.cpp +++ b/src/openrct2/world/Sprite.cpp @@ -135,29 +135,27 @@ static void invalidate_sprite_max_zoom(SpriteBase* sprite, int32_t maxZoom) * Invalidate the sprite if at closest zoom. * rct2: 0x006EC60B */ -void invalidate_sprite_0(SpriteBase* sprite) +void SpriteBase::Invalidate0() { - invalidate_sprite_max_zoom(sprite, 0); + invalidate_sprite_max_zoom(this, 0); } /** * Invalidate sprite if at closest zoom or next zoom up from closest. * rct2: 0x006EC53F */ -void invalidate_sprite_1(SpriteBase* sprite) +void SpriteBase::Invalidate1() { - invalidate_sprite_max_zoom(sprite, 1); + invalidate_sprite_max_zoom(this, 1); } /** * Invalidate sprite if not at furthest zoom. * rct2: 0x006EC473 - * - * @param sprite (esi) */ -void invalidate_sprite_2(SpriteBase* sprite) +void SpriteBase::Invalidate2() { - invalidate_sprite_max_zoom(sprite, 2); + invalidate_sprite_max_zoom(this, 2); } /** @@ -502,7 +500,7 @@ static void move_sprite_to_list(SpriteBase* sprite, SPRITE_LIST newListIndex) */ static void sprite_steam_particle_update(SteamParticle* steam) { - invalidate_sprite_2(steam); + steam->Invalidate2(); // Move up 1 z every 3 ticks (Starts after 4 ticks) steam->time_to_move++; @@ -543,7 +541,7 @@ void sprite_misc_explosion_cloud_create(int32_t x, int32_t y, int32_t z) */ static void sprite_misc_explosion_cloud_update(rct_sprite* sprite) { - invalidate_sprite_2(&sprite->generic); + sprite->generic.Invalidate2(); sprite->generic.frame += 128; if (sprite->generic.frame >= (36 * 128)) { @@ -576,7 +574,7 @@ void sprite_misc_explosion_flare_create(int32_t x, int32_t y, int32_t z) */ static void sprite_misc_explosion_flare_update(rct_sprite* sprite) { - invalidate_sprite_2(&sprite->generic); + sprite->generic.Invalidate2(); sprite->generic.frame += 64; if (sprite->generic.frame >= (124 * 64)) { @@ -822,7 +820,7 @@ void litter_create(int32_t x, int32_t y, int32_t z, int32_t direction, int32_t t if (newestLitter != nullptr) { - invalidate_sprite_0(newestLitter); + newestLitter->Invalidate0(); sprite_remove(newestLitter); } } @@ -838,7 +836,7 @@ void litter_create(int32_t x, int32_t y, int32_t z, int32_t direction, int32_t t litter->sprite_identifier = SPRITE_IDENTIFIER_LITTER; litter->type = type; litter->MoveTo({ x, y, z }); - invalidate_sprite_0(litter); + litter->Invalidate0(); litter->creationTick = gScenarioTicks; } @@ -861,7 +859,7 @@ void litter_remove_at(int32_t x, int32_t y, int32_t z) { if (abs(litter->x - x) <= 8 && abs(litter->y - y) <= 8) { - invalidate_sprite_0(litter); + litter->Invalidate0(); sprite_remove(litter); } } @@ -960,7 +958,7 @@ void sprite_position_tween_all(float alpha) sprite_set_coordinates( std::round(posB.x * alpha + posA.x * inv), std::round(posB.y * alpha + posA.y * inv), std::round(posB.z * alpha + posA.z * inv), &sprite->generic); - invalidate_sprite_2(&sprite->generic); + sprite->generic.Invalidate2(); } } } @@ -975,7 +973,7 @@ void sprite_position_tween_restore() rct_sprite* sprite = get_sprite(i); if (sprite_should_tween(sprite)) { - invalidate_sprite_2(&sprite->generic); + sprite->generic.Invalidate2(); auto pos = _spritelocations2[i]; sprite_set_coordinates(pos.x, pos.y, pos.z, &sprite->generic); diff --git a/src/openrct2/world/Sprite.h b/src/openrct2/world/Sprite.h index 5d1bd83a86..337bf92ae9 100644 --- a/src/openrct2/world/Sprite.h +++ b/src/openrct2/world/Sprite.h @@ -209,9 +209,6 @@ void reset_sprite_spatial_index(); void sprite_clear_all_unused(); void sprite_misc_update_all(); void sprite_set_coordinates(int16_t x, int16_t y, int16_t z, SpriteBase* sprite); -void invalidate_sprite_0(SpriteBase* sprite); -void invalidate_sprite_1(SpriteBase* sprite); -void invalidate_sprite_2(SpriteBase* sprite); void sprite_remove(SpriteBase* sprite); void litter_create(int32_t x, int32_t y, int32_t z, int32_t direction, int32_t type); void litter_remove_at(int32_t x, int32_t y, int32_t z); diff --git a/src/openrct2/world/SpriteBase.h b/src/openrct2/world/SpriteBase.h index ced5d89fbf..be763792a4 100644 --- a/src/openrct2/world/SpriteBase.h +++ b/src/openrct2/world/SpriteBase.h @@ -33,6 +33,9 @@ struct SpriteBase uint8_t sprite_direction; void MoveTo(const CoordsXYZ& newLocation); + void Invalidate0(); + void Invalidate1(); + void Invalidate2(); template bool Is() const; template T* As() {