From ae1e9b75edabdd9336ddfa5cbc5999f293b6e6e9 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Sun, 21 Jun 2020 13:50:54 -0300 Subject: [PATCH] Make sprite_set_coordinates use CoordsXYZ --- src/openrct2/world/Sprite.cpp | 21 +++++++++++---------- src/openrct2/world/Sprite.h | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/openrct2/world/Sprite.cpp b/src/openrct2/world/Sprite.cpp index 0bbc1709cc..5134d6fa7a 100644 --- a/src/openrct2/world/Sprite.cpp +++ b/src/openrct2/world/Sprite.cpp @@ -715,22 +715,21 @@ void SpriteBase::MoveTo(const CoordsXYZ& newLocation) } else { - sprite_set_coordinates(loc.x, loc.y, loc.z, this); + sprite_set_coordinates(loc, this); } } -void sprite_set_coordinates(int16_t x, int16_t y, int16_t z, SpriteBase* sprite) +void sprite_set_coordinates(const CoordsXYZ& spritePos, SpriteBase* sprite) { - CoordsXYZ coords3d = { x, y, z }; - auto screenCoords = translate_3d_to_2d_with_z(get_current_rotation(), coords3d); + auto screenCoords = translate_3d_to_2d_with_z(get_current_rotation(), spritePos); sprite->sprite_left = screenCoords.x - sprite->sprite_width; sprite->sprite_right = screenCoords.x + sprite->sprite_width; sprite->sprite_top = screenCoords.y - sprite->sprite_height_negative; sprite->sprite_bottom = screenCoords.y + sprite->sprite_height_positive; - sprite->x = x; - sprite->y = y; - sprite->z = z; + sprite->x = spritePos.x; + sprite->y = spritePos.y; + sprite->z = spritePos.z; } /** @@ -938,8 +937,10 @@ void sprite_position_tween_all(float alpha) continue; } 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); + { static_cast(std::round(posB.x * alpha + posA.x * inv)), + static_cast(std::round(posB.y * alpha + posA.y * inv)), + static_cast(std::round(posB.z * alpha + posA.z * inv)) }, + sprite); sprite->Invalidate2(); } } @@ -958,7 +959,7 @@ void sprite_position_tween_restore() sprite->Invalidate2(); auto pos = _spritelocations2[i]; - sprite_set_coordinates(pos.x, pos.y, pos.z, sprite); + sprite_set_coordinates(pos, sprite); } } } diff --git a/src/openrct2/world/Sprite.h b/src/openrct2/world/Sprite.h index 841605a45b..c6669a8d9b 100644 --- a/src/openrct2/world/Sprite.h +++ b/src/openrct2/world/Sprite.h @@ -217,7 +217,7 @@ void reset_sprite_list(); 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 sprite_set_coordinates(const CoordsXYZ& spritePos, 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);