Use TileCoordXYZ for location argument

This commit is contained in:
Hielke Morsink 2018-04-27 14:31:18 +02:00 committed by duncanspumpkin
parent 278f67e627
commit 64932cbacf
2 changed files with 13 additions and 17 deletions

View File

@ -788,38 +788,34 @@ void rct_peep::PickupAbort(sint32 old_x)
gPickupPeepImage = UINT32_MAX;
}
bool rct_peep::Place(sint32 posX, sint32 posY, sint32 posZ, bool apply)
// Returns true when a peep can be dropped at the given location. When apply is set to true the peep gets dropped.
bool rct_peep::Place(TileCoordsXYZ location, bool apply)
{
rct_tile_element * tileElement = map_get_path_element_at(posX / 32, posY / 32, posZ);
rct_tile_element * tileElement = map_get_path_element_at(location.x, location.y, location.z);
if (!tileElement)
{
tileElement = map_get_surface_element_at({ posX, posY });
tileElement = map_get_surface_element_at(location.x, location.y);
}
if (!tileElement)
return false;
sint32 dest_x = posX & 0xFFE0;
sint32 dest_y = posY & 0xFFE0;
CoordsXYZ destination = { location.x * 32, location.y * 32, location.z * 8 };
// Set the coordinate of destination to be exactly
// in the middle of a tile.
dest_x += 16;
dest_y += 16;
// Set the tile coordinate to top left of tile
sint32 tile_y = dest_y & 0xFFE0;
sint32 tile_x = dest_x & 0xFFE0;
destination.x += 16;
destination.y += 16;
destination.z = tileElement->base_height * 8 + 16;
sint32 dest_z = tileElement->base_height * 8 + 16;
if (!map_is_location_owned(tile_x, tile_y, dest_z))
if (!map_is_location_owned(location.x * 32, location.y * 32, destination.z))
{
gGameCommandErrorTitle = STR_ERR_CANT_PLACE_PERSON_HERE;
return false;
}
if (!map_can_construct_at(tile_x, tile_y, dest_z / 8, (dest_z / 8) + 1, 15))
if (!map_can_construct_at(destination.x, destination.y, destination.z / 8, (destination.z / 8) + 1, 15))
{
if (gGameCommandErrorText != STR_RAISE_OR_LOWER_LAND_FIRST)
{
@ -833,7 +829,7 @@ bool rct_peep::Place(sint32 posX, sint32 posY, sint32 posZ, bool apply)
if (apply)
{
sprite_move(dest_x, dest_y, dest_z, (rct_sprite *)this);
sprite_move(destination.x, destination.y, destination.z, (rct_sprite *)this);
Invalidate();
SetState(PEEP_STATE_FALLING);
action = 0xFF;
@ -922,7 +918,7 @@ bool peep_pickup_command(uint32 peepnum, sint32 x, sint32 y, sint32 z, sint32 ac
return false;
}
if (!peep->Place(x, y, z, apply))
if (!peep->Place({ x / 32, y / 32, z }, apply))
{
return false;
}

View File

@ -716,7 +716,7 @@ public: // Peep
void SetNextFlags(uint8 next_direction, bool is_sloped, bool is_surface);
void Pickup();
void PickupAbort(sint32 old_x);
bool Place(sint32 x, sint32 y, sint32 z, bool apply);
bool Place(TileCoordsXYZ location, bool apply);
public: // Guest
void Tick128UpdateGuest(sint32 index);
void RemoveFromQueue();