1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-22 07:13:07 +01:00

Refactor sprite_remove

This commit is contained in:
duncanspumpkin
2020-01-19 16:12:29 +00:00
parent 65c6564165
commit a262f325ed
12 changed files with 29 additions and 29 deletions

View File

@@ -422,7 +422,7 @@ private:
{ {
litter = &(get_sprite(spriteIndex)->litter); litter = &(get_sprite(spriteIndex)->litter);
nextSpriteIndex = litter->next; nextSpriteIndex = litter->next;
sprite_remove((rct_sprite*)litter); sprite_remove(litter);
} }
tile_element_iterator it; tile_element_iterator it;

View File

@@ -154,7 +154,7 @@ private:
if (execute == false) if (execute == false)
{ {
// In query we just want to see if we can obtain a sprite slot. // In query we just want to see if we can obtain a sprite slot.
sprite_remove((rct_sprite*)newPeep); sprite_remove(newPeep);
} }
else else
{ {

View File

@@ -849,7 +849,7 @@ void peep_sprite_remove(Peep* peep)
news_item_disable_news(NEWS_ITEM_PEEP, peep->sprite_index); news_item_disable_news(NEWS_ITEM_PEEP, peep->sprite_index);
} }
sprite_remove((rct_sprite*)peep); sprite_remove(peep);
} }
/** /**

View File

@@ -1014,7 +1014,7 @@ static void ride_remove_cable_lift(Ride* ride)
{ {
Vehicle* vehicle = GET_VEHICLE(spriteIndex); Vehicle* vehicle = GET_VEHICLE(spriteIndex);
invalidate_sprite_2((rct_sprite*)vehicle); invalidate_sprite_2((rct_sprite*)vehicle);
sprite_remove((rct_sprite*)vehicle); sprite_remove(vehicle);
spriteIndex = vehicle->next_vehicle_on_train; spriteIndex = vehicle->next_vehicle_on_train;
} while (spriteIndex != SPRITE_INDEX_NULL); } while (spriteIndex != SPRITE_INDEX_NULL);
} }
@@ -1038,7 +1038,7 @@ static void ride_remove_vehicles(Ride* ride)
{ {
Vehicle* vehicle = GET_VEHICLE(spriteIndex); Vehicle* vehicle = GET_VEHICLE(spriteIndex);
invalidate_sprite_2((rct_sprite*)vehicle); invalidate_sprite_2((rct_sprite*)vehicle);
sprite_remove((rct_sprite*)vehicle); sprite_remove(vehicle);
spriteIndex = vehicle->next_vehicle_on_train; spriteIndex = vehicle->next_vehicle_on_train;
} }

View File

@@ -37,7 +37,7 @@ void Balloon::Update()
frame++; frame++;
if (frame >= 5) if (frame >= 5)
{ {
sprite_remove((rct_sprite*)this); sprite_remove(this);
} }
} }
else else

View File

@@ -97,7 +97,7 @@ void Duck::Invalidate()
void Duck::Remove() void Duck::Remove()
{ {
Invalidate(); Invalidate();
sprite_remove((rct_sprite*)this); sprite_remove(this);
} }
void Duck::MoveTo(const CoordsXYZ& destination) void Duck::MoveTo(const CoordsXYZ& destination)
@@ -382,7 +382,7 @@ void duck_remove_all()
if (sprite->type == SPRITE_MISC_DUCK) if (sprite->type == SPRITE_MISC_DUCK)
{ {
invalidate_sprite_1((rct_sprite*)sprite); invalidate_sprite_1((rct_sprite*)sprite);
sprite_remove((rct_sprite*)sprite); sprite_remove(sprite);
} }
} }
} }

View File

@@ -401,7 +401,7 @@ void footpath_remove_litter(const CoordsXYZ& footpathPos)
if (distanceZ <= 32) if (distanceZ <= 32)
{ {
invalidate_sprite_0((rct_sprite*)sprite); invalidate_sprite_0((rct_sprite*)sprite);
sprite_remove((rct_sprite*)sprite); sprite_remove(sprite);
} }
} }
spriteIndex = nextSpriteIndex; spriteIndex = nextSpriteIndex;

View File

@@ -187,7 +187,7 @@ void JumpingFountain::Update()
if (frame == 16) if (frame == 16)
{ {
sprite_remove(reinterpret_cast<rct_sprite*>(this)); sprite_remove(this);
} }
} }

View File

@@ -142,7 +142,7 @@ void MoneyEffect::Update()
return; return;
} }
sprite_remove((rct_sprite*)this); sprite_remove(this);
} }
std::pair<rct_string_id, money32> MoneyEffect::GetStringId() const std::pair<rct_string_id, money32> MoneyEffect::GetStringId() const

View File

@@ -54,7 +54,7 @@ void crashed_vehicle_particle_update(VehicleCrashParticle* particle)
particle->time_to_live--; particle->time_to_live--;
if (particle->time_to_live == 0) if (particle->time_to_live == 0)
{ {
sprite_remove((rct_sprite*)particle); sprite_remove(particle);
return; return;
} }
@@ -88,7 +88,7 @@ void crashed_vehicle_particle_update(VehicleCrashParticle* particle)
// Splash // Splash
audio_play_sound_at_location(SoundId::Water2, { particle->x, particle->y, waterZ }); audio_play_sound_at_location(SoundId::Water2, { particle->x, particle->y, waterZ });
crash_splash_create(particle->x, particle->y, waterZ); crash_splash_create(particle->x, particle->y, waterZ);
sprite_remove((rct_sprite*)particle); sprite_remove(particle);
return; return;
} }
@@ -137,6 +137,6 @@ void crash_splash_update(CrashSplashParticle* splash)
splash->frame += 85; splash->frame += 85;
if (splash->frame >= 7168) if (splash->frame >= 7168)
{ {
sprite_remove((rct_sprite*)splash); sprite_remove(splash);
} }
} }

View File

@@ -490,7 +490,7 @@ static void sprite_steam_particle_update(SteamParticle* steam)
steam->frame += 64; steam->frame += 64;
if (steam->frame >= (56 * 64)) if (steam->frame >= (56 * 64))
{ {
sprite_remove((rct_sprite*)steam); sprite_remove(steam);
} }
} }
@@ -523,7 +523,7 @@ static void sprite_misc_explosion_cloud_update(rct_sprite* sprite)
sprite->generic.frame += 128; sprite->generic.frame += 128;
if (sprite->generic.frame >= (36 * 128)) if (sprite->generic.frame >= (36 * 128))
{ {
sprite_remove(sprite); sprite_remove(&sprite->generic);
} }
} }
@@ -556,7 +556,7 @@ static void sprite_misc_explosion_flare_update(rct_sprite* sprite)
sprite->generic.frame += 64; sprite->generic.frame += 64;
if (sprite->generic.frame >= (124 * 64)) if (sprite->generic.frame >= (124 * 64))
{ {
sprite_remove(sprite); sprite_remove(&sprite->generic);
} }
} }
@@ -689,26 +689,26 @@ void sprite_set_coordinates(int16_t x, int16_t y, int16_t z, rct_sprite* sprite)
* *
* rct2: 0x0069EDB6 * rct2: 0x0069EDB6
*/ */
void sprite_remove(rct_sprite* sprite) void sprite_remove(SpriteBase* sprite)
{ {
auto peep = sprite->AsPeep(); auto peep = ((rct_sprite*)sprite)->AsPeep();
if (peep != nullptr) if (peep != nullptr)
{ {
peep->SetName({}); peep->SetName({});
} }
move_sprite_to_list(&sprite->generic, SPRITE_LIST_FREE); move_sprite_to_list(sprite, SPRITE_LIST_FREE);
sprite->generic.sprite_identifier = SPRITE_IDENTIFIER_NULL; sprite->sprite_identifier = SPRITE_IDENTIFIER_NULL;
_spriteFlashingList[sprite->generic.sprite_index] = false; _spriteFlashingList[sprite->sprite_index] = false;
size_t quadrantIndex = GetSpatialIndexOffset(sprite->generic.x, sprite->generic.y); size_t quadrantIndex = GetSpatialIndexOffset(sprite->x, sprite->y);
uint16_t* spriteIndex = &gSpriteSpatialIndex[quadrantIndex]; uint16_t* spriteIndex = &gSpriteSpatialIndex[quadrantIndex];
rct_sprite* quadrantSprite; SpriteBase* quadrantSprite;
while (*spriteIndex != SPRITE_INDEX_NULL && (quadrantSprite = get_sprite(*spriteIndex)) != sprite) while (*spriteIndex != SPRITE_INDEX_NULL && (quadrantSprite = &get_sprite(*spriteIndex)->generic) != sprite)
{ {
spriteIndex = &quadrantSprite->generic.next_in_quadrant; spriteIndex = &quadrantSprite->next_in_quadrant;
} }
*spriteIndex = sprite->generic.next_in_quadrant; *spriteIndex = sprite->next_in_quadrant;
} }
static bool litter_can_be_at(int32_t x, int32_t y, int32_t z) static bool litter_can_be_at(int32_t x, int32_t y, int32_t z)
@@ -769,7 +769,7 @@ void litter_create(int32_t x, int32_t y, int32_t z, int32_t direction, int32_t t
if (newestLitter != nullptr) if (newestLitter != nullptr)
{ {
invalidate_sprite_0((rct_sprite*)newestLitter); invalidate_sprite_0((rct_sprite*)newestLitter);
sprite_remove((rct_sprite*)newestLitter); sprite_remove(newestLitter);
} }
} }

View File

@@ -206,7 +206,7 @@ void sprite_set_coordinates(int16_t x, int16_t y, int16_t z, rct_sprite* sprite)
void invalidate_sprite_0(rct_sprite* sprite); void invalidate_sprite_0(rct_sprite* sprite);
void invalidate_sprite_1(rct_sprite* sprite); void invalidate_sprite_1(rct_sprite* sprite);
void invalidate_sprite_2(rct_sprite* sprite); void invalidate_sprite_2(rct_sprite* sprite);
void sprite_remove(rct_sprite* 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_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); void litter_remove_at(int32_t x, int32_t y, int32_t z);
void sprite_misc_explosion_cloud_create(int32_t x, int32_t y, int32_t z); void sprite_misc_explosion_cloud_create(int32_t x, int32_t y, int32_t z);