Make litter_create use CoordsXYZD

This commit is contained in:
Tulio Leao 2020-06-21 14:13:22 -03:00
parent 7622ca513e
commit 40a7dfbb24
4 changed files with 15 additions and 14 deletions

View File

@ -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<Direction>(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<Direction>(scenario_rand() & 3) }, litterType);
ItemExtraFlags &= ~(1 << cur_container);
WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_INVENTORY;

View File

@ -653,7 +653,7 @@ std::optional<CoordsXY> 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];

View File

@ -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;
}

View File

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