mirror of https://github.com/OpenRCT2/OpenRCT2.git
Modify next_x/y/z to become a CoordsXYZ (#10680)
* Modify next_x/y/z to become a CoordsXYZ Should be further scope for refactoring from this. * Make suggested changes * Fix default construct issues
This commit is contained in:
parent
3df79cb4d5
commit
b8b539c16e
|
@ -2093,7 +2093,7 @@ void window_guest_debug_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
|||
}
|
||||
y += LIST_ROW_HEIGHT;
|
||||
{
|
||||
int32_t args[] = { peep->next_x, peep->next_y, peep->next_z };
|
||||
int32_t args[] = { peep->NextLoc.x, peep->NextLoc.y, peep->NextLoc.z };
|
||||
format_string(buffer, sizeof(buffer), STR_PEEP_DEBUG_NEXT, args);
|
||||
if (peep->GetNextIsSurface())
|
||||
{
|
||||
|
|
|
@ -202,9 +202,9 @@ struct GameStateSnapshots : public IGameStateSnapshots
|
|||
|
||||
void CompareSpriteDataPeep(const Peep& spriteBase, const Peep& spriteCmp, GameStateSpriteChange_t& changeData) const
|
||||
{
|
||||
COMPARE_FIELD(Peep, next_x);
|
||||
COMPARE_FIELD(Peep, next_y);
|
||||
COMPARE_FIELD(Peep, next_z);
|
||||
COMPARE_FIELD(Peep, NextLoc.x);
|
||||
COMPARE_FIELD(Peep, NextLoc.y);
|
||||
COMPARE_FIELD(Peep, NextLoc.z);
|
||||
COMPARE_FIELD(Peep, next_flags);
|
||||
COMPARE_FIELD(Peep, outside_of_park);
|
||||
COMPARE_FIELD(Peep, state);
|
||||
|
|
|
@ -283,7 +283,7 @@ private:
|
|||
if (guest->state == PEEP_STATE_WALKING)
|
||||
{
|
||||
// Check the walking guest's tile. Only count them if they're on a path tile.
|
||||
guest_tile = map_get_path_element_at({ guest->next_x / 32, guest->next_y / 32, guest->next_z });
|
||||
guest_tile = map_get_path_element_at(TileCoordsXYZ{ guest->NextLoc });
|
||||
if (guest_tile != nullptr)
|
||||
++count;
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ private:
|
|||
{
|
||||
if (guest->state == PEEP_STATE_WALKING)
|
||||
{
|
||||
guest_tile = map_get_path_element_at({ guest->next_x / 32, guest->next_y / 32, guest->next_z });
|
||||
guest_tile = map_get_path_element_at(TileCoordsXYZ{ guest->NextLoc });
|
||||
if (guest_tile != nullptr)
|
||||
{
|
||||
if (rand == 0)
|
||||
|
|
|
@ -957,7 +957,7 @@ void Guest::Tick128UpdateGuest(int32_t index)
|
|||
{
|
||||
/* Peep happiness is affected once the peep has been waiting
|
||||
* too long in a queue. */
|
||||
TileElement* tileElement = map_get_first_element_at({ next_x, next_y });
|
||||
TileElement* tileElement = map_get_first_element_at(NextLoc);
|
||||
bool found = false;
|
||||
do
|
||||
{
|
||||
|
@ -965,7 +965,7 @@ void Guest::Tick128UpdateGuest(int32_t index)
|
|||
break;
|
||||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH)
|
||||
continue;
|
||||
if (tileElement->base_height != next_z)
|
||||
if (tileElement->GetBaseZ() == NextLoc.z)
|
||||
continue;
|
||||
|
||||
// Check if the footpath has a queue line TV monitor on it
|
||||
|
@ -3385,8 +3385,8 @@ void Guest::UpdateBuying()
|
|||
window_invalidate_by_number(WC_PEEP, sprite_index);
|
||||
}
|
||||
sprite_direction ^= 0x10;
|
||||
destination_x = next_x + 16;
|
||||
destination_y = next_y + 16;
|
||||
destination_x = NextLoc.x + 16;
|
||||
destination_y = NextLoc.y + 16;
|
||||
direction = direction_reverse(direction);
|
||||
|
||||
SetState(PEEP_STATE_WALKING);
|
||||
|
@ -5079,8 +5079,8 @@ void Guest::UpdateRideShopInteract()
|
|||
if (ride == nullptr)
|
||||
return;
|
||||
|
||||
const int16_t tileCenterX = next_x + 16;
|
||||
const int16_t tileCenterY = next_y + 16;
|
||||
const int16_t tileCenterX = NextLoc.x + 16;
|
||||
const int16_t tileCenterY = NextLoc.y + 16;
|
||||
if (ride->type == RIDE_TYPE_FIRST_AID)
|
||||
{
|
||||
if (nausea <= 35)
|
||||
|
@ -5134,9 +5134,9 @@ void Guest::UpdateRideShopLeave()
|
|||
{
|
||||
MoveTo((*loc).x, (*loc).y, z);
|
||||
|
||||
if ((x & 0xFFE0) != next_x)
|
||||
if ((x & 0xFFE0) != NextLoc.x)
|
||||
return;
|
||||
if ((y & 0xFFE0) != next_y)
|
||||
if ((y & 0xFFE0) != NextLoc.y)
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5390,7 +5390,7 @@ void Guest::UpdateWalking()
|
|||
|
||||
// Check if vehicle is blocking the destination tile
|
||||
auto curPos = TileCoordsXYZ(CoordsXYZ{ x, y, z });
|
||||
auto dstPos = TileCoordsXYZ(CoordsXY{ destination_x, destination_y }, next_z);
|
||||
auto dstPos = TileCoordsXYZ(CoordsXYZ{ destination_x, destination_y, NextLoc.z });
|
||||
if (curPos.x != dstPos.x || curPos.y != dstPos.y)
|
||||
{
|
||||
if (footpath_is_blocked_by_vehicle(dstPos))
|
||||
|
@ -5407,7 +5407,7 @@ void Guest::UpdateWalking()
|
|||
|
||||
if (GetNextIsSurface())
|
||||
{
|
||||
auto surfaceElement = map_get_surface_element_at(CoordsXY{ next_x, next_y });
|
||||
auto surfaceElement = map_get_surface_element_at(NextLoc);
|
||||
|
||||
if (surfaceElement != nullptr)
|
||||
{
|
||||
|
@ -5456,7 +5456,7 @@ void Guest::UpdateWalking()
|
|||
if (GetNextIsSurface() || GetNextIsSloped())
|
||||
return;
|
||||
|
||||
TileElement* tileElement = map_get_first_element_at({ next_x, next_y });
|
||||
TileElement* tileElement = map_get_first_element_at(NextLoc);
|
||||
if (tileElement == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -5464,7 +5464,7 @@ void Guest::UpdateWalking()
|
|||
{
|
||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH)
|
||||
{
|
||||
if (next_z == tileElement->base_height)
|
||||
if (NextLoc.z == tileElement->GetBaseZ())
|
||||
break;
|
||||
}
|
||||
if (tileElement->IsLastForTile())
|
||||
|
@ -5874,7 +5874,7 @@ void Guest::UpdateUsingBin()
|
|||
return;
|
||||
}
|
||||
|
||||
TileElement* tileElement = map_get_first_element_at({ next_x, next_y });
|
||||
TileElement* tileElement = map_get_first_element_at(NextLoc);
|
||||
if (tileElement == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -5885,7 +5885,7 @@ void Guest::UpdateUsingBin()
|
|||
continue;
|
||||
}
|
||||
|
||||
if (tileElement->base_height == next_z)
|
||||
if (tileElement->GetBaseZ() == NextLoc.z)
|
||||
break;
|
||||
|
||||
if (tileElement->IsLastForTile())
|
||||
|
@ -5997,7 +5997,7 @@ void Guest::UpdateUsingBin()
|
|||
additionStatus |= space_left_in_bin << selected_bin;
|
||||
tileElement->AsPath()->SetAdditionStatus(additionStatus);
|
||||
|
||||
map_invalidate_tile_zoom0({ next_x, next_y, tileElement->GetBaseZ(), tileElement->GetClearanceZ() });
|
||||
map_invalidate_tile_zoom0({ NextLoc, tileElement->GetBaseZ(), tileElement->GetClearanceZ() });
|
||||
StateReset();
|
||||
break;
|
||||
}
|
||||
|
@ -6044,7 +6044,7 @@ bool Guest::UpdateWalkingFindBench()
|
|||
if (!ShouldFindBench())
|
||||
return false;
|
||||
|
||||
TileElement* tileElement = map_get_first_element_at({ next_x, next_y });
|
||||
TileElement* tileElement = map_get_first_element_at(NextLoc);
|
||||
if (tileElement == nullptr)
|
||||
return false;
|
||||
|
||||
|
@ -6052,7 +6052,7 @@ bool Guest::UpdateWalkingFindBench()
|
|||
{
|
||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH)
|
||||
{
|
||||
if (next_z == tileElement->base_height)
|
||||
if (NextLoc.z == tileElement->GetBaseZ())
|
||||
break;
|
||||
}
|
||||
if (tileElement->IsLastForTile())
|
||||
|
@ -6141,7 +6141,7 @@ bool Guest::UpdateWalkingFindBin()
|
|||
if (peep->GetNextIsSurface())
|
||||
return false;
|
||||
|
||||
TileElement* tileElement = map_get_first_element_at({ peep->next_x, peep->next_y });
|
||||
TileElement* tileElement = map_get_first_element_at(peep->NextLoc);
|
||||
if (tileElement == nullptr)
|
||||
return false;
|
||||
|
||||
|
@ -6149,7 +6149,7 @@ bool Guest::UpdateWalkingFindBin()
|
|||
{
|
||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH)
|
||||
{
|
||||
if (peep->next_z == tileElement->base_height)
|
||||
if (peep->NextLoc.z == tileElement->GetBaseZ())
|
||||
break;
|
||||
}
|
||||
if (tileElement->IsLastForTile())
|
||||
|
@ -6244,7 +6244,7 @@ static void peep_update_walking_break_scenery(Peep* peep)
|
|||
if (peep->GetNextIsSurface())
|
||||
return;
|
||||
|
||||
TileElement* tileElement = map_get_first_element_at({ peep->next_x, peep->next_y });
|
||||
TileElement* tileElement = map_get_first_element_at(peep->NextLoc);
|
||||
if (tileElement == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -6252,7 +6252,7 @@ static void peep_update_walking_break_scenery(Peep* peep)
|
|||
{
|
||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH)
|
||||
{
|
||||
if (peep->next_z == tileElement->base_height)
|
||||
if (peep->NextLoc.z == tileElement->GetBaseZ())
|
||||
break;
|
||||
}
|
||||
if (tileElement->IsLastForTile())
|
||||
|
@ -6314,7 +6314,7 @@ static void peep_update_walking_break_scenery(Peep* peep)
|
|||
|
||||
tileElement->AsPath()->SetIsBroken(true);
|
||||
|
||||
map_invalidate_tile_zoom1({ peep->next_x, peep->next_y, tileElement->GetBaseZ(), tileElement->GetBaseZ() + 32 });
|
||||
map_invalidate_tile_zoom1({ peep->NextLoc, tileElement->GetBaseZ(), tileElement->GetBaseZ() + 32 });
|
||||
|
||||
peep->angriness = 16;
|
||||
}
|
||||
|
@ -6390,7 +6390,7 @@ bool loc_690FD0(Peep* peep, uint8_t* rideToView, uint8_t* rideSeatToView, TileEl
|
|||
*rideSeatToView = 1;
|
||||
if (ride->status != RIDE_STATUS_OPEN)
|
||||
{
|
||||
if (tileElement->clearance_height > peep->next_z + 8)
|
||||
if (tileElement->GetClearanceZ() > peep->NextLoc.z + (8 * COORDS_Z_STEP))
|
||||
{
|
||||
*rideSeatToView |= (1 << 1);
|
||||
}
|
||||
|
@ -6403,7 +6403,7 @@ bool loc_690FD0(Peep* peep, uint8_t* rideToView, uint8_t* rideSeatToView, TileEl
|
|||
*rideSeatToView = 0;
|
||||
if (ride->status == RIDE_STATUS_OPEN && !(ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN))
|
||||
{
|
||||
if (tileElement->clearance_height > peep->next_z + 8)
|
||||
if (tileElement->GetClearanceZ() > peep->NextLoc.z + (8 * COORDS_Z_STEP))
|
||||
{
|
||||
*rideSeatToView = 0x02;
|
||||
}
|
||||
|
@ -6429,7 +6429,7 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToV
|
|||
{
|
||||
TileElement* tileElement;
|
||||
|
||||
auto surfaceElement = map_get_surface_element_at(CoordsXY{ peep->next_x, peep->next_y });
|
||||
auto surfaceElement = map_get_surface_element_at(peep->NextLoc);
|
||||
|
||||
tileElement = reinterpret_cast<TileElement*>(surfaceElement);
|
||||
if (tileElement == nullptr)
|
||||
|
@ -6453,16 +6453,16 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToV
|
|||
auto wallEntry = tileElement->AsWall()->GetEntry();
|
||||
if (wallEntry == nullptr || (wallEntry->wall.flags2 & WALL_SCENERY_2_IS_OPAQUE))
|
||||
continue;
|
||||
if (peep->next_z + 4 <= tileElement->base_height)
|
||||
if (peep->NextLoc.z + (4 * COORDS_Z_STEP) <= tileElement->GetBaseZ())
|
||||
continue;
|
||||
if (peep->next_z + 1 >= tileElement->clearance_height)
|
||||
if (peep->NextLoc.z + (1 * COORDS_Z_STEP) >= tileElement->GetClearanceZ())
|
||||
continue;
|
||||
|
||||
return false;
|
||||
} while (!(tileElement++)->IsLastForTile());
|
||||
|
||||
uint16_t x = peep->next_x + CoordsDirectionDelta[edge].x;
|
||||
uint16_t y = peep->next_y + CoordsDirectionDelta[edge].y;
|
||||
uint16_t x = peep->NextLoc.x + CoordsDirectionDelta[edge].x;
|
||||
uint16_t y = peep->NextLoc.y + CoordsDirectionDelta[edge].y;
|
||||
if (x > 255 * 32 || y > 255 * 32)
|
||||
{
|
||||
return false;
|
||||
|
@ -6493,9 +6493,9 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToV
|
|||
if (wallEntry == nullptr || (wallEntry->wall.flags2 & WALL_SCENERY_2_IS_OPAQUE))
|
||||
continue;
|
||||
// TODO: Check whether this shouldn't be <=, as the other loops use. If so, also extract as loop A.
|
||||
if (peep->next_z + 4 >= tileElement->base_height)
|
||||
if (peep->NextLoc.z + (4 * COORDS_Z_STEP) >= tileElement->GetBaseZ())
|
||||
continue;
|
||||
if (peep->next_z + 1 >= tileElement->clearance_height)
|
||||
if (peep->NextLoc.z + (1 * COORDS_Z_STEP) >= tileElement->GetClearanceZ())
|
||||
continue;
|
||||
|
||||
return false;
|
||||
|
@ -6513,9 +6513,9 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToV
|
|||
continue;
|
||||
}
|
||||
|
||||
if (tileElement->clearance_height + 1 < peep->next_z)
|
||||
if (tileElement->GetClearanceZ() + (1 * COORDS_Z_STEP) < peep->NextLoc.z)
|
||||
continue;
|
||||
if (peep->next_z + 6 < tileElement->base_height)
|
||||
if (peep->NextLoc.z + (6 * COORDS_Z_STEP) < tileElement->GetBaseZ())
|
||||
continue;
|
||||
|
||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_TRACK)
|
||||
|
@ -6534,7 +6534,7 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToV
|
|||
}
|
||||
|
||||
*rideSeatToView = 0;
|
||||
if (tileElement->clearance_height >= peep->next_z + 8)
|
||||
if (tileElement->GetClearanceZ() >= peep->NextLoc.z + (8 * COORDS_Z_STEP))
|
||||
{
|
||||
*rideSeatToView = 0x02;
|
||||
}
|
||||
|
@ -6556,9 +6556,9 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToV
|
|||
if (tileElement->IsGhost())
|
||||
continue;
|
||||
}
|
||||
if (tileElement->clearance_height + 1 < peep->next_z)
|
||||
if (tileElement->GetClearanceZ() + (1 * COORDS_Z_STEP) < peep->NextLoc.z)
|
||||
continue;
|
||||
if (peep->next_z + 6 < tileElement->base_height)
|
||||
if (peep->NextLoc.z + (6 * COORDS_Z_STEP) < tileElement->GetBaseZ())
|
||||
continue;
|
||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_SURFACE)
|
||||
continue;
|
||||
|
@ -6610,9 +6610,9 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToV
|
|||
auto wallEntry = tileElement->AsWall()->GetEntry();
|
||||
if (wallEntry == nullptr || (wallEntry->wall.flags2 & WALL_SCENERY_2_IS_OPAQUE))
|
||||
continue;
|
||||
if (peep->next_z + 6 <= tileElement->base_height)
|
||||
if (peep->NextLoc.z + (6 * COORDS_Z_STEP) <= tileElement->GetBaseZ())
|
||||
continue;
|
||||
if (peep->next_z >= tileElement->clearance_height)
|
||||
if (peep->NextLoc.z >= tileElement->GetClearanceZ())
|
||||
continue;
|
||||
|
||||
return false;
|
||||
|
@ -6629,9 +6629,9 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToV
|
|||
if (tileElement->IsGhost())
|
||||
continue;
|
||||
}
|
||||
if (tileElement->clearance_height + 1 < peep->next_z)
|
||||
if (tileElement->GetClearanceZ() + (1 * COORDS_Z_STEP) < peep->NextLoc.z)
|
||||
continue;
|
||||
if (peep->next_z + 8 < tileElement->base_height)
|
||||
if (peep->NextLoc.z + (8 * COORDS_Z_STEP) < tileElement->GetBaseZ())
|
||||
continue;
|
||||
|
||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_TRACK)
|
||||
|
@ -6651,7 +6651,7 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToV
|
|||
}
|
||||
|
||||
*rideSeatToView = 0;
|
||||
if (tileElement->clearance_height >= peep->next_z + 8)
|
||||
if (tileElement->GetClearanceZ() >= peep->NextLoc.z + (8 * COORDS_Z_STEP))
|
||||
{
|
||||
*rideSeatToView = 0x02;
|
||||
}
|
||||
|
@ -6673,9 +6673,9 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToV
|
|||
if (tileElement->IsGhost())
|
||||
continue;
|
||||
}
|
||||
if (tileElement->clearance_height + 1 < peep->next_z)
|
||||
if (tileElement->GetClearanceZ() + (1 * COORDS_Z_STEP) < peep->NextLoc.z)
|
||||
continue;
|
||||
if (peep->next_z + 8 < tileElement->base_height)
|
||||
if (peep->NextLoc.z + (8 * COORDS_Z_STEP) < tileElement->GetBaseZ())
|
||||
continue;
|
||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_SURFACE)
|
||||
continue;
|
||||
|
@ -6726,9 +6726,9 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToV
|
|||
auto wallEntry = tileElement->AsWall()->GetEntry();
|
||||
if (wallEntry == nullptr || (wallEntry->wall.flags2 & WALL_SCENERY_2_IS_OPAQUE))
|
||||
continue;
|
||||
if (peep->next_z + 8 <= tileElement->base_height)
|
||||
if (peep->NextLoc.z + (8 * COORDS_Z_STEP) <= tileElement->GetBaseZ())
|
||||
continue;
|
||||
if (peep->next_z >= tileElement->clearance_height)
|
||||
if (peep->NextLoc.z >= tileElement->GetClearanceZ())
|
||||
continue;
|
||||
|
||||
return false;
|
||||
|
@ -6745,9 +6745,9 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToV
|
|||
if (tileElement->IsGhost())
|
||||
continue;
|
||||
}
|
||||
if (tileElement->clearance_height + 1 < peep->next_z)
|
||||
if (tileElement->GetClearanceZ() + (1 * COORDS_Z_STEP) < peep->NextLoc.z)
|
||||
continue;
|
||||
if (peep->next_z + 10 < tileElement->base_height)
|
||||
if (peep->NextLoc.z + (10 * COORDS_Z_STEP) < tileElement->GetBaseZ())
|
||||
continue;
|
||||
|
||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_TRACK)
|
||||
|
@ -6766,7 +6766,7 @@ static bool peep_find_ride_to_look_at(Peep* peep, uint8_t edge, uint8_t* rideToV
|
|||
}
|
||||
|
||||
*rideSeatToView = 0;
|
||||
if (tileElement->clearance_height >= peep->next_z + 8)
|
||||
if (tileElement->GetClearanceZ() >= peep->NextLoc.z + (8 * COORDS_Z_STEP))
|
||||
{
|
||||
*rideSeatToView = 0x02;
|
||||
}
|
||||
|
|
|
@ -109,20 +109,17 @@ static int32_t path_get_permitted_edges(PathElement* pathElement)
|
|||
static int32_t peep_move_one_tile(Direction direction, Peep* peep)
|
||||
{
|
||||
assert(direction_valid(direction));
|
||||
int16_t x = peep->next_x;
|
||||
int16_t y = peep->next_y;
|
||||
x += CoordsDirectionDelta[direction].x;
|
||||
y += CoordsDirectionDelta[direction].y;
|
||||
auto newTile = CoordsXY{ CoordsXY{ peep->NextLoc } + CoordsDirectionDelta[direction] }.ToTileCentre();
|
||||
|
||||
if (x >= MAXIMUM_MAP_SIZE_BIG || y >= MAXIMUM_MAP_SIZE_BIG)
|
||||
if (newTile.x >= MAXIMUM_MAP_SIZE_BIG || newTile.y >= MAXIMUM_MAP_SIZE_BIG)
|
||||
{
|
||||
// This could loop!
|
||||
return guest_surface_path_finding(peep);
|
||||
}
|
||||
|
||||
peep->direction = direction;
|
||||
peep->destination_x = x + 16;
|
||||
peep->destination_y = y + 16;
|
||||
peep->destination_x = newTile.x;
|
||||
peep->destination_y = newTile.y;
|
||||
peep->destination_tolerance = 2;
|
||||
if (peep->state != PEEP_STATE_QUEUING)
|
||||
{
|
||||
|
@ -137,8 +134,7 @@ static int32_t peep_move_one_tile(Direction direction, Peep* peep)
|
|||
*/
|
||||
static int32_t guest_surface_path_finding(Peep* peep)
|
||||
{
|
||||
auto pathPos = CoordsXYRangedZ{ peep->next_x, peep->next_y, peep->next_z * COORDS_Z_STEP,
|
||||
(peep->next_z * COORDS_Z_STEP) + PATH_HEIGHT };
|
||||
auto pathPos = CoordsXYRangedZ{ peep->NextLoc, peep->NextLoc.z, peep->NextLoc.z + PATH_HEIGHT };
|
||||
Direction randDirection = scenario_rand() & 3;
|
||||
|
||||
if (!fence_in_the_way(pathPos, randDirection))
|
||||
|
@ -164,8 +160,8 @@ static int32_t guest_surface_path_finding(Peep* peep)
|
|||
}
|
||||
randDirection &= 3;
|
||||
|
||||
pathPos.x = peep->next_x;
|
||||
pathPos.y = peep->next_y;
|
||||
pathPos.x = peep->NextLoc.x;
|
||||
pathPos.y = peep->NextLoc.y;
|
||||
if (!fence_in_the_way(pathPos, randDirection))
|
||||
{
|
||||
pathPos.x += CoordsDirectionDelta[randDirection].x;
|
||||
|
@ -184,8 +180,8 @@ static int32_t guest_surface_path_finding(Peep* peep)
|
|||
randDirection -= 2;
|
||||
randDirection &= 3;
|
||||
|
||||
pathPos.x = peep->next_x;
|
||||
pathPos.y = peep->next_y;
|
||||
pathPos.x = peep->NextLoc.x;
|
||||
pathPos.y = peep->NextLoc.y;
|
||||
if (!fence_in_the_way(pathPos, randDirection))
|
||||
{
|
||||
pathPos.x += CoordsDirectionDelta[randDirection].x;
|
||||
|
@ -1409,7 +1405,7 @@ Direction peep_pathfind_choose_direction(TileCoordsXYZ loc, Peep* peep)
|
|||
/* Mechanics are the only staff type that
|
||||
* pathfind to a destination. Determine if the
|
||||
* mechanic is in their patrol area. */
|
||||
inPatrolArea = staff_is_location_in_patrol(peep, peep->next_x, peep->next_y);
|
||||
inPatrolArea = staff_is_location_in_patrol(peep, peep->NextLoc.x, peep->NextLoc.y);
|
||||
}
|
||||
|
||||
#if defined(DEBUG_LEVEL_2) && DEBUG_LEVEL_2
|
||||
|
@ -1569,7 +1565,7 @@ static uint8_t get_nearest_park_entrance_index(uint16_t x, uint16_t y)
|
|||
static int32_t guest_path_find_entering_park(Peep* peep, uint8_t edges)
|
||||
{
|
||||
// Send peeps to the nearest park entrance.
|
||||
uint8_t chosenEntrance = get_nearest_park_entrance_index(peep->next_x, peep->next_y);
|
||||
uint8_t chosenEntrance = get_nearest_park_entrance_index(peep->NextLoc.x, peep->NextLoc.y);
|
||||
|
||||
// If no defined park entrances are found, walk aimlessly.
|
||||
if (chosenEntrance == 0xFF)
|
||||
|
@ -1583,7 +1579,7 @@ static int32_t guest_path_find_entering_park(Peep* peep, uint8_t edges)
|
|||
gPeepPathFindIgnoreForeignQueues = true;
|
||||
gPeepPathFindQueueRideIndex = RIDE_ID_NULL;
|
||||
|
||||
Direction chosenDirection = peep_pathfind_choose_direction({ peep->next_x / 32, peep->next_y / 32, peep->next_z }, peep);
|
||||
Direction chosenDirection = peep_pathfind_choose_direction(TileCoordsXYZ{ peep->NextLoc }, peep);
|
||||
|
||||
if (chosenDirection == INVALID_DIRECTION)
|
||||
return guest_path_find_aimless(peep, edges);
|
||||
|
@ -1622,7 +1618,7 @@ static uint8_t get_nearest_peep_spawn_index(uint16_t x, uint16_t y)
|
|||
static int32_t guest_path_find_leaving_park(Peep* peep, uint8_t edges)
|
||||
{
|
||||
// Send peeps to the nearest spawn point.
|
||||
uint8_t chosenSpawn = get_nearest_peep_spawn_index(peep->next_x, peep->next_y);
|
||||
uint8_t chosenSpawn = get_nearest_peep_spawn_index(peep->NextLoc.x, peep->NextLoc.y);
|
||||
|
||||
// If no defined spawns were found, walk aimlessly.
|
||||
if (chosenSpawn == 0xFF)
|
||||
|
@ -1636,14 +1632,14 @@ static int32_t guest_path_find_leaving_park(Peep* peep, uint8_t edges)
|
|||
Direction direction = peepSpawn->direction;
|
||||
|
||||
gPeepPathFindGoalPosition = { x / 32, y / 32, z };
|
||||
if (x == peep->next_x && y == peep->next_y)
|
||||
if (x == peep->NextLoc.x && y == peep->NextLoc.y)
|
||||
{
|
||||
return peep_move_one_tile(direction, peep);
|
||||
}
|
||||
|
||||
gPeepPathFindIgnoreForeignQueues = true;
|
||||
gPeepPathFindQueueRideIndex = RIDE_ID_NULL;
|
||||
direction = peep_pathfind_choose_direction({ peep->next_x / 32, peep->next_y / 32, peep->next_z }, peep);
|
||||
direction = peep_pathfind_choose_direction(TileCoordsXYZ{ peep->NextLoc }, peep);
|
||||
if (direction == INVALID_DIRECTION)
|
||||
return guest_path_find_aimless(peep, edges);
|
||||
else
|
||||
|
@ -1670,7 +1666,7 @@ static int32_t guest_path_find_park_entrance(Peep* peep, uint8_t edges)
|
|||
uint8_t entranceNum = 0;
|
||||
for (const auto& entrance : gParkEntrances)
|
||||
{
|
||||
uint16_t dist = abs(entrance.x - peep->next_x) + abs(entrance.y - peep->next_y);
|
||||
uint16_t dist = abs(entrance.x - peep->NextLoc.x) + abs(entrance.y - peep->NextLoc.y);
|
||||
if (dist < nearestDist)
|
||||
{
|
||||
nearestDist = dist;
|
||||
|
@ -1699,7 +1695,7 @@ static int32_t guest_path_find_park_entrance(Peep* peep, uint8_t edges)
|
|||
pathfind_logging_enable(peep);
|
||||
#endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
|
||||
|
||||
Direction chosenDirection = peep_pathfind_choose_direction({ peep->next_x / 32, peep->next_y / 32, peep->next_z }, peep);
|
||||
Direction chosenDirection = peep_pathfind_choose_direction(TileCoordsXYZ{ peep->NextLoc }, peep);
|
||||
|
||||
#if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
|
||||
pathfind_logging_disable();
|
||||
|
@ -1875,7 +1871,7 @@ int32_t guest_path_finding(Guest* peep)
|
|||
return guest_surface_path_finding(peep);
|
||||
}
|
||||
|
||||
TileCoordsXYZ loc = { peep->next_x / 32, peep->next_y / 32, peep->next_z };
|
||||
TileCoordsXYZ loc{ peep->NextLoc };
|
||||
|
||||
auto* pathElement = map_get_path_element_at(loc);
|
||||
if (pathElement == nullptr)
|
||||
|
@ -2081,9 +2077,7 @@ int32_t guest_path_finding(Guest* peep)
|
|||
entranceStations |= (1 << stationNum);
|
||||
|
||||
TileCoordsXYZD entranceLocation = ride_get_entrance_location(ride, stationNum);
|
||||
auto score = CalculateHeuristicPathingScore(
|
||||
{ entranceLocation.x, entranceLocation.y, entranceLocation.z },
|
||||
{ peep->next_x / 32, peep->next_y / 32, peep->next_z });
|
||||
auto score = CalculateHeuristicPathingScore(entranceLocation, TileCoordsXYZ{ peep->NextLoc });
|
||||
if (score < bestScore)
|
||||
{
|
||||
bestScore = score;
|
||||
|
@ -2139,7 +2133,7 @@ int32_t guest_path_finding(Guest* peep)
|
|||
gPeepPathFindGoalPosition = loc;
|
||||
gPeepPathFindIgnoreForeignQueues = true;
|
||||
|
||||
direction = peep_pathfind_choose_direction({ peep->next_x / 32, peep->next_y / 32, peep->next_z }, peep);
|
||||
direction = peep_pathfind_choose_direction(TileCoordsXYZ{ peep->NextLoc }, peep);
|
||||
|
||||
if (direction == INVALID_DIRECTION)
|
||||
{
|
||||
|
|
|
@ -472,7 +472,7 @@ bool Peep::CheckForPath()
|
|||
return true;
|
||||
}
|
||||
|
||||
TileElement* tile_element = map_get_first_element_at({ next_x, next_y });
|
||||
TileElement* tile_element = map_get_first_element_at(NextLoc);
|
||||
|
||||
uint8_t map_type = TILE_ELEMENT_TYPE_PATH;
|
||||
if (GetNextIsSurface())
|
||||
|
@ -480,15 +480,13 @@ bool Peep::CheckForPath()
|
|||
map_type = TILE_ELEMENT_TYPE_SURFACE;
|
||||
}
|
||||
|
||||
int32_t height = next_z;
|
||||
|
||||
do
|
||||
{
|
||||
if (tile_element == nullptr)
|
||||
break;
|
||||
if (tile_element->GetType() == map_type)
|
||||
{
|
||||
if (height == tile_element->base_height)
|
||||
if (NextLoc.z == tile_element->GetBaseZ())
|
||||
{
|
||||
// Found a suitable path or surface
|
||||
return true;
|
||||
|
@ -977,9 +975,7 @@ void Peep::UpdateFalling()
|
|||
|
||||
MoveTo(x, y, saved_height);
|
||||
|
||||
next_x = x & 0xFFE0;
|
||||
next_y = y & 0xFFE0;
|
||||
next_z = saved_map->base_height;
|
||||
NextLoc = { CoordsXY{ x, y }.ToTileStart(), saved_map->GetBaseZ() };
|
||||
|
||||
if (saved_map->GetType() != TILE_ELEMENT_TYPE_PATH)
|
||||
{
|
||||
|
@ -2644,9 +2640,7 @@ static void peep_interact_with_entrance(Peep* peep, int16_t x, int16_t y, TileEl
|
|||
*/
|
||||
static void peep_footpath_move_forward(Peep* peep, int16_t x, int16_t y, TileElement* tile_element, bool vandalism)
|
||||
{
|
||||
peep->next_x = (x & 0xFFE0);
|
||||
peep->next_y = (y & 0xFFE0);
|
||||
peep->next_z = tile_element->base_height;
|
||||
peep->NextLoc = { CoordsXY{ x, y }.ToTileStart(), tile_element->GetBaseZ() };
|
||||
peep->SetNextFlags(tile_element->AsPath()->GetSlopeDirection(), tile_element->AsPath()->IsSloped(), false);
|
||||
|
||||
int16_t z = peep->GetZOnSlope(x, y);
|
||||
|
@ -2696,7 +2690,7 @@ static void peep_footpath_move_forward(Peep* peep, int16_t x, int16_t y, TileEle
|
|||
if (other_peep->state != PEEP_STATE_WALKING)
|
||||
continue;
|
||||
|
||||
if (abs(other_peep->z - peep->next_z * 8) > 16)
|
||||
if (abs(other_peep->z - peep->NextLoc.z) > 16)
|
||||
continue;
|
||||
crowded++;
|
||||
continue;
|
||||
|
@ -2704,7 +2698,7 @@ static void peep_footpath_move_forward(Peep* peep, int16_t x, int16_t y, TileEle
|
|||
else if (sprite->generic.sprite_identifier == SPRITE_IDENTIFIER_LITTER)
|
||||
{
|
||||
Litter* litter = (Litter*)sprite;
|
||||
if (abs(litter->z - peep->next_z * 8) > 16)
|
||||
if (abs(litter->z - peep->NextLoc.z) > 16)
|
||||
continue;
|
||||
|
||||
litter_count++;
|
||||
|
@ -3077,7 +3071,7 @@ void Peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result)
|
|||
|
||||
auto newLoc = *loc;
|
||||
CoordsXY truncatedNewLoc = newLoc.ToTileStart();
|
||||
if (truncatedNewLoc.x == next_x && truncatedNewLoc.y == next_y)
|
||||
if (truncatedNewLoc == CoordsXY{ NextLoc })
|
||||
{
|
||||
int16_t height = GetZOnSlope(newLoc.x, newLoc.y);
|
||||
MoveTo(newLoc.x, newLoc.y, height);
|
||||
|
@ -3174,9 +3168,7 @@ void Peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result)
|
|||
}
|
||||
|
||||
// The peep is on a surface and not on a path
|
||||
next_x = truncatedNewLoc.x;
|
||||
next_y = truncatedNewLoc.y;
|
||||
next_z = surfaceElement->base_height;
|
||||
NextLoc = { truncatedNewLoc, surfaceElement->GetBaseZ() };
|
||||
SetNextFlags(0, false, true);
|
||||
|
||||
height = GetZOnSlope(newLoc.x, newLoc.y);
|
||||
|
@ -3222,9 +3214,8 @@ int32_t Peep::GetZOnSlope(int32_t tile_x, int32_t tile_y)
|
|||
return tile_element_height({ tile_x, tile_y });
|
||||
}
|
||||
|
||||
int32_t height = next_z * 8;
|
||||
uint8_t slope = GetNextDirection();
|
||||
return height + map_height_from_slope({ tile_x, tile_y }, slope, GetNextIsSloped());
|
||||
return NextLoc.z + map_height_from_slope({ tile_x, tile_y }, slope, GetNextIsSloped());
|
||||
}
|
||||
|
||||
rct_string_id get_real_name_string_id_from_id(uint32_t id)
|
||||
|
|
|
@ -543,9 +543,7 @@ struct Staff;
|
|||
struct Peep : SpriteBase
|
||||
{
|
||||
char* name;
|
||||
uint16_t next_x;
|
||||
uint16_t next_y;
|
||||
uint8_t next_z;
|
||||
CoordsXYZ NextLoc;
|
||||
uint8_t next_flags;
|
||||
uint8_t outside_of_park;
|
||||
PeepState state;
|
||||
|
@ -860,7 +858,7 @@ private:
|
|||
void UpdateHeadingToInspect();
|
||||
};
|
||||
|
||||
static_assert(sizeof(Peep) <= 256);
|
||||
static_assert(sizeof(Peep) <= 512);
|
||||
|
||||
struct rct_sprite_bounds
|
||||
{
|
||||
|
|
|
@ -535,11 +535,11 @@ static uint8_t staff_handyman_direction_to_uncut_grass(Peep* peep, uint8_t valid
|
|||
{
|
||||
if (!(peep->GetNextIsSurface()))
|
||||
{
|
||||
auto surfaceElement = map_get_surface_element_at(CoordsXY{ peep->next_x, peep->next_y });
|
||||
auto surfaceElement = map_get_surface_element_at(peep->NextLoc);
|
||||
if (surfaceElement == nullptr)
|
||||
return INVALID_DIRECTION;
|
||||
|
||||
if (peep->next_z != surfaceElement->base_height)
|
||||
if (peep->NextLoc.z != surfaceElement->GetBaseZ())
|
||||
return INVALID_DIRECTION;
|
||||
|
||||
if (peep->GetNextIsSloped())
|
||||
|
@ -561,8 +561,7 @@ static uint8_t staff_handyman_direction_to_uncut_grass(Peep* peep, uint8_t valid
|
|||
continue;
|
||||
}
|
||||
|
||||
CoordsXY chosenTile = { static_cast<int32_t>(peep->next_x + CoordsDirectionDelta[chosenDirection].x),
|
||||
static_cast<int32_t>(peep->next_y + CoordsDirectionDelta[chosenDirection].y) };
|
||||
CoordsXY chosenTile = CoordsXY{ peep->NextLoc } + CoordsDirectionDelta[chosenDirection];
|
||||
|
||||
if (chosenTile.x > 0x1FFF || chosenTile.y > 0x1FFF)
|
||||
continue;
|
||||
|
@ -570,7 +569,7 @@ static uint8_t staff_handyman_direction_to_uncut_grass(Peep* peep, uint8_t valid
|
|||
auto surfaceElement = map_get_surface_element_at(chosenTile);
|
||||
if (surfaceElement != nullptr)
|
||||
{
|
||||
if (std::abs(surfaceElement->base_height - peep->next_z) <= 2)
|
||||
if (std::abs(surfaceElement->GetBaseZ() - peep->NextLoc.z) <= 2 * COORDS_Z_STEP)
|
||||
{
|
||||
if (surfaceElement->CanGrassGrow() && (surfaceElement->GetGrassLength() & 0x7) >= GRASS_LENGTH_CLEAR_1)
|
||||
{
|
||||
|
@ -595,8 +594,7 @@ static int32_t staff_handyman_direction_rand_surface(Peep* peep, uint8_t validDi
|
|||
if (!(validDirections & (1 << direction)))
|
||||
continue;
|
||||
|
||||
CoordsXY chosenTile = { peep->next_x + CoordsDirectionDelta[direction].x,
|
||||
peep->next_y + CoordsDirectionDelta[direction].y };
|
||||
CoordsXY chosenTile = CoordsXY{ peep->NextLoc } + CoordsDirectionDelta[direction];
|
||||
|
||||
if (map_surface_is_blocked(chosenTile))
|
||||
continue;
|
||||
|
@ -619,7 +617,7 @@ static bool staff_path_finding_handyman(Peep* peep)
|
|||
peep->staff_mowing_timeout++;
|
||||
|
||||
uint8_t litterDirection = 0xFF;
|
||||
uint8_t validDirections = staff_get_valid_patrol_directions(peep, peep->next_x, peep->next_y);
|
||||
uint8_t validDirections = staff_get_valid_patrol_directions(peep, peep->NextLoc.x, peep->NextLoc.y);
|
||||
|
||||
if ((peep->staff_orders & STAFF_ORDERS_SWEEPING) && ((gCurrentTicks + peep->sprite_index) & 0xFFF) > 110)
|
||||
{
|
||||
|
@ -640,7 +638,7 @@ static bool staff_path_finding_handyman(Peep* peep)
|
|||
}
|
||||
else
|
||||
{
|
||||
auto* pathElement = map_get_path_element_at({ peep->next_x / 32, peep->next_y / 32, peep->next_z });
|
||||
auto* pathElement = map_get_path_element_at(TileCoordsXYZ{ peep->NextLoc });
|
||||
|
||||
if (pathElement == nullptr)
|
||||
return true;
|
||||
|
@ -684,14 +682,12 @@ static bool staff_path_finding_handyman(Peep* peep)
|
|||
// countof(CoordsDirectionDelta)
|
||||
assert(direction < 8);
|
||||
|
||||
CoordsXY chosenTile = { peep->next_x + CoordsDirectionDelta[direction].x,
|
||||
peep->next_y + CoordsDirectionDelta[direction].y };
|
||||
CoordsXY chosenTile = CoordsXY{ peep->NextLoc } + CoordsDirectionDelta[direction];
|
||||
|
||||
while (chosenTile.x > 0x1FFF || chosenTile.y > 0x1FFF)
|
||||
{
|
||||
direction = staff_handyman_direction_rand_surface(peep, validDirections);
|
||||
chosenTile.x = peep->next_x + CoordsDirectionDelta[direction].x;
|
||||
chosenTile.y = peep->next_y + CoordsDirectionDelta[direction].y;
|
||||
chosenTile = CoordsXY{ peep->NextLoc } + CoordsDirectionDelta[direction];
|
||||
}
|
||||
|
||||
peep->direction = direction;
|
||||
|
@ -727,20 +723,14 @@ static uint8_t staff_direction_surface(Peep* peep, uint8_t initialDirection)
|
|||
|
||||
direction &= 3;
|
||||
|
||||
if (fence_in_the_way(
|
||||
{ peep->next_x, peep->next_y, peep->next_z * COORDS_Z_STEP,
|
||||
(peep->next_z * COORDS_Z_STEP) + PEEP_CLEARANCE_HEIGHT },
|
||||
direction))
|
||||
if (fence_in_the_way({ peep->NextLoc, peep->NextLoc.z, peep->NextLoc.z + PEEP_CLEARANCE_HEIGHT }, direction))
|
||||
continue;
|
||||
|
||||
if (fence_in_the_way(
|
||||
{ peep->next_x, peep->next_y, peep->next_z * COORDS_Z_STEP,
|
||||
(peep->next_z * COORDS_Z_STEP) + PEEP_CLEARANCE_HEIGHT },
|
||||
direction_reverse(direction)))
|
||||
{ peep->NextLoc, peep->NextLoc.z, peep->NextLoc.z + PEEP_CLEARANCE_HEIGHT }, direction_reverse(direction)))
|
||||
continue;
|
||||
|
||||
CoordsXY chosenTile = { peep->next_x + CoordsDirectionDelta[direction].x,
|
||||
peep->next_y + CoordsDirectionDelta[direction].y };
|
||||
CoordsXY chosenTile = CoordsXY{ peep->NextLoc } + CoordsDirectionDelta[direction];
|
||||
|
||||
if (!map_surface_is_blocked(chosenTile))
|
||||
{
|
||||
|
@ -879,8 +869,7 @@ static uint8_t staff_mechanic_direction_path(Peep* peep, uint8_t validDirections
|
|||
pathfind_logging_enable(peep);
|
||||
#endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
|
||||
|
||||
Direction pathfindDirection = peep_pathfind_choose_direction(
|
||||
{ peep->next_x / 32, peep->next_y / 32, peep->next_z }, peep);
|
||||
Direction pathfindDirection = peep_pathfind_choose_direction(TileCoordsXYZ{ peep->NextLoc }, peep);
|
||||
|
||||
#if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1
|
||||
pathfind_logging_disable();
|
||||
|
@ -909,7 +898,7 @@ static uint8_t staff_mechanic_direction_path(Peep* peep, uint8_t validDirections
|
|||
*/
|
||||
static bool staff_path_finding_mechanic(Peep* peep)
|
||||
{
|
||||
uint8_t validDirections = staff_get_valid_patrol_directions(peep, peep->next_x, peep->next_y);
|
||||
uint8_t validDirections = staff_get_valid_patrol_directions(peep, peep->NextLoc.x, peep->NextLoc.y);
|
||||
Direction direction = INVALID_DIRECTION;
|
||||
if (peep->GetNextIsSurface())
|
||||
{
|
||||
|
@ -917,7 +906,7 @@ static bool staff_path_finding_mechanic(Peep* peep)
|
|||
}
|
||||
else
|
||||
{
|
||||
auto* pathElement = map_get_path_element_at({ peep->next_x / 32, peep->next_y / 32, peep->next_z });
|
||||
auto* pathElement = map_get_path_element_at(TileCoordsXYZ{ peep->NextLoc });
|
||||
if (pathElement == nullptr)
|
||||
return true;
|
||||
|
||||
|
@ -927,14 +916,12 @@ static bool staff_path_finding_mechanic(Peep* peep)
|
|||
// countof(CoordsDirectionDelta)
|
||||
assert(direction < 8);
|
||||
|
||||
CoordsXY chosenTile = { peep->next_x + CoordsDirectionDelta[direction].x,
|
||||
peep->next_y + CoordsDirectionDelta[direction].y };
|
||||
CoordsXY chosenTile = CoordsXY{ peep->NextLoc } + CoordsDirectionDelta[direction];
|
||||
|
||||
while (chosenTile.x > 0x1FFF || chosenTile.y > 0x1FFF)
|
||||
{
|
||||
direction = staff_mechanic_direction_surface(peep);
|
||||
chosenTile.x = peep->next_x + CoordsDirectionDelta[direction].x;
|
||||
chosenTile.y = peep->next_y + CoordsDirectionDelta[direction].y;
|
||||
chosenTile = CoordsXY{ peep->NextLoc } + CoordsDirectionDelta[direction];
|
||||
}
|
||||
|
||||
peep->direction = direction;
|
||||
|
@ -996,7 +983,7 @@ static uint8_t staff_direction_path(Peep* peep, uint8_t validDirections, PathEle
|
|||
*/
|
||||
static bool staff_path_finding_misc(Peep* peep)
|
||||
{
|
||||
uint8_t validDirections = staff_get_valid_patrol_directions(peep, peep->next_x, peep->next_y);
|
||||
uint8_t validDirections = staff_get_valid_patrol_directions(peep, peep->NextLoc.x, peep->NextLoc.y);
|
||||
|
||||
Direction direction = INVALID_DIRECTION;
|
||||
if (peep->GetNextIsSurface())
|
||||
|
@ -1005,21 +992,19 @@ static bool staff_path_finding_misc(Peep* peep)
|
|||
}
|
||||
else
|
||||
{
|
||||
auto* pathElement = map_get_path_element_at({ peep->next_x / 32, peep->next_y / 32, peep->next_z });
|
||||
auto* pathElement = map_get_path_element_at(TileCoordsXYZ{ peep->NextLoc });
|
||||
if (pathElement == nullptr)
|
||||
return true;
|
||||
|
||||
direction = staff_direction_path(peep, validDirections, pathElement);
|
||||
}
|
||||
|
||||
CoordsXY chosenTile = { peep->next_x + CoordsDirectionDelta[direction].x,
|
||||
peep->next_y + CoordsDirectionDelta[direction].y };
|
||||
CoordsXY chosenTile = CoordsXY{ peep->NextLoc } + CoordsDirectionDelta[direction];
|
||||
|
||||
while (chosenTile.x > 0x1FFF || chosenTile.y > 0x1FFF)
|
||||
{
|
||||
direction = staff_direction_surface(peep, scenario_rand() & 3);
|
||||
chosenTile.x = peep->next_x + CoordsDirectionDelta[direction].x;
|
||||
chosenTile.y = peep->next_y + CoordsDirectionDelta[direction].y;
|
||||
chosenTile = CoordsXY{ peep->NextLoc } + CoordsDirectionDelta[direction];
|
||||
}
|
||||
|
||||
peep->direction = direction;
|
||||
|
@ -1227,17 +1212,17 @@ void Staff::UpdateMowing()
|
|||
return;
|
||||
}
|
||||
|
||||
destination_x = _MowingWaypoints[var_37].x + next_x;
|
||||
destination_y = _MowingWaypoints[var_37].y + next_y;
|
||||
destination_x = _MowingWaypoints[var_37].x + NextLoc.x;
|
||||
destination_y = _MowingWaypoints[var_37].y + NextLoc.y;
|
||||
|
||||
if (var_37 != 7)
|
||||
continue;
|
||||
|
||||
auto surfaceElement = map_get_surface_element_at(CoordsXY{ next_x, next_y });
|
||||
auto surfaceElement = map_get_surface_element_at(NextLoc);
|
||||
if (surfaceElement != nullptr && surfaceElement->CanGrassGrow())
|
||||
{
|
||||
surfaceElement->SetGrassLength(GRASS_LENGTH_MOWED);
|
||||
map_invalidate_tile_zoom0({ next_x, next_y, surfaceElement->GetBaseZ(), surfaceElement->GetBaseZ() + 16 });
|
||||
map_invalidate_tile_zoom0({ NextLoc, surfaceElement->GetBaseZ(), surfaceElement->GetBaseZ() + 16 });
|
||||
}
|
||||
staff_lawns_mown++;
|
||||
window_invalidate_flags |= PEEP_INVALIDATE_STAFF_STATS;
|
||||
|
@ -1278,10 +1263,9 @@ void Staff::UpdateWatering()
|
|||
return;
|
||||
}
|
||||
|
||||
int32_t actionX = next_x + CoordsDirectionDelta[var_37].x;
|
||||
int32_t actionY = next_y + CoordsDirectionDelta[var_37].y;
|
||||
auto actionLoc = CoordsXY{ NextLoc } + CoordsDirectionDelta[var_37];
|
||||
|
||||
TileElement* tile_element = map_get_first_element_at({ actionX, actionY });
|
||||
TileElement* tile_element = map_get_first_element_at(actionLoc);
|
||||
if (tile_element == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -1290,7 +1274,7 @@ void Staff::UpdateWatering()
|
|||
if (tile_element->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY)
|
||||
continue;
|
||||
|
||||
if (abs(((int32_t)next_z) - tile_element->base_height) > 4)
|
||||
if (abs(NextLoc.z - tile_element->GetBaseZ()) > 4 * COORDS_Z_STEP)
|
||||
continue;
|
||||
|
||||
rct_scenery_entry* scenery_entry = tile_element->AsSmallScenery()->GetEntry();
|
||||
|
@ -1299,7 +1283,7 @@ void Staff::UpdateWatering()
|
|||
continue;
|
||||
|
||||
tile_element->AsSmallScenery()->SetAge(0);
|
||||
map_invalidate_tile_zoom0({ actionX, actionY, tile_element->GetBaseZ(), tile_element->GetClearanceZ() });
|
||||
map_invalidate_tile_zoom0({ actionLoc, tile_element->GetBaseZ(), tile_element->GetClearanceZ() });
|
||||
staff_gardens_watered++;
|
||||
window_invalidate_flags |= PEEP_INVALIDATE_STAFF_STATS;
|
||||
} while (!(tile_element++)->IsLastForTile());
|
||||
|
@ -1348,7 +1332,7 @@ void Staff::UpdateEmptyingBin()
|
|||
if (action_frame != 11)
|
||||
return;
|
||||
|
||||
TileElement* tile_element = map_get_first_element_at({ next_x, next_y });
|
||||
TileElement* tile_element = map_get_first_element_at(NextLoc);
|
||||
if (tile_element == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -1356,7 +1340,7 @@ void Staff::UpdateEmptyingBin()
|
|||
{
|
||||
if (tile_element->GetType() == TILE_ELEMENT_TYPE_PATH)
|
||||
{
|
||||
if (next_z == tile_element->base_height)
|
||||
if (NextLoc.z == tile_element->GetBaseZ())
|
||||
break;
|
||||
}
|
||||
if ((tile_element)->IsLastForTile())
|
||||
|
@ -1383,7 +1367,7 @@ void Staff::UpdateEmptyingBin()
|
|||
uint8_t additionStatus = tile_element->AsPath()->GetAdditionStatus() | ((3 << var_37) << var_37);
|
||||
tile_element->AsPath()->SetAdditionStatus(additionStatus);
|
||||
|
||||
map_invalidate_tile_zoom0({ next_x, next_y, tile_element->GetBaseZ(), tile_element->GetClearanceZ() });
|
||||
map_invalidate_tile_zoom0({ NextLoc, tile_element->GetBaseZ(), tile_element->GetClearanceZ() });
|
||||
staff_bins_emptied++;
|
||||
window_invalidate_flags |= PEEP_INVALIDATE_STAFF_STATS;
|
||||
}
|
||||
|
@ -1501,8 +1485,8 @@ void Staff::UpdateHeadingToInspect()
|
|||
|
||||
direction = rideEntranceExitElement->GetDirection();
|
||||
|
||||
int32_t destX = next_x + 16 + DirectionOffsets[direction].x * 53;
|
||||
int32_t destY = next_y + 16 + DirectionOffsets[direction].y * 53;
|
||||
int32_t destX = NextLoc.x + 16 + DirectionOffsets[direction].x * 53;
|
||||
int32_t destY = NextLoc.y + 16 + DirectionOffsets[direction].y * 53;
|
||||
|
||||
destination_x = destX;
|
||||
destination_y = destY;
|
||||
|
@ -1612,8 +1596,8 @@ void Staff::UpdateAnswering()
|
|||
|
||||
direction = rideEntranceExitElement->GetDirection();
|
||||
|
||||
int32_t destX = next_x + 16 + DirectionOffsets[direction].x * 53;
|
||||
int32_t destY = next_y + 16 + DirectionOffsets[direction].y * 53;
|
||||
int32_t destX = NextLoc.x + 16 + DirectionOffsets[direction].x * 53;
|
||||
int32_t destY = NextLoc.y + 16 + DirectionOffsets[direction].y * 53;
|
||||
|
||||
destination_x = destX;
|
||||
destination_y = destY;
|
||||
|
@ -1662,10 +1646,9 @@ static int32_t peep_update_patrolling_find_watering(Peep* peep)
|
|||
{
|
||||
chosen_position &= 7;
|
||||
|
||||
int32_t x = peep->next_x + CoordsDirectionDelta[chosen_position].x;
|
||||
int32_t y = peep->next_y + CoordsDirectionDelta[chosen_position].y;
|
||||
auto chosenLoc = CoordsXY{ peep->NextLoc } + CoordsDirectionDelta[chosen_position];
|
||||
|
||||
TileElement* tile_element = map_get_first_element_at({ x, y });
|
||||
TileElement* tile_element = map_get_first_element_at(chosenLoc);
|
||||
|
||||
// This seems to happen in some SV4 files.
|
||||
if (tile_element == nullptr)
|
||||
|
@ -1680,9 +1663,9 @@ static int32_t peep_update_patrolling_find_watering(Peep* peep)
|
|||
continue;
|
||||
}
|
||||
|
||||
uint8_t z_diff = abs(peep->next_z - tile_element->base_height);
|
||||
uint8_t z_diff = abs(peep->NextLoc.z - tile_element->GetBaseZ());
|
||||
|
||||
if (z_diff >= 4)
|
||||
if (z_diff >= 4 * COORDS_Z_STEP)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -1733,13 +1716,13 @@ static int32_t peep_update_patrolling_find_bin(Peep* peep)
|
|||
if (peep->GetNextIsSurface())
|
||||
return 0;
|
||||
|
||||
TileElement* tileElement = map_get_first_element_at({ peep->next_x, peep->next_y });
|
||||
TileElement* tileElement = map_get_first_element_at(peep->NextLoc);
|
||||
if (tileElement == nullptr)
|
||||
return 0;
|
||||
|
||||
for (;; tileElement++)
|
||||
{
|
||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH && (tileElement->base_height == peep->next_z))
|
||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH && (tileElement->GetBaseZ() == peep->NextLoc.z))
|
||||
break;
|
||||
|
||||
if (tileElement->IsLastForTile())
|
||||
|
@ -1801,7 +1784,7 @@ static int32_t peep_update_patrolling_find_grass(Peep* peep)
|
|||
if (!(peep->GetNextIsSurface()))
|
||||
return 0;
|
||||
|
||||
auto surfaceElement = map_get_surface_element_at(CoordsXY{ peep->next_x, peep->next_y });
|
||||
auto surfaceElement = map_get_surface_element_at(peep->NextLoc);
|
||||
if (surfaceElement != nullptr && surfaceElement->CanGrassGrow())
|
||||
{
|
||||
if ((surfaceElement->GetGrassLength() & 0x7) >= GRASS_LENGTH_CLEAR_1)
|
||||
|
@ -1809,8 +1792,8 @@ static int32_t peep_update_patrolling_find_grass(Peep* peep)
|
|||
peep->SetState(PEEP_STATE_MOWING);
|
||||
peep->var_37 = 0;
|
||||
// Original code used .y for both x and y. Changed to .x to make more sense (both x and y are 28)
|
||||
peep->destination_x = peep->next_x + _MowingWaypoints[0].x;
|
||||
peep->destination_y = peep->next_y + _MowingWaypoints[0].y;
|
||||
peep->destination_x = peep->NextLoc.x + _MowingWaypoints[0].x;
|
||||
peep->destination_y = peep->NextLoc.y + _MowingWaypoints[0].y;
|
||||
peep->destination_tolerance = 3;
|
||||
return 1;
|
||||
}
|
||||
|
@ -1939,7 +1922,7 @@ void Staff::UpdatePatrolling()
|
|||
|
||||
if (GetNextIsSurface())
|
||||
{
|
||||
auto surfaceElement = map_get_surface_element_at(CoordsXY{ next_x, next_y });
|
||||
auto surfaceElement = map_get_surface_element_at(NextLoc);
|
||||
|
||||
if (surfaceElement != nullptr)
|
||||
{
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#define RCT1_RESEARCH_FLAGS_SEPARATOR 0xFF
|
||||
#define RCT1_MAX_ANIMATED_OBJECTS 1000
|
||||
#define RCT1_MAX_BANNERS 100
|
||||
constexpr int32_t RCT1_COORDS_Z_STEP = 4;
|
||||
|
||||
struct ParkLoadResult;
|
||||
|
||||
|
|
|
@ -1406,9 +1406,7 @@ private:
|
|||
|
||||
dst->state = static_cast<PeepState>(src->state);
|
||||
dst->sub_state = src->sub_state;
|
||||
dst->next_x = src->next_x;
|
||||
dst->next_y = src->next_y;
|
||||
dst->next_z = src->next_z / 2;
|
||||
dst->NextLoc = { src->next_x, src->next_y, src->next_z * RCT1_COORDS_Z_STEP };
|
||||
dst->next_flags = src->next_flags;
|
||||
dst->var_37 = src->var_37;
|
||||
dst->time_to_consume = src->time_to_consume;
|
||||
|
|
|
@ -1102,9 +1102,9 @@ void S6Exporter::ExportSpritePeep(RCT2SpritePeep* dst, const Peep* src)
|
|||
}
|
||||
}
|
||||
|
||||
dst->next_x = src->next_x;
|
||||
dst->next_y = src->next_y;
|
||||
dst->next_z = src->next_z;
|
||||
dst->next_x = src->NextLoc.x;
|
||||
dst->next_y = src->NextLoc.y;
|
||||
dst->next_z = src->NextLoc.z / COORDS_Z_STEP;
|
||||
dst->next_flags = src->next_flags;
|
||||
dst->outside_of_park = src->outside_of_park;
|
||||
dst->state = (uint8_t)src->state;
|
||||
|
|
|
@ -1271,7 +1271,7 @@ public:
|
|||
|
||||
void ImportSprite(rct_sprite* dst, const RCT2Sprite* src)
|
||||
{
|
||||
std::memset(dst, 0, sizeof(rct_sprite));
|
||||
std::memset(&dst->pad_00, 0, sizeof(rct_sprite));
|
||||
switch (src->unknown.sprite_identifier)
|
||||
{
|
||||
case SPRITE_IDENTIFIER_NULL:
|
||||
|
@ -1378,9 +1378,7 @@ public:
|
|||
{
|
||||
dst->SetName(GetUserString(src->name_string_idx));
|
||||
}
|
||||
dst->next_x = src->next_x;
|
||||
dst->next_y = src->next_y;
|
||||
dst->next_z = src->next_z;
|
||||
dst->NextLoc = { src->next_x, src->next_y, src->next_z * COORDS_Z_STEP };
|
||||
dst->next_flags = src->next_flags;
|
||||
dst->outside_of_park = src->outside_of_park;
|
||||
dst->state = (PeepState)src->state;
|
||||
|
|
|
@ -1132,13 +1132,11 @@ void ride_remove_peeps(Ride* ride)
|
|||
|
||||
if (exitDirection == 255)
|
||||
{
|
||||
int32_t x = peep->next_x + 16;
|
||||
int32_t y = peep->next_y + 16;
|
||||
int32_t z = peep->next_z * 8;
|
||||
CoordsXYZ newLoc = { peep->NextLoc.ToTileCentre(), peep->NextLoc.z };
|
||||
if (peep->GetNextIsSloped())
|
||||
z += 8;
|
||||
z++;
|
||||
sprite_move(x, y, z, peep);
|
||||
newLoc.z += COORDS_Z_STEP;
|
||||
newLoc.z++;
|
||||
sprite_move(newLoc.x, newLoc.y, newLoc.z, peep);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -145,6 +145,16 @@ struct CoordsXY
|
|||
return rotatedCoords;
|
||||
}
|
||||
|
||||
bool operator==(const CoordsXY& other) const
|
||||
{
|
||||
return x == other.x && y == other.y;
|
||||
}
|
||||
|
||||
bool operator!=(const CoordsXY& other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
CoordsXY ToTileCentre() const
|
||||
{
|
||||
return ToTileStart() + CoordsXY{ 16, 16 };
|
||||
|
|
|
@ -137,6 +137,11 @@ union rct_sprite
|
|||
Duck* AsDuck();
|
||||
MoneyEffect* AsMoneyEffect();
|
||||
Peep* AsPeep();
|
||||
// Default constructor to prevent non trivial construction issues
|
||||
rct_sprite()
|
||||
: pad_00()
|
||||
{
|
||||
}
|
||||
};
|
||||
assert_struct_size(rct_sprite, 0x200);
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ protected:
|
|||
|
||||
// Check that the peep is still on a footpath. Use next_z instead of pos->z here because pos->z will change
|
||||
// when the peep is halfway up a slope, but next_z will not change until they move to the next tile.
|
||||
EXPECT_NE(map_get_footpath_element(TileCoordsXYZ{ pos->x, pos->y, peep->next_z }.ToCoordsXYZ()), nullptr);
|
||||
EXPECT_NE(map_get_footpath_element({ pos->ToCoordsXY(), peep->NextLoc.z }), nullptr);
|
||||
}
|
||||
|
||||
// Clean up the peep, because we're reusing this loaded context for all tests.
|
||||
|
|
|
@ -155,9 +155,9 @@ static void CompareSpriteDataCommon(const SpriteBase& left, const SpriteBase& ri
|
|||
|
||||
static void CompareSpriteDataPeep(const Peep& left, const Peep& right)
|
||||
{
|
||||
COMPARE_FIELD(next_x);
|
||||
COMPARE_FIELD(next_y);
|
||||
COMPARE_FIELD(next_z);
|
||||
COMPARE_FIELD(NextLoc.x);
|
||||
COMPARE_FIELD(NextLoc.y);
|
||||
COMPARE_FIELD(NextLoc.z);
|
||||
COMPARE_FIELD(next_flags);
|
||||
COMPARE_FIELD(outside_of_park);
|
||||
COMPARE_FIELD(state);
|
||||
|
|
Loading…
Reference in New Issue