Replace some usages of LocationXY(Z)16 (#10699)

This commit is contained in:
Michael Steenbeek authored and GitHub committed 2020-02-18 22:42:38 +01:00
1 parent a8b5304786
commit f41f878581
11 files changed
+83 -99

No files matched your search

+15 -28
View File
@@ -2487,13 +2487,11 @@ static money32 try_place_ghost_scenery(
if (res->Error != GA_ERROR::OK)
return MONEY32_UNDEFINED;
gSceneryGhostPosition.x = map_tile.x;
gSceneryGhostPosition.y = map_tile.y;
gSceneryPlaceRotation = (uint16_t)(parameter_3 & 0xFF);
gSceneryPlaceObject = selected_tab;
tileElement = dynamic_cast<SmallSceneryPlaceActionResult*>(res.get())->tileElement;
gSceneryGhostPosition.z = tileElement->base_height;
gSceneryGhostPosition = { map_tile, tileElement->GetBaseZ() };
gSceneryQuadrant = tileElement->AsSmallScenery()->GetSceneryQuadrant();
if (dynamic_cast<SmallSceneryPlaceActionResult*>(res.get())->GroundFlags & ELEMENT_IS_UNDERGROUND)
{
@@ -2523,10 +2521,7 @@ static money32 try_place_ghost_scenery(
{
return;
}
gSceneryGhostPosition.x = map_tile.x;
gSceneryGhostPosition.y = map_tile.y;
gSceneryGhostPosition.z = (parameter_2 & 0xFF);
gSceneryGhostPosition = { map_tile, static_cast<int32_t>((parameter_2 & 0xFF) * COORDS_Z_STEP) };
gSceneryGhostType |= SCENERY_GHOST_FLAG_1;
});
auto res = GameActions::Execute(&footpathSceneryPlaceAction);
@@ -2551,10 +2546,8 @@ static money32 try_place_ghost_scenery(
if (result->Error != GA_ERROR::OK)
return;
gSceneryGhostPosition.x = map_tile.x;
gSceneryGhostPosition.y = map_tile.y;
gSceneryGhostPosition = { map_tile, result->tileElement->GetBaseZ() };
gSceneryGhostWallRotation = edges;
gSceneryGhostPosition.z = result->tileElement->base_height;
gSceneryGhostType |= SCENERY_GHOST_FLAG_2;
});
@@ -2582,12 +2575,10 @@ static money32 try_place_ghost_scenery(
if (res->Error != GA_ERROR::OK)
return MONEY32_UNDEFINED;
gSceneryGhostPosition.x = map_tile.x;
gSceneryGhostPosition.y = map_tile.y;
gSceneryPlaceRotation = loc.direction;
tileElement = dynamic_cast<LargeSceneryPlaceActionResult*>(res.get())->tileElement;
gSceneryGhostPosition.z = tileElement->base_height;
gSceneryGhostPosition = { map_tile, tileElement->GetBaseZ() };
if (dynamic_cast<LargeSceneryPlaceActionResult*>(res.get())->GroundFlags & ELEMENT_IS_UNDERGROUND)
{
@@ -2626,9 +2617,8 @@ static money32 try_place_ghost_scenery(
if (res->Error != GA_ERROR::OK)
return MONEY32_UNDEFINED;
gSceneryGhostPosition.x = loc.x;
gSceneryGhostPosition.y = loc.y;
gSceneryGhostPosition.z = loc.z / 8 + 2;
gSceneryGhostPosition = loc;
gSceneryGhostPosition.z += (2 * COORDS_Z_STEP);
gSceneryPlaceRotation = direction;
gSceneryGhostType |= SCENERY_GHOST_FLAG_4;
cost = res->Cost;
@@ -2716,9 +2706,8 @@ static void top_toolbar_tool_update_scenery(int16_t x, int16_t y)
map_invalidate_selection_rect();
// If no change in ghost placement
if ((gSceneryGhostType & SCENERY_GHOST_FLAG_0) && mapTile.x == gSceneryGhostPosition.x
&& mapTile.y == gSceneryGhostPosition.y && (parameter2 & 0xFF) == _unkF64F0E && gSceneryPlaceZ == _unkF64F0A
&& gSceneryPlaceObject == selected_tab)
if ((gSceneryGhostType & SCENERY_GHOST_FLAG_0) && mapTile == gSceneryGhostPosition
&& (parameter2 & 0xFF) == _unkF64F0E && gSceneryPlaceZ == _unkF64F0A && gSceneryPlaceObject == selected_tab)
{
return;
}
@@ -2756,8 +2745,8 @@ static void top_toolbar_tool_update_scenery(int16_t x, int16_t y)
map_invalidate_selection_rect();
// If no change in ghost placement
if ((gSceneryGhostType & SCENERY_GHOST_FLAG_1) && mapTile.x == gSceneryGhostPosition.x
&& mapTile.y == gSceneryGhostPosition.y && (int16_t)(parameter2 & 0xFF) == gSceneryGhostPosition.z)
if ((gSceneryGhostType & SCENERY_GHOST_FLAG_1) && mapTile == gSceneryGhostPosition
&& (int16_t)(parameter2 & 0xFF) * COORDS_Z_STEP == gSceneryGhostPosition.z)
{
return;
}
@@ -2779,9 +2768,8 @@ static void top_toolbar_tool_update_scenery(int16_t x, int16_t y)
map_invalidate_selection_rect();
// If no change in ghost placement
if ((gSceneryGhostType & SCENERY_GHOST_FLAG_2) && mapTile.x == gSceneryGhostPosition.x
&& mapTile.y == gSceneryGhostPosition.y && (parameter2 & 0xFF) == gSceneryGhostWallRotation
&& gSceneryPlaceZ == _unkF64F0A)
if ((gSceneryGhostType & SCENERY_GHOST_FLAG_2) && mapTile == gSceneryGhostPosition
&& (parameter2 & 0xFF) == gSceneryGhostWallRotation && gSceneryPlaceZ == _unkF64F0A)
{
return;
}
@@ -2830,8 +2818,7 @@ static void top_toolbar_tool_update_scenery(int16_t x, int16_t y)
map_invalidate_map_selection_tiles();
// If no change in ghost placement
if ((gSceneryGhostType & SCENERY_GHOST_FLAG_3) && mapTile.x == gSceneryGhostPosition.x
&& mapTile.y == gSceneryGhostPosition.y && gSceneryPlaceZ == _unkF64F0A
if ((gSceneryGhostType & SCENERY_GHOST_FLAG_3) && mapTile == gSceneryGhostPosition && gSceneryPlaceZ == _unkF64F0A
&& (int16_t)(parameter3 & 0xFFFF) == gSceneryPlaceObject)
{
return;
@@ -2872,8 +2859,8 @@ static void top_toolbar_tool_update_scenery(int16_t x, int16_t y)
map_invalidate_selection_rect();
// If no change in ghost placement
if ((gSceneryGhostType & SCENERY_GHOST_FLAG_4) && mapTile.x == gSceneryGhostPosition.x
&& mapTile.y == gSceneryGhostPosition.y && (int16_t)(parameter2 & 0xFF) == gSceneryGhostPosition.z
if ((gSceneryGhostType & SCENERY_GHOST_FLAG_4) && mapTile == gSceneryGhostPosition
&& (int16_t)(parameter2 & 0xFF) * COORDS_Z_STEP == gSceneryGhostPosition.z
&& ((parameter2 >> 8) & 0xFF) == gSceneryPlaceRotation)
{
return;
+35 -39
View File
@@ -24,8 +24,8 @@
static uint16_t _virtualFloorBaseSize = 5 * 32;
static uint16_t _virtualFloorHeight = 0;
static LocationXYZ16 _virtualFloorLastMinPos;
static LocationXYZ16 _virtualFloorLastMaxPos;
static CoordsXYZ _virtualFloorLastMinPos;
static CoordsXYZ _virtualFloorLastMaxPos;
static uint32_t _virtualFloorFlags = 0;
enum VirtualFloorFlags
@@ -56,10 +56,10 @@ void virtual_floor_set_height(int16_t height)
static void virtual_floor_reset()
{
_virtualFloorLastMinPos.x = std::numeric_limits<int16_t>::max();
_virtualFloorLastMinPos.y = std::numeric_limits<int16_t>::max();
_virtualFloorLastMaxPos.x = std::numeric_limits<int16_t>::lowest();
_virtualFloorLastMaxPos.y = std::numeric_limits<int16_t>::lowest();
_virtualFloorLastMinPos.x = std::numeric_limits<int32_t>::max();
_virtualFloorLastMinPos.y = std::numeric_limits<int32_t>::max();
_virtualFloorLastMaxPos.x = std::numeric_limits<int32_t>::lowest();
_virtualFloorLastMaxPos.y = std::numeric_limits<int32_t>::lowest();
_virtualFloorHeight = 0;
}
@@ -121,25 +121,23 @@ void virtual_floor_invalidate()
max_position.y += _virtualFloorBaseSize + 16;
// Invalidate previous region if appropriate.
if (_virtualFloorLastMinPos.x != std::numeric_limits<int16_t>::max()
&& _virtualFloorLastMinPos.y != std::numeric_limits<int16_t>::max()
&& _virtualFloorLastMaxPos.x != std::numeric_limits<int16_t>::lowest()
&& _virtualFloorLastMaxPos.y != std::numeric_limits<int16_t>::lowest())
if (_virtualFloorLastMinPos.x != std::numeric_limits<int32_t>::max()
&& _virtualFloorLastMinPos.y != std::numeric_limits<int32_t>::max()
&& _virtualFloorLastMaxPos.x != std::numeric_limits<int32_t>::lowest()
&& _virtualFloorLastMaxPos.y != std::numeric_limits<int32_t>::lowest())
{
CoordsXY prevMins = { _virtualFloorLastMinPos.x, _virtualFloorLastMinPos.y };
CoordsXY prevMaxs = { _virtualFloorLastMaxPos.x, _virtualFloorLastMaxPos.y };
if (prevMins.x != min_position.x || prevMins.y != min_position.y || prevMaxs.x != max_position.x
|| prevMaxs.y != max_position.y || (_virtualFloorFlags & VIRTUAL_FLOOR_FORCE_INVALIDATION) != 0)
if (_virtualFloorLastMinPos != min_position || _virtualFloorLastMaxPos != max_position
|| (_virtualFloorFlags & VIRTUAL_FLOOR_FORCE_INVALIDATION) != 0)
{
log_verbose("Invalidating previous region, Min: %d %d, Max: %d %d", prevMins.x, prevMins.y, prevMaxs.x, prevMaxs.y);
map_invalidate_region(prevMins, prevMaxs);
log_verbose(
"Invalidating previous region, Min: %d %d, Max: %d %d", _virtualFloorLastMinPos.x, _virtualFloorLastMinPos.y,
_virtualFloorLastMaxPos.x, _virtualFloorLastMaxPos.y);
map_invalidate_region(_virtualFloorLastMinPos, _virtualFloorLastMaxPos);
}
}
// Do not invalidate new region if floor hasn't moved.
if (_virtualFloorLastMinPos.x == min_position.x && _virtualFloorLastMinPos.y == min_position.y
&& _virtualFloorLastMinPos.z == _virtualFloorHeight)
if (min_position == _virtualFloorLastMinPos && _virtualFloorLastMinPos.z == _virtualFloorHeight)
{
return;
}
@@ -152,8 +150,8 @@ void virtual_floor_invalidate()
log_verbose("Min: %d %d, Max: %d %d", min_position.x, min_position.y, max_position.x, max_position.y);
// Invalidate new region if coordinates are set.
if (min_position.x != std::numeric_limits<int16_t>::max() && min_position.y != std::numeric_limits<int16_t>::max()
&& max_position.x != std::numeric_limits<int16_t>::lowest() && max_position.y != std::numeric_limits<int16_t>::lowest())
if (min_position.x != std::numeric_limits<int32_t>::max() && min_position.y != std::numeric_limits<int32_t>::max()
&& max_position.x != std::numeric_limits<int32_t>::lowest() && max_position.y != std::numeric_limits<int32_t>::lowest())
{
map_invalidate_region(min_position, max_position);
@@ -168,7 +166,7 @@ void virtual_floor_invalidate()
}
}
bool virtual_floor_tile_is_floor(int16_t x, int16_t y)
bool virtual_floor_tile_is_floor(const CoordsXY& loc)
{
if (!virtual_floor_is_enabled())
{
@@ -177,9 +175,9 @@ bool virtual_floor_tile_is_floor(int16_t x, int16_t y)
// Check if map selection (usually single tiles) are enabled
// and if the current tile is near or on them
if ((gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) && x >= gMapSelectPositionA.x - _virtualFloorBaseSize
&& y >= gMapSelectPositionA.y - _virtualFloorBaseSize && x <= gMapSelectPositionB.x + _virtualFloorBaseSize
&& y <= gMapSelectPositionB.y + _virtualFloorBaseSize)
if ((gMapSelectFlags & MAP_SELECT_FLAG_ENABLE) && loc.x >= gMapSelectPositionA.x - _virtualFloorBaseSize
&& loc.y >= gMapSelectPositionA.y - _virtualFloorBaseSize && loc.x <= gMapSelectPositionB.x + _virtualFloorBaseSize
&& loc.y <= gMapSelectPositionB.y + _virtualFloorBaseSize)
{
return true;
}
@@ -188,8 +186,8 @@ bool virtual_floor_tile_is_floor(int16_t x, int16_t y)
// Check if we are anywhere near the selection tiles (larger scenery / rides)
for (const auto& tile : gMapSelectionTiles)
{
if (x >= tile.x - _virtualFloorBaseSize && y >= tile.y - _virtualFloorBaseSize
&& x <= tile.x + _virtualFloorBaseSize && y <= tile.y + _virtualFloorBaseSize)
if (loc.x >= tile.x - _virtualFloorBaseSize && loc.y >= tile.y - _virtualFloorBaseSize
&& loc.x <= tile.x + _virtualFloorBaseSize && loc.y <= tile.y + _virtualFloorBaseSize)
{
return true;
}
@@ -200,7 +198,7 @@ bool virtual_floor_tile_is_floor(int16_t x, int16_t y)
}
static void virtual_floor_get_tile_properties(
int16_t x, int16_t y, int16_t height, bool* outOccupied, bool* tileOwned, uint8_t* outOccupiedEdges, bool* outBelowGround,
const CoordsXY& loc, int16_t height, bool* outOccupied, bool* tileOwned, uint8_t* outOccupiedEdges, bool* outBelowGround,
bool* aboveGround, bool* outLit)
{
*outOccupied = false;
@@ -213,8 +211,7 @@ static void virtual_floor_get_tile_properties(
// See if we are a selected tile
if ((gMapSelectFlags & MAP_SELECT_FLAG_ENABLE))
{
if (x >= gMapSelectPositionA.x && y >= gMapSelectPositionA.y && x <= gMapSelectPositionB.x
&& y <= gMapSelectPositionB.y)
if (loc >= gMapSelectPositionA && loc <= gMapSelectPositionB)
{
*outLit = true;
}
@@ -225,7 +222,7 @@ static void virtual_floor_get_tile_properties(
{
for (const auto& tile : gMapSelectionTiles)
{
if (x == tile.x && y == tile.y)
if (tile == loc)
{
*outLit = true;
break;
@@ -233,7 +230,7 @@ static void virtual_floor_get_tile_properties(
}
}
*tileOwned = map_is_location_owned({ x, y, height });
*tileOwned = map_is_location_owned({ loc, height });
if (gCheatsSandboxMode)
*tileOwned = true;
@@ -242,7 +239,7 @@ static void virtual_floor_get_tile_properties(
// * Surfaces, which may put us underground
// * Walls / banners, which are displayed as occupied edges
// * Ghost objects, which are displayed as lit squares
TileElement* tileElement = map_get_first_element_at({ x, y });
TileElement* tileElement = map_get_first_element_at(loc);
if (tileElement == nullptr)
return;
do
@@ -318,8 +315,8 @@ void virtual_floor_paint(paint_session* session)
uint8_t litEdges = 0;
virtual_floor_get_tile_properties(
session->MapPosition.x, session->MapPosition.y, virtualFloorClipHeight, &weAreOccupied, &weAreOwned, &occupiedEdges,
&weAreBelowGround, &weAreAboveGround, &weAreLit);
session->MapPosition, virtualFloorClipHeight, &weAreOccupied, &weAreOwned, &occupiedEdges, &weAreBelowGround,
&weAreAboveGround, &weAreLit);
// Move the bits around to match the current rotation
occupiedEdges |= occupiedEdges << 4;
@@ -331,8 +328,7 @@ void virtual_floor_paint(paint_session* session)
for (uint8_t i = 0; i < 4; i++)
{
uint8_t effectiveRotation = (4 + i - direction) % 4;
int16_t theirLocationX = session->MapPosition.x + scenery_half_tile_offsets[effectiveRotation].x;
int16_t theirLocationY = session->MapPosition.y + scenery_half_tile_offsets[effectiveRotation].y;
CoordsXY theirLocation = session->MapPosition + scenery_half_tile_offsets[effectiveRotation];
bool theyAreOccupied;
uint8_t theirOccupiedEdges;
@@ -342,8 +338,8 @@ void virtual_floor_paint(paint_session* session)
bool theyAreAboveGround;
virtual_floor_get_tile_properties(
theirLocationX, theirLocationY, virtualFloorClipHeight, &theyAreOccupied, &theyAreOwned, &theirOccupiedEdges,
&theyAreBelowGround, &theyAreAboveGround, &theyAreLit);
theirLocation, virtualFloorClipHeight, &theyAreOccupied, &theyAreOwned, &theirOccupiedEdges, &theyAreBelowGround,
&theyAreAboveGround, &theyAreLit);
if (theirOccupiedEdges & (1 << ((effectiveRotation + 2) % 4)) && (weAreOwned && !theyAreOwned))
{
+3 -5
View File
@@ -7,10 +7,10 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#ifndef _VIRTUAL_FLOOR_H
#define _VIRTUAL_FLOOR_H
#pragma once
#include "../common.h"
#include "../world/Location.hpp"
enum VirtualFloorStyles
{
@@ -30,8 +30,6 @@ void virtual_floor_enable();
void virtual_floor_disable();
void virtual_floor_invalidate();
bool virtual_floor_tile_is_floor(int16_t x, int16_t y);
bool virtual_floor_tile_is_floor(const CoordsXY& loc);
void virtual_floor_paint(paint_session* session);
#endif
@@ -163,7 +163,7 @@ static void sub_68B3FB(paint_session* session, int32_t x, int32_t y)
#ifndef __TESTPAINT__
if (gConfigGeneral.virtual_floor_style != VIRTUAL_FLOOR_STYLE_OFF)
{
partOfVirtualFloor = virtual_floor_tile_is_floor(session->MapPosition.x, session->MapPosition.y);
partOfVirtualFloor = virtual_floor_tile_is_floor(session->MapPosition);
}
#endif // __TESTPAINT__
+1 -2
View File
@@ -1228,8 +1228,7 @@ void Guest::UpdateSitting()
if (!(pathingResult & PATHING_DESTINATION_REACHED))
return;
auto loc = CoordsXYZ{ x, y, z }.ToTileStart()
+ CoordsXYZ{ BenchUseOffsets[var_37 & 0x7].x, BenchUseOffsets[var_37 & 0x7].y, 0 };
auto loc = CoordsXYZ{ x, y, z }.ToTileStart() + CoordsXYZ{ BenchUseOffsets[var_37 & 0x7], 0 };
MoveTo(loc.x, loc.y, loc.z);
+5 -5
View File
@@ -3585,7 +3585,7 @@ static void vehicle_update_collision_setup(Vehicle* vehicle)
}
/** rct2: 0x009A3AC4, 0x009A3AC6 */
static constexpr const LocationXY16 stru_9A3AC4[] = {
static constexpr const CoordsXY stru_9A3AC4[] = {
{ -256, 0 }, { -236, 98 }, { -181, 181 }, { -98, 236 }, { 0, 256 }, { 98, 236 }, { 181, 181 }, { 236, 98 },
{ 256, 0 }, { 236, -98 }, { 181, -181 }, { 98, -236 }, { 0, -256 }, { -98, -236 }, { -181, -181 }, { -236, -98 },
};
@@ -3622,23 +3622,23 @@ static void vehicle_update_crash_setup(Vehicle* vehicle)
trainVehicle->sub_state = 0;
int32_t x = stru_9A3AC4[trainVehicle->sprite_direction / 2].x;
int32_t y = stru_9A3AC4[trainVehicle->sprite_direction / 2].y;
auto z = Unk9A38D4[trainVehicle->vehicle_sprite_type] >> 23;
int32_t ecx = Unk9A37E4[trainVehicle->vehicle_sprite_type] >> 15;
x *= ecx;
y *= ecx;
x >>= 16;
y >>= 16;
ecx = Unk9A38D4[trainVehicle->vehicle_sprite_type] >> 23;
x *= edx;
y *= edx;
ecx *= edx;
z *= edx;
x >>= 8;
y >>= 8;
ecx >>= 8;
z >>= 8;
trainVehicle->crash_x = x;
trainVehicle->crash_y = y;
trainVehicle->crash_z = ecx;
trainVehicle->crash_z = z;
trainVehicle->crash_x += (scenario_rand() & 0xF) - 8;
trainVehicle->crash_y += (scenario_rand() & 0xF) - 8;
trainVehicle->crash_z += (scenario_rand() & 0xF) - 8;
+2 -2
View File
@@ -56,7 +56,7 @@ static uint8_t _footpathQueueChain[64];
// This is the coordinates that a user of the bin should move to
// rct2: 0x00992A4C
const LocationXY16 BinUseOffsets[4] = {
const CoordsXY BinUseOffsets[4] = {
{ 11, 16 },
{ 16, 21 },
{ 21, 16 },
@@ -65,7 +65,7 @@ const LocationXY16 BinUseOffsets[4] = {
// These are the offsets for bench positions on footpaths, 2 for each edge
// rct2: 0x00981F2C, 0x00981F2E
const LocationXY16 BenchUseOffsets[8] = {
const CoordsXY BenchUseOffsets[8] = {
{ 7, 12 }, { 12, 25 }, { 25, 20 }, { 20, 7 }, { 7, 20 }, { 20, 25 }, { 25, 12 }, { 12, 7 },
};
+2 -2
View File
@@ -172,8 +172,8 @@ extern uint8_t gFootpathGroundFlags;
// Given a direction, this will return how to increase/decrease the x and y coordinates.
extern const CoordsXY DirectionOffsets[NumOrthogonalDirections];
extern const LocationXY16 BinUseOffsets[NumOrthogonalDirections];
extern const LocationXY16 BenchUseOffsets[NumOrthogonalDirections * 2];
extern const CoordsXY BinUseOffsets[NumOrthogonalDirections];
extern const CoordsXY BenchUseOffsets[NumOrthogonalDirections * 2];
TileElement* map_get_footpath_element(CoordsXYZ coords);
struct PathElement;
+10
View File
@@ -108,6 +108,16 @@ struct CoordsXY
return *this;
}
bool operator>=(const CoordsXY& rhs) const
{
return x >= rhs.x && y >= rhs.y;
}
bool operator<=(const CoordsXY& rhs) const
{
return x <= rhs.x && y <= rhs.y;
}
const CoordsXY operator+(const CoordsXY& rhs) const
{
return { x + rhs.x, y + rhs.y };
+8 -14
View File
@@ -39,7 +39,7 @@ int16_t gSceneryPlaceZ;
uint8_t gSceneryPlaceRotation;
uint8_t gSceneryGhostType;
LocationXYZ16 gSceneryGhostPosition;
CoordsXYZ gSceneryGhostPosition;
uint8_t gSceneryGhostWallRotation;
int16_t gSceneryShiftPressed;
@@ -166,17 +166,11 @@ void scenery_update_age(const CoordsXY& sceneryPos, TileElement* tileElement)
*/
void scenery_remove_ghost_tool_placement()
{
int16_t x, y, z;
x = gSceneryGhostPosition.x;
y = gSceneryGhostPosition.y;
z = gSceneryGhostPosition.z;
if (gSceneryGhostType & SCENERY_GHOST_FLAG_0)
{
gSceneryGhostType &= ~SCENERY_GHOST_FLAG_0;
auto removeSceneryAction = SmallSceneryRemoveAction({ x, y, z * 8 }, gSceneryQuadrant, gSceneryPlaceObject);
auto removeSceneryAction = SmallSceneryRemoveAction(gSceneryGhostPosition, gSceneryQuadrant, gSceneryPlaceObject);
removeSceneryAction.SetFlags(
GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST);
removeSceneryAction.Execute();
@@ -185,7 +179,7 @@ void scenery_remove_ghost_tool_placement()
if (gSceneryGhostType & SCENERY_GHOST_FLAG_1)
{
gSceneryGhostType &= ~SCENERY_GHOST_FLAG_1;
TileElement* tileElement = map_get_first_element_at({ x, y });
TileElement* tileElement = map_get_first_element_at(gSceneryGhostPosition);
do
{
@@ -195,10 +189,10 @@ void scenery_remove_ghost_tool_placement()
if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH)
continue;
if (tileElement->base_height != z)
if (tileElement->GetBaseZ() != gSceneryGhostPosition.z)
continue;
auto footpathSceneryRemoveAction = FootpathSceneryRemoveAction({ x, y, z * 8 });
auto footpathSceneryRemoveAction = FootpathSceneryRemoveAction(gSceneryGhostPosition);
footpathSceneryRemoveAction.SetFlags(GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_GHOST);
GameActions::Execute(&footpathSceneryRemoveAction);
break;
@@ -209,7 +203,7 @@ void scenery_remove_ghost_tool_placement()
{
gSceneryGhostType &= ~SCENERY_GHOST_FLAG_2;
CoordsXYZD wallLocation = { x, y, z * 8, gSceneryGhostWallRotation };
CoordsXYZD wallLocation = { gSceneryGhostPosition, gSceneryGhostWallRotation };
auto wallRemoveAction = WallRemoveAction(wallLocation);
wallRemoveAction.SetFlags(GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_PATH_SCENERY);
wallRemoveAction.Execute();
@@ -219,7 +213,7 @@ void scenery_remove_ghost_tool_placement()
{
gSceneryGhostType &= ~SCENERY_GHOST_FLAG_3;
auto removeSceneryAction = LargeSceneryRemoveAction({ x, y, z * 8, gSceneryPlaceRotation }, 0);
auto removeSceneryAction = LargeSceneryRemoveAction({ gSceneryGhostPosition, gSceneryPlaceRotation }, 0);
removeSceneryAction.SetFlags(
GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED
| GAME_COMMAND_FLAG_NO_SPEND);
@@ -230,7 +224,7 @@ void scenery_remove_ghost_tool_placement()
{
gSceneryGhostType &= ~SCENERY_GHOST_FLAG_4;
auto removeSceneryAction = BannerRemoveAction({ x, y, z * 8, gSceneryPlaceRotation });
auto removeSceneryAction = BannerRemoveAction({ gSceneryGhostPosition, gSceneryPlaceRotation });
removeSceneryAction.SetFlags(
GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND);
GameActions::Execute(&removeSceneryAction);
+1 -1
View File
@@ -254,7 +254,7 @@ extern int16_t gSceneryPlaceZ;
extern uint8_t gSceneryPlaceRotation;
extern uint8_t gSceneryGhostType;
extern LocationXYZ16 gSceneryGhostPosition;
extern CoordsXYZ gSceneryGhostPosition;
extern uint8_t gSceneryGhostWallRotation;
extern int16_t gSceneryShiftPressed;