Use GetLocation in more places

This commit is contained in:
ζeh Matt 2021-09-28 03:16:04 +03:00
parent fb51f796c2
commit eb2de0222b
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
19 changed files with 115 additions and 122 deletions

View File

@ -593,7 +593,7 @@ void reset_all_sprite_quadrant_placements()
auto* spr = GetEntity(i);
if (spr != nullptr && spr->Type != EntityType::Null)
{
spr->MoveTo({ spr->x, spr->y, spr->z });
spr->MoveTo(spr->GetLocation());
}
}
}

View File

@ -100,8 +100,7 @@ GameActions::Result::Ptr GuestSetNameAction::Execute() const
context_broadcast_intent(&intent);
auto res = std::make_unique<GameActions::Result>();
res->Position.x = guest->x;
res->Position.y = guest->y;
res->Position.z = guest->z;
res->Position = guest->GetLocation();
return res;
}

View File

@ -61,7 +61,7 @@ GameActions::Result::Ptr PeepPickupAction::Query() const
{
case PeepPickupType::Pickup:
{
res->Position = { peep->x, peep->y, peep->z };
res->Position = peep->GetLocation();
if (!peep->CanBePickedUp())
{
return MakeResult(GameActions::Status::Disallowed, STR_ERR_CANT_PLACE_PERSON_HERE);
@ -83,7 +83,7 @@ GameActions::Result::Ptr PeepPickupAction::Query() const
}
break;
case PeepPickupType::Cancel:
res->Position = { peep->x, peep->y, peep->z };
res->Position = peep->GetLocation();
break;
case PeepPickupType::Place:
res->Position = _loc;
@ -119,7 +119,7 @@ GameActions::Result::Ptr PeepPickupAction::Execute() const
{
case PeepPickupType::Pickup:
{
res->Position = { peep->x, peep->y, peep->z };
res->Position = peep->GetLocation();
Peep* existing = network_get_pickup_peep(_owner);
if (existing != nullptr)
@ -148,7 +148,7 @@ GameActions::Result::Ptr PeepPickupAction::Execute() const
break;
case PeepPickupType::Cancel:
{
res->Position = { peep->x, peep->y, peep->z };
res->Position = peep->GetLocation();
Peep* const pickedUpPeep = network_get_pickup_peep(_owner);
if (pickedUpPeep != nullptr)

View File

@ -203,7 +203,8 @@ GameActions::Result::Ptr StaffHireNewAction::QueryExecute(bool execute) const
// NOTE: This state is required for the window to act.
newPeep->State = PeepState::Picked;
newPeep->MoveTo({ newPeep->x, newPeep->y, newPeep->z });
// INVESTIGATE: x and y are LOCATION_NULL at this point.
newPeep->MoveTo(newPeep->GetLocation());
}
// Staff uses this
@ -285,17 +286,13 @@ void StaffHireNewAction::AutoPositionNewStaff(Peep* newPeep) const
if (chosenGuest != nullptr)
{
newLocation.x = chosenGuest->x;
newLocation.y = chosenGuest->y;
newLocation.z = chosenGuest->z;
newLocation = chosenGuest->GetLocation();
}
else
{
// User must pick a location
newPeep->State = PeepState::Picked;
newLocation.x = newPeep->x;
newLocation.y = newPeep->y;
newLocation.z = newPeep->z;
newLocation = newPeep->GetLocation();
}
}
else
@ -315,9 +312,7 @@ void StaffHireNewAction::AutoPositionNewStaff(Peep* newPeep) const
{
// User must pick a location
newPeep->State = PeepState::Picked;
newLocation.x = newPeep->x;
newLocation.y = newPeep->y;
newLocation.z = newPeep->z;
newLocation = newPeep->GetLocation();
}
}

View File

@ -102,8 +102,7 @@ GameActions::Result::Ptr StaffSetCostumeAction::Execute() const
context_broadcast_intent(&intent);
auto res = std::make_unique<GameActions::Result>();
res->Position.x = staff->x;
res->Position.y = staff->y;
res->Position.z = staff->z;
res->Position = staff->GetLocation();
return res;
}

View File

@ -85,8 +85,7 @@ GameActions::Result::Ptr StaffSetNameAction::Execute() const
context_broadcast_intent(&intent);
auto res = std::make_unique<GameActions::Result>();
res->Position.x = staff->x;
res->Position.y = staff->y;
res->Position.z = staff->z;
res->Position = staff->GetLocation();
return res;
}

View File

@ -68,8 +68,7 @@ GameActions::Result::Ptr StaffSetOrdersAction::Execute() const
context_broadcast_intent(&intent);
auto res = std::make_unique<GameActions::Result>();
res->Position.x = staff->x;
res->Position.y = staff->y;
res->Position.z = staff->z;
res->Position = staff->GetLocation();
return res;
}

View File

@ -668,7 +668,7 @@ void viewport_update_sprite_follow(rct_window* window)
viewport_set_underground_flag(underground, window, window->viewport);
auto centreLoc = centre_2d_coordinates({ sprite->x, sprite->y, sprite->z }, window->viewport);
auto centreLoc = centre_2d_coordinates(sprite->GetLocation(), window->viewport);
if (centreLoc.has_value())
{
window->savedViewPos = *centreLoc;

View File

@ -224,7 +224,7 @@ std::optional<CoordsXYZ> News::GetSubjectLocation(News::ItemType type, int32_t s
if (peep == nullptr)
break;
subjectLoc = CoordsXYZ{ peep->x, peep->y, peep->z };
subjectLoc = peep->GetLocation();
if (subjectLoc->x != LOCATION_NULL)
break;
@ -251,7 +251,7 @@ std::optional<CoordsXYZ> News::GetSubjectLocation(News::ItemType type, int32_t s
}
if (sprite != nullptr)
{
subjectLoc = CoordsXYZ{ sprite->x, sprite->y, sprite->z };
subjectLoc = sprite->GetLocation();
}
break;
}
@ -260,7 +260,7 @@ std::optional<CoordsXYZ> News::GetSubjectLocation(News::ItemType type, int32_t s
auto peep = TryGetEntity<Peep>(subject);
if (peep != nullptr)
{
subjectLoc = CoordsXYZ{ peep->x, peep->y, peep->z };
subjectLoc = peep->GetLocation();
}
break;
}

View File

@ -25,31 +25,26 @@ template<> void PaintEntity(paint_session* session, const Peep* peep, int32_t im
{
if (peep->Is<Staff>())
{
int16_t peep_x, peep_y, peep_z;
peep_x = peep->x;
peep_y = peep->y;
peep_z = peep->z;
auto loc = peep->GetLocation();
switch (peep->sprite_direction)
{
case 0:
peep_x -= 10;
loc.x -= 10;
break;
case 8:
peep_y += 10;
loc.y += 10;
break;
case 16:
peep_x += 10;
loc.x += 10;
break;
case 24:
peep_y -= 10;
loc.y -= 10;
break;
default:
return;
}
LightfxAdd3DLight(*peep, 0, { peep_x, peep_y, peep_z }, LightType::Spot1);
LightfxAdd3DLight(*peep, 0, loc, LightType::Spot1);
}
}
#endif

View File

@ -65,21 +65,23 @@ void sprite_paint_setup(paint_session* session, const CoordsXY& pos)
}
}
const auto entityPos = spr->GetLocation();
// Only paint sprites that are below the clip height and inside the clip selection.
// Here converting from land/path/etc height scale to pixel height scale.
// Note: peeps/scenery on slopes will be above the base
// height of the slope element, and consequently clipped.
if ((session->ViewFlags & VIEWPORT_FLAG_CLIP_VIEW))
{
if (spr->z > (gClipHeight * COORDS_Z_STEP))
if (entityPos.z > (gClipHeight * COORDS_Z_STEP))
{
continue;
}
if (spr->x < gClipSelectionA.x || spr->x > gClipSelectionB.x)
if (entityPos.x < gClipSelectionA.x || entityPos.x > gClipSelectionB.x)
{
continue;
}
if (spr->y < gClipSelectionA.y || spr->y > gClipSelectionB.y)
if (entityPos.y < gClipSelectionA.y || entityPos.y > gClipSelectionB.y)
{
continue;
}
@ -99,8 +101,8 @@ void sprite_paint_setup(paint_session* session, const CoordsXY& pos)
image_direction &= 0x1F;
session->CurrentlyDrawnItem = spr;
session->SpritePosition.x = spr->x;
session->SpritePosition.y = spr->y;
session->SpritePosition.x = entityPos.x;
session->SpritePosition.y = entityPos.y;
session->InteractionType = ViewportInteractionItem::Entity;
switch (spr->Type)

View File

@ -898,7 +898,7 @@ void Guest::Tick128UpdateGuest(int32_t index)
{
if (State == PeepState::Walking || State == PeepState::Sitting)
{
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Crash, { x, y, z });
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Crash, GetLocation());
ExplosionCloud::Create({ x, y, z + 16 });
ExplosionFlare::Create({ x, y, z + 16 });
@ -1237,7 +1237,7 @@ void Guest::UpdateSitting()
if (!(pathingResult & PATHING_DESTINATION_REACHED))
return;
auto loc = CoordsXYZ{ x, y, z }.ToTileStart() + CoordsXYZ{ BenchUseOffsets[Var37 & 0x7], 0 };
auto loc = GetLocation().ToTileStart() + CoordsXYZ{ BenchUseOffsets[Var37 & 0x7], 0 };
MoveTo(loc);
@ -1770,7 +1770,7 @@ void Guest::OnExitRide(Ride* ride)
int32_t laughType = scenario_rand() & 7;
if (laughType < 3)
{
OpenRCT2::Audio::Play3D(laughs[laughType], { x, y, z });
OpenRCT2::Audio::Play3D(laughs[laughType], GetLocation());
}
}
@ -2289,11 +2289,11 @@ void Guest::SpendMoney(money16& peep_expend_type, money32 amount, ExpenditureTyp
// needing to be synchronised
if (network_get_mode() == NETWORK_MODE_NONE && !gOpenRCT2Headless)
{
MoneyEffect::CreateAt(amount, { x, y, z }, true);
MoneyEffect::CreateAt(amount, GetLocation(), true);
}
}
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Purchase, { x, y, z });
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Purchase, GetLocation());
}
void Guest::SetHasRidden(const Ride* ride)
@ -5007,7 +5007,7 @@ void Guest::UpdateRideShopInteract()
// Do not play toilet flush sound on title screen as it's considered loud and annoying
if (!(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO))
{
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::ToiletFlush, { x, y, z });
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::ToiletFlush, GetLocation());
}
RideSubState = PeepRideSubState::LeaveShop;
@ -5027,11 +5027,13 @@ void Guest::UpdateRideShopLeave()
{
if (auto loc = UpdateAction(); loc.has_value())
{
MoveTo({ loc.value(), z });
const auto curLoc = GetLocation();
if ((x & 0xFFE0) != NextLoc.x)
MoveTo({ loc.value(), curLoc.z });
if ((curLoc.x & 0xFFE0) != NextLoc.x)
return;
if ((y & 0xFFE0) != NextLoc.y)
if ((curLoc.y & 0xFFE0) != NextLoc.y)
return;
}
@ -5238,11 +5240,12 @@ void Guest::UpdateWalking()
Litter::Type::EmptyCup,
};
auto litterType = litter_types[scenario_rand() & 0x3];
int32_t litterX = x + (scenario_rand() & 0x7) - 3;
int32_t litterY = y + (scenario_rand() & 0x7) - 3;
const auto loc = GetLocation();
int32_t litterX = loc.x + (scenario_rand() & 0x7) - 3;
int32_t litterY = loc.y + (scenario_rand() & 0x7) - 3;
Direction litterDirection = (scenario_rand() & 0x3);
Litter::Create({ litterX, litterY, z, litterDirection }, litterType);
Litter::Create({ litterX, litterY, loc.z, litterDirection }, litterType);
}
}
}
@ -5264,16 +5267,17 @@ void Guest::UpdateWalking()
WindowInvalidateFlags |= PEEP_INVALIDATE_PEEP_INVENTORY;
UpdateSpriteType();
int32_t litterX = x + (scenario_rand() & 0x7) - 3;
int32_t litterY = y + (scenario_rand() & 0x7) - 3;
const auto loc = GetLocation();
int32_t litterX = loc.x + (scenario_rand() & 0x7) - 3;
int32_t litterY = loc.y + (scenario_rand() & 0x7) - 3;
Direction litterDirection = (scenario_rand() & 0x3);
Litter::Create({ litterX, litterY, z, litterDirection }, litterType);
Litter::Create({ litterX, litterY, loc.z, litterDirection }, litterType);
}
}
// Check if vehicle is blocking the destination tile
auto curPos = TileCoordsXYZ(CoordsXYZ{ x, y, z });
auto curPos = TileCoordsXYZ(GetLocation());
auto dstPos = TileCoordsXYZ(CoordsXYZ{ GetDestination(), NextLoc.z });
if (curPos.x != dstPos.x || curPos.y != dstPos.y)
{

View File

@ -474,13 +474,14 @@ 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::VomitAlt : Litter::Type::Vomit);
const auto curLoc = GetLocation();
Litter::Create({ curLoc, sprite_direction }, (sprite_index & 1) ? Litter::Type::VomitAlt : Litter::Type::Vomit);
static constexpr OpenRCT2::Audio::SoundId coughs[4] = { OpenRCT2::Audio::SoundId::Cough1, OpenRCT2::Audio::SoundId::Cough2,
OpenRCT2::Audio::SoundId::Cough3,
OpenRCT2::Audio::SoundId::Cough4 };
auto soundId = coughs[scenario_rand() & 3];
OpenRCT2::Audio::Play3D(soundId, { x, y, z });
OpenRCT2::Audio::Play3D(soundId, curLoc);
return { { x, y } };
}

View File

@ -1344,7 +1344,7 @@ void Staff::UpdateSweeping()
if (Action == PeepActionType::StaffSweep && ActionFrame == 8)
{
// Remove sick at this location
Litter::RemoveAt({ x, y, z });
Litter::RemoveAt(GetLocation());
StaffLitterSwept++;
WindowInvalidateFlags |= PEEP_INVALIDATE_STAFF_STATS;
}
@ -2489,7 +2489,7 @@ bool Staff::UpdateFixingFixStationBrakes(bool firstRun, Ride* ride)
if (ActionFrame == 0x13 || ActionFrame == 0x19 || ActionFrame == 0x1F || ActionFrame == 0x25 || ActionFrame == 0x2B)
{
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::MechanicFix, { x, y, z });
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::MechanicFix, GetLocation());
}
return false;

View File

@ -391,9 +391,7 @@ int32_t Vehicle::CableLiftUpdateTrackMotion()
if (vehicle->remaining_distance < 0 || vehicle->remaining_distance >= 13962)
{
unk_F64E20.x = vehicle->x;
unk_F64E20.y = vehicle->y;
unk_F64E20.z = vehicle->z;
unk_F64E20 = vehicle->GetLocation();
vehicle->Invalidate();
while (true)

View File

@ -3274,12 +3274,12 @@ void Vehicle::UpdateDeparting()
auto soundId = (rideEntry->vehicles[0].sound_range == 4) ? OpenRCT2::Audio::SoundId::Tram
: OpenRCT2::Audio::SoundId::TrainDeparting;
OpenRCT2::Audio::Play3D(soundId, { x, y, z });
OpenRCT2::Audio::Play3D(soundId, GetLocation());
}
if (curRide->mode == RideMode::UpwardLaunch || (curRide->mode == RideMode::DownwardLaunch && var_CE > 1))
{
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::RideLaunch2, { x, y, z });
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::RideLaunch2, GetLocation());
}
if (!(curRide->lifecycle_flags & RIDE_LIFECYCLE_TESTED))
@ -3492,7 +3492,7 @@ void Vehicle::FinishDeparting()
if (var_CE >= 1 && (14 << 16) > velocity)
return;
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::RideLaunch1, { x, y, z });
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::RideLaunch1, GetLocation());
}
if (curRide->mode == RideMode::UpwardLaunch)
@ -3500,7 +3500,7 @@ void Vehicle::FinishDeparting()
if ((curRide->launch_speed << 16) > velocity)
return;
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::RideLaunch1, { x, y, z });
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::RideLaunch1, GetLocation());
}
if (curRide->mode != RideMode::Race && !curRide->IsBlockSectioned())
@ -3633,14 +3633,15 @@ void Vehicle::UpdateCollisionSetup()
#ifdef ENABLE_SCRIPTING
InvokeVehicleCrashHook(train->sprite_index, "another_vehicle");
#endif
const auto trainLoc = train->GetLocation();
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Crash, { train->x, train->y, train->z });
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Crash, trainLoc);
ExplosionCloud::Create({ train->x, train->y, train->z });
ExplosionCloud::Create(trainLoc);
for (int32_t i = 0; i < 10; i++)
{
VehicleCrashParticle::Create(train->colours, { train->x, train->y, train->z });
VehicleCrashParticle::Create(train->colours, trainLoc);
}
train->IsCrashedVehicle = true;
@ -3651,7 +3652,7 @@ void Vehicle::UpdateCollisionSetup()
train->sprite_height_negative = 45;
train->sprite_height_positive = 5;
train->MoveTo({ train->x, train->y, train->z });
train->MoveTo(trainLoc);
train->SwingSpeed = 0;
}
@ -3694,7 +3695,7 @@ void Vehicle::UpdateCrashSetup()
if (NumPeepsUntilTrainTail() != 0)
{
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::HauntedHouseScream2, { x, y, z });
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::HauntedHouseScream2, GetLocation());
}
int32_t edx = velocity >> 10;
@ -4131,7 +4132,7 @@ void Vehicle::UpdateArriving()
if ((curRide->mode == RideMode::UpwardLaunch || curRide->mode == RideMode::DownwardLaunch) && var_CE < 2)
{
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::RideLaunch2, { x, y, z });
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::RideLaunch2, GetLocation());
velocity = 0;
acceleration = 0;
SetState(Vehicle::Status::Departing, 1);
@ -4421,9 +4422,7 @@ void Vehicle::UpdateMotionBoatHire()
if (remaining_distance >= 0x368A)
{
sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL;
unk_F64E20.x = x;
unk_F64E20.y = y;
unk_F64E20.z = z;
unk_F64E20 = GetLocation();
Invalidate();
for (;;)
@ -5124,24 +5123,24 @@ void Vehicle::UpdateHauntedHouseOperating()
switch (current_time)
{
case 45:
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::HauntedHouseScare, { x, y, z });
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::HauntedHouseScare, GetLocation());
break;
case 75:
Pitch = 1;
Invalidate();
break;
case 400:
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::HauntedHouseScream1, { x, y, z });
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::HauntedHouseScream1, GetLocation());
break;
case 745:
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::HauntedHouseScare, { x, y, z });
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::HauntedHouseScare, GetLocation());
break;
case 775:
Pitch = 1;
Invalidate();
break;
case 1100:
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::HauntedHouseScream2, { x, y, z });
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::HauntedHouseScream2, GetLocation());
break;
}
}
@ -5401,15 +5400,17 @@ void Vehicle::CrashOnLand()
}
sub_state = 2;
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Crash, { x, y, z });
ExplosionCloud::Create({ x, y, z });
ExplosionFlare::Create({ x, y, z });
const auto curLoc = GetLocation();
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Crash, curLoc);
ExplosionCloud::Create(curLoc);
ExplosionFlare::Create(curLoc);
uint8_t numParticles = std::min(sprite_width, static_cast<uint8_t>(7));
while (numParticles-- != 0)
VehicleCrashParticle::Create(colours, { x, y, z });
VehicleCrashParticle::Create(colours, curLoc);
IsCrashedVehicle = true;
animation_frame = 0;
@ -5418,7 +5419,7 @@ void Vehicle::CrashOnLand()
sprite_height_negative = 45;
sprite_height_positive = 5;
MoveTo({ x, y, z });
MoveTo(curLoc);
crash_z = 0;
}
@ -5467,16 +5468,18 @@ void Vehicle::CrashOnWater()
}
sub_state = 2;
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Water1, { x, y, z });
CrashSplashParticle::Create({ x, y, z });
CrashSplashParticle::Create({ x - 8, y - 9, z });
CrashSplashParticle::Create({ x + 11, y - 9, z });
CrashSplashParticle::Create({ x + 11, y + 8, z });
CrashSplashParticle::Create({ x - 4, y + 8, z });
const auto curLoc = GetLocation();
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::Water1, curLoc);
CrashSplashParticle::Create(curLoc);
CrashSplashParticle::Create(curLoc + CoordsXYZ{ -8, -9, 0 });
CrashSplashParticle::Create(curLoc + CoordsXYZ{ 11, -9, 0 });
CrashSplashParticle::Create(curLoc + CoordsXYZ{ 11, 8, 0 });
CrashSplashParticle::Create(curLoc + CoordsXYZ{ -4, 8, 0 });
for (int32_t i = 0; i < 10; ++i)
VehicleCrashParticle::Create(colours, { x - 4, y + 8, z });
VehicleCrashParticle::Create(colours, curLoc + CoordsXYZ{ -4, 8, 0 });
IsCrashedVehicle = true;
animation_frame = 0;
@ -5485,7 +5488,7 @@ void Vehicle::CrashOnWater()
sprite_height_negative = 45;
sprite_height_positive = 5;
MoveTo({ x, y, z });
MoveTo(curLoc);
crash_z = -1;
}
@ -5499,6 +5502,8 @@ void Vehicle::UpdateCrash()
for (Vehicle* curVehicle = GetEntity<Vehicle>(sprite_index); curVehicle != nullptr;
curVehicle = GetEntity<Vehicle>(curVehicle->next_vehicle_on_train))
{
CoordsXYZ curPos = curVehicle->GetLocation();
if (curVehicle->sub_state > 1)
{
if (curVehicle->crash_z <= 96)
@ -5508,7 +5513,8 @@ void Vehicle::UpdateCrash()
{
int32_t xOffset = (scenario_rand() & 2) - 1;
int32_t yOffset = (scenario_rand() & 2) - 1;
ExplosionCloud::Create({ curVehicle->x + xOffset, curVehicle->y + yOffset, curVehicle->z });
ExplosionCloud::Create(curPos + CoordsXYZ{ xOffset, yOffset, 0 });
}
}
if (curVehicle->animationState <= 0xe388)
@ -5526,7 +5532,7 @@ void Vehicle::UpdateCrash()
continue;
}
TileElement* collideElement = vehicle_check_collision({ curVehicle->x, curVehicle->y, curVehicle->z });
TileElement* collideElement = vehicle_check_collision(curPos);
if (collideElement == nullptr)
{
curVehicle->sub_state = 1;
@ -5537,12 +5543,12 @@ void Vehicle::UpdateCrash()
continue;
}
int16_t height = tile_element_height({ curVehicle->x, curVehicle->y });
int16_t waterHeight = tile_element_water_height({ curVehicle->x, curVehicle->y });
int16_t height = tile_element_height(curPos);
int16_t waterHeight = tile_element_water_height(curPos);
int16_t zDiff;
if (waterHeight != 0)
{
zDiff = curVehicle->z - waterHeight;
zDiff = curPos.z - waterHeight;
if (zDiff <= 0 && zDiff >= -20)
{
curVehicle->CrashOnWater();
@ -5550,8 +5556,8 @@ void Vehicle::UpdateCrash()
}
}
zDiff = curVehicle->z - height;
if ((zDiff <= 0 && zDiff >= -20) || curVehicle->z < 16)
zDiff = curPos.z - height;
if ((zDiff <= 0 && zDiff >= -20) || curPos.z < 16)
{
curVehicle->CrashOnLand();
continue;
@ -5559,20 +5565,18 @@ void Vehicle::UpdateCrash()
curVehicle->Invalidate();
CoordsXYZ curPosition = { curVehicle->x, curVehicle->y, curVehicle->z };
curPosition.x += static_cast<int8_t>(curVehicle->crash_x >> 8);
curPosition.y += static_cast<int8_t>(curVehicle->crash_y >> 8);
curPosition.z += static_cast<int8_t>(curVehicle->crash_z >> 8);
curPos.x += static_cast<int8_t>(curVehicle->crash_x >> 8);
curPos.y += static_cast<int8_t>(curVehicle->crash_y >> 8);
curPos.z += static_cast<int8_t>(curVehicle->crash_z >> 8);
curVehicle->TrackLocation = { (curVehicle->crash_x << 8), (curVehicle->crash_y << 8), (curVehicle->crash_z << 8) };
if (!map_is_location_valid(curPosition))
if (!map_is_location_valid(curPos))
{
curVehicle->CrashOnLand();
continue;
}
curVehicle->MoveTo(curPosition);
curVehicle->MoveTo(curPos);
if (curVehicle->sub_state == 1)
{

View File

@ -20,17 +20,17 @@ void EntityTweener::PopulateEntities()
for (auto ent : EntityList<Guest>())
{
Entities.push_back(ent);
PrePos.emplace_back(ent->x, ent->y, ent->z);
PrePos.emplace_back(ent->GetLocation());
}
for (auto ent : EntityList<Staff>())
{
Entities.push_back(ent);
PrePos.emplace_back(ent->x, ent->y, ent->z);
PrePos.emplace_back(ent->GetLocation());
}
for (auto ent : EntityList<Vehicle>())
{
Entities.push_back(ent);
PrePos.emplace_back(ent->x, ent->y, ent->z);
PrePos.emplace_back(ent->GetLocation());
}
}
@ -52,7 +52,7 @@ void EntityTweener::PostTick()
}
else
{
PostPos.emplace_back(ent->x, ent->y, ent->z);
PostPos.emplace_back(ent->GetLocation());
}
}
}

View File

@ -544,9 +544,7 @@ void sprite_set_coordinates(const CoordsXYZ& spritePos, EntityBase* sprite)
sprite->SpriteRect = ScreenRect(
screenCoords - ScreenCoordsXY{ sprite->sprite_width, sprite->sprite_height_negative },
screenCoords + ScreenCoordsXY{ sprite->sprite_width, sprite->sprite_height_positive });
sprite->x = spritePos.x;
sprite->y = spritePos.y;
sprite->z = spritePos.z;
sprite->SetLocation(spritePos);
}
/**

View File

@ -109,7 +109,7 @@ protected:
peep->PerformNextAction(pathingResult);
++step;
*pos = TileCoordsXYZ(CoordsXYZ(peep->x, peep->y, peep->z));
*pos = TileCoordsXYZ(peep->GetLocation());
EXPECT_PRED_FORMAT1(AssertIsNotForbiddenPosition, *pos);