From 40a7dfbb2406cae6d3740822cd8b4d4bc0900981 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Sun, 21 Jun 2020 14:13:22 -0300 Subject: [PATCH] Make litter_create use CoordsXYZD --- src/openrct2/peep/Guest.cpp | 12 ++++++------ src/openrct2/peep/Peep.cpp | 2 +- src/openrct2/world/Sprite.cpp | 13 +++++++------ src/openrct2/world/Sprite.h | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index ce6e706867..afc5da8c3a 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -5314,9 +5314,9 @@ void Guest::UpdateWalking() int32_t litterType = litter_types[scenario_rand() & 0x3]; int32_t litterX = x + (scenario_rand() & 0x7) - 3; int32_t litterY = y + (scenario_rand() & 0x7) - 3; - int32_t litterDirection = (scenario_rand() & 0x3); + Direction litterDirection = (scenario_rand() & 0x3); - litter_create(litterX, litterY, z, litterDirection, litterType); + litter_create({ litterX, litterY, z, litterDirection }, litterType); } } } @@ -5352,9 +5352,9 @@ void Guest::UpdateWalking() int32_t litterX = x + (scenario_rand() & 0x7) - 3; int32_t litterY = y + (scenario_rand() & 0x7) - 3; - int32_t litterDirection = (scenario_rand() & 0x3); + Direction litterDirection = (scenario_rand() & 0x3); - litter_create(litterX, litterY, z, litterDirection, litterType); + litter_create({ litterX, litterY, z, litterDirection }, litterType); } } @@ -5917,7 +5917,7 @@ void Guest::UpdateUsingBin() int32_t litterX = x + (scenario_rand() & 7) - 3; int32_t litterY = y + (scenario_rand() & 7) - 3; - litter_create(litterX, litterY, z, scenario_rand() & 3, litterType); + litter_create({ litterX, litterY, z, static_cast(scenario_rand() & 3) }, litterType); ItemStandardFlags &= ~(1 << cur_container); WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_INVENTORY; @@ -5951,7 +5951,7 @@ void Guest::UpdateUsingBin() int32_t litterX = x + (scenario_rand() & 7) - 3; int32_t litterY = y + (scenario_rand() & 7) - 3; - litter_create(litterX, litterY, z, scenario_rand() & 3, litterType); + litter_create({ litterX, litterY, z, static_cast(scenario_rand() & 3) }, litterType); ItemExtraFlags &= ~(1 << cur_container); WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_INVENTORY; diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index a39171e295..5beb991eb2 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -653,7 +653,7 @@ std::optional Peep::UpdateAction(int16_t& xy_distance) WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_2; // Create sick at location - litter_create(x, y, z, sprite_direction, (sprite_index & 1) ? LITTER_TYPE_SICK_ALT : LITTER_TYPE_SICK); + litter_create({ x, y, z, sprite_direction }, (sprite_index & 1) ? LITTER_TYPE_SICK_ALT : LITTER_TYPE_SICK); SoundId coughs[4] = { SoundId::Cough1, SoundId::Cough2, SoundId::Cough3, SoundId::Cough4 }; auto soundId = coughs[scenario_rand() & 3]; diff --git a/src/openrct2/world/Sprite.cpp b/src/openrct2/world/Sprite.cpp index df04024f5d..97957d4d50 100644 --- a/src/openrct2/world/Sprite.cpp +++ b/src/openrct2/world/Sprite.cpp @@ -786,15 +786,16 @@ static bool litter_can_be_at(int32_t x, int32_t y, int32_t z) * * rct2: 0x0067375D */ -void litter_create(int32_t x, int32_t y, int32_t z, int32_t direction, int32_t type) +void litter_create(const CoordsXYZD& litterPos, int32_t type) { if (gCheatsDisableLittering) return; - x += CoordsDirectionDelta[direction >> 3].x / 8; - y += CoordsDirectionDelta[direction >> 3].y / 8; + auto offsetLitterPos = litterPos + + CoordsXY{ CoordsDirectionDelta[litterPos.direction >> 3].x / 8, + CoordsDirectionDelta[litterPos.direction >> 3].y / 8 }; - if (!litter_can_be_at(x, y, z)) + if (!litter_can_be_at(offsetLitterPos.x, offsetLitterPos.y, offsetLitterPos.z)) return; if (gSpriteListCount[SPRITE_LIST_LITTER] >= 500) @@ -821,13 +822,13 @@ void litter_create(int32_t x, int32_t y, int32_t z, int32_t direction, int32_t t if (litter == nullptr) return; - litter->sprite_direction = direction; + litter->sprite_direction = offsetLitterPos.direction; litter->sprite_width = 6; litter->sprite_height_negative = 6; litter->sprite_height_positive = 3; litter->sprite_identifier = SPRITE_IDENTIFIER_LITTER; litter->type = type; - litter->MoveTo({ x, y, z }); + litter->MoveTo(offsetLitterPos); litter->Invalidate0(); litter->creationTick = gScenarioTicks; } diff --git a/src/openrct2/world/Sprite.h b/src/openrct2/world/Sprite.h index 2943b040e1..815e885736 100644 --- a/src/openrct2/world/Sprite.h +++ b/src/openrct2/world/Sprite.h @@ -219,7 +219,7 @@ void sprite_clear_all_unused(); void sprite_misc_update_all(); 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_create(const CoordsXYZD& litterPos, int32_t type); void litter_remove_at(const CoordsXYZ& litterPos); uint16_t remove_floating_sprites(); void sprite_misc_explosion_cloud_create(const CoordsXYZ& cloudPos);