Refactor more TileCoords

This commit is contained in:
Michael Steenbeek 2020-03-07 21:07:18 +01:00 committed by GitHub
parent 4f86d0115c
commit be13c1fc87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 280 additions and 276 deletions

View File

@ -1067,7 +1067,7 @@ static TileElement* footpath_get_tile_element_to_remove()
}
z = std::min(255 * COORDS_Z_STEP, gFootpathConstructFromPosition.z);
zLow = z - (2 * COORDS_Z_STEP);
zLow = z - PATH_HEIGHT_STEP;
tileElement = map_get_first_element_at(gFootpathConstructFromPosition);
do

View File

@ -3551,8 +3551,7 @@ void ride_construction_toolupdate_construct(const ScreenCoordsXY& screenCoords)
_previousTrackPiece = _currentTrackBegin;
// search for appropriate z value for ghost, up to max ride height
const auto smallZ = z / COORDS_Z_STEP;
int numAttempts = (smallZ <= MAX_TRACK_HEIGHT ? (MAX_TRACK_HEIGHT - smallZ + 1) : 2);
int numAttempts = (z <= MAX_TRACK_HEIGHT ? ((MAX_TRACK_HEIGHT - z) / COORDS_Z_STEP + 1) : 2);
if (ride->type == RIDE_TYPE_MAZE)
{
@ -3769,9 +3768,9 @@ void ride_construction_tooldown_construct(const ScreenCoordsXY& screenCoords)
z -= bx;
// FIX not sure exactly why it starts trial and error place from a lower Z, but it causes issues with disable clearance
if (!gCheatsDisableClearanceChecks && z > 16)
if (!gCheatsDisableClearanceChecks && z > MINIMUM_LAND_HEIGHT_BIG)
{
z -= 16;
z -= LAND_HEIGHT_STEP;
}
}
else
@ -3780,8 +3779,7 @@ void ride_construction_tooldown_construct(const ScreenCoordsXY& screenCoords)
}
// search for z value to build at, up to max ride height
const auto smallZ = z / COORDS_Z_STEP;
int numAttempts = (smallZ <= MAX_TRACK_HEIGHT ? (MAX_TRACK_HEIGHT - smallZ + 1) : 2);
int numAttempts = (z <= MAX_TRACK_HEIGHT ? ((MAX_TRACK_HEIGHT - z) / COORDS_Z_STEP + 1) : 2);
if (ride->type == RIDE_TYPE_MAZE)
{

View File

@ -1879,7 +1879,7 @@ static void window_top_toolbar_scenery_tool_down(int16_t x, int16_t y, rct_windo
case SCENERY_TYPE_PATH_ITEM:
{
auto pathItemType = parameter_3 & 0xFF;
int32_t z = (parameter_2 & 0xFF) * 8;
int32_t z = (parameter_2 & 0xFF) * COORDS_Z_STEP;
auto footpathSceneryPlaceAction = FootpathSceneryPlaceAction({ gridPos, z }, pathItemType);
footpathSceneryPlaceAction.SetCallback([](const GameAction* ga, const GameActionResult* result) {
@ -2535,7 +2535,7 @@ static money32 try_place_ghost_scenery(
// Path Bits
// 6e265b
auto pathItemType = parameter_3 & 0xFF;
int32_t z = (parameter_2 & 0xFF) * 8;
int32_t z = (parameter_2 & 0xFF) * COORDS_Z_STEP;
auto footpathSceneryPlaceAction = FootpathSceneryPlaceAction({ map_tile.x, map_tile.y, z }, pathItemType);
footpathSceneryPlaceAction.SetFlags(GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED);
footpathSceneryPlaceAction.SetCallback([=](const GameAction* ga, const GameActionResult* result) {
@ -2640,7 +2640,7 @@ static money32 try_place_ghost_scenery(
return MONEY32_UNDEFINED;
gSceneryGhostPosition = loc;
gSceneryGhostPosition.z += (2 * COORDS_Z_STEP);
gSceneryGhostPosition.z += PATH_HEIGHT_STEP;
gSceneryPlaceRotation = direction;
gSceneryGhostType |= SCENERY_GHOST_FLAG_4;
cost = res->Cost;

View File

@ -67,8 +67,8 @@ static rct_widget window_view_clipping_widgets[] = {
#pragma region Members
static CoordsXY _selectionStart;
static TileCoordsXY _previousClipSelectionA;
static TileCoordsXY _previousClipSelectionB;
static CoordsXY _previousClipSelectionA;
static CoordsXY _previousClipSelectionB;
static bool _toolActive;
static bool _dragging;
@ -364,8 +364,8 @@ static void window_view_clipping_tool_drag(rct_window* w, rct_widgetindex widget
static void window_view_clipping_tool_up(struct rct_window*, rct_widgetindex, const ScreenCoordsXY&)
{
gClipSelectionA = TileCoordsXY{ gMapSelectPositionA };
gClipSelectionB = TileCoordsXY{ gMapSelectPositionB };
gClipSelectionA = gMapSelectPositionA;
gClipSelectionB = gMapSelectPositionB;
_toolActive = false;
tool_cancel();
gfx_invalidate_screen();

View File

@ -508,8 +508,8 @@ void game_fix_save_vars()
// At this point, we can be sure that surfaceElement is not NULL.
if (x == 0 || x == gMapSize - 1 || y == 0 || y == gMapSize - 1)
{
surfaceElement->SetBaseZ(2 * COORDS_Z_STEP);
surfaceElement->SetClearanceZ(2 * COORDS_Z_STEP);
surfaceElement->SetBaseZ(MINIMUM_LAND_HEIGHT_BIG);
surfaceElement->SetClearanceZ(MINIMUM_LAND_HEIGHT_BIG);
surfaceElement->SetSlope(0);
surfaceElement->SetWaterHeight(0);
}

View File

@ -102,7 +102,7 @@ private:
{
for (int32_t x = x0; x <= x1; x += COORDS_XY_STEP)
{
if (MapCanClearAt(x, y))
if (MapCanClearAt({ x, y }))
{
auto cost = ClearSceneryFromTile({ x, y }, executing);
if (cost != MONEY32_UNDEFINED)
@ -252,9 +252,9 @@ private:
}
}
static bool MapCanClearAt(int32_t x, int32_t y)
static bool MapCanClearAt(const CoordsXY& location)
{
return (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode
|| map_is_location_owned_or_has_rights({ x, y });
|| map_is_location_owned_or_has_rights(location);
}
};

View File

@ -57,9 +57,7 @@ public:
GameActionResult::Ptr res = std::make_unique<GameActionResult>();
res->Cost = 0;
res->Expenditure = ExpenditureType::Landscaping;
res->Position = _loc;
res->Position.x += 16;
res->Position.y += 16;
res->Position = _loc.ToTileCentre();
gFootpathGroundFlags = 0;
@ -111,9 +109,7 @@ public:
GameActionResult::Ptr res = std::make_unique<GameActionResult>();
res->Cost = 0;
res->Expenditure = ExpenditureType::Landscaping;
res->Position = _loc;
res->Position.x += 16;
res->Position.y += 16;
res->Position = _loc.ToTileCentre();
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST))
{
@ -131,7 +127,7 @@ public:
{
// It is possible, let's remove walls between the old and new piece of path
auto zLow = _loc.z;
auto zHigh = zLow + (4 * 8);
auto zHigh = zLow + PATH_CLEARANCE;
wall_remove_intersecting_walls(
{ _loc, zLow, zHigh + (_slope & TILE_ELEMENT_SURFACE_RAISED_CORNERS_MASK) ? 16 : 0 },
direction_reverse(_direction));
@ -213,12 +209,12 @@ private:
res->Cost = MONEY(12, 00);
QuarterTile quarterTile{ 0b1111, 0 };
auto zLow = _loc.z / 8;
auto zHigh = zLow + 4;
auto zLow = _loc.z;
auto zHigh = zLow + PATH_CLEARANCE;
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
{
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & TILE_ELEMENT_DIRECTION_MASK);
zHigh += 2;
zHigh += PATH_HEIGHT_STEP;
}
auto entranceElement = map_get_park_entrance_element_at(_loc, false);
@ -239,8 +235,7 @@ private:
: CREATE_CROSSING_MODE_PATH_OVER_TRACK;
if (!entrancePath
&& !map_can_construct_with_clear_at(
{ _loc, zLow * 8, zHigh * 8 }, &map_place_non_scenery_clear_func, quarterTile, GetFlags(), &res->Cost,
crossingMode))
{ _loc, zLow, zHigh }, &map_place_non_scenery_clear_func, quarterTile, GetFlags(), &res->Cost, crossingMode))
{
return MakeResult(GA_ERROR::NO_CLEARANCE, STR_CANT_BUILD_FOOTPATH_HERE, gGameCommandErrorText, gCommonFormatArgs);
}
@ -256,8 +251,8 @@ private:
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_FOOTPATH_HERE);
}
int32_t supportHeight = zLow - surfaceElement->base_height;
res->Cost += supportHeight < 0 ? MONEY(20, 00) : (supportHeight / 2) * MONEY(5, 00);
int32_t supportHeight = zLow - surfaceElement->GetBaseZ();
res->Cost += supportHeight < 0 ? MONEY(20, 00) : (supportHeight / PATH_HEIGHT_STEP) * MONEY(5, 00);
// Prevent the place sound from being spammed
if (entranceIsSamePath)
@ -278,12 +273,12 @@ private:
res->Cost = MONEY(12, 00);
QuarterTile quarterTile{ 0b1111, 0 };
auto zLow = _loc.z / 8;
auto zHigh = zLow + 4;
auto zLow = _loc.z;
auto zHigh = zLow + PATH_CLEARANCE;
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
{
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & TILE_ELEMENT_DIRECTION_MASK);
zHigh += 2;
zHigh += PATH_HEIGHT_STEP;
}
auto entranceElement = map_get_park_entrance_element_at(_loc, false);
@ -304,8 +299,8 @@ private:
: CREATE_CROSSING_MODE_PATH_OVER_TRACK;
if (!entrancePath
&& !map_can_construct_with_clear_at(
{ _loc, zLow * 8, zHigh * 8 }, &map_place_non_scenery_clear_func, quarterTile,
GAME_COMMAND_FLAG_APPLY | GetFlags(), &res->Cost, crossingMode))
{ _loc, zLow, zHigh }, &map_place_non_scenery_clear_func, quarterTile, GAME_COMMAND_FLAG_APPLY | GetFlags(),
&res->Cost, crossingMode))
{
return MakeResult(GA_ERROR::NO_CLEARANCE, STR_CANT_BUILD_FOOTPATH_HERE, gGameCommandErrorText, gCommonFormatArgs);
}
@ -317,8 +312,8 @@ private:
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_FOOTPATH_HERE);
}
int32_t supportHeight = zLow - surfaceElement->base_height;
res->Cost += supportHeight < 0 ? MONEY(20, 00) : (supportHeight / 2) * MONEY(5, 00);
int32_t supportHeight = zLow - surfaceElement->GetBaseZ();
res->Cost += supportHeight < 0 ? MONEY(20, 00) : (supportHeight / PATH_HEIGHT_STEP) * MONEY(5, 00);
if (entrancePath)
{
@ -331,11 +326,11 @@ private:
}
else
{
auto tileElement = tile_element_insert({ _loc.x / 32, _loc.y / 32, zLow }, 0b1111);
auto tileElement = tile_element_insert(TileCoordsXYZ(_loc), 0b1111);
assert(tileElement != nullptr);
tileElement->SetType(TILE_ELEMENT_TYPE_PATH);
PathElement* pathElement = tileElement->AsPath();
pathElement->clearance_height = zHigh;
pathElement->SetClearanceZ(zHigh);
pathElement->SetSurfaceEntryIndex(_type & ~FOOTPATH_ELEMENT_INSERT_QUEUE);
pathElement->SetSlopeDirection(_slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK);
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)

View File

@ -57,9 +57,7 @@ public:
GameActionResult::Ptr res = std::make_unique<GameActionResult>();
res->Cost = 0;
res->Expenditure = ExpenditureType::Landscaping;
res->Position = _loc;
res->Position.x += 16;
res->Position.y += 16;
res->Position = _loc.ToTileCentre();
gFootpathGroundFlags = 0;
@ -92,9 +90,7 @@ public:
GameActionResult::Ptr res = std::make_unique<GameActionResult>();
res->Cost = 0;
res->Expenditure = ExpenditureType::Landscaping;
res->Position = _loc;
res->Position.x += 16;
res->Position.y += 16;
res->Position = _loc.ToTileCentre();
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST))
{
@ -122,12 +118,12 @@ private:
res->Cost = MONEY(12, 00);
QuarterTile quarterTile{ 0b1111, 0 };
auto zLow = _loc.z / 8;
auto zHigh = zLow + 4;
auto zLow = _loc.z;
auto zHigh = zLow + PATH_CLEARANCE;
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
{
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & TILE_ELEMENT_DIRECTION_MASK);
zHigh += 2;
zHigh += PATH_HEIGHT_STEP;
}
auto entranceElement = map_get_park_entrance_element_at(_loc, false);
@ -148,8 +144,7 @@ private:
: CREATE_CROSSING_MODE_PATH_OVER_TRACK;
if (!entrancePath
&& !map_can_construct_with_clear_at(
{ _loc, zLow * 8, zHigh * 8 }, &map_place_non_scenery_clear_func, quarterTile, GetFlags(), &res->Cost,
crossingMode))
{ _loc, zLow, zHigh }, &map_place_non_scenery_clear_func, quarterTile, GetFlags(), &res->Cost, crossingMode))
{
return MakeResult(
GA_ERROR::NO_CLEARANCE, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, gGameCommandErrorText,
@ -168,8 +163,8 @@ private:
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE);
}
int32_t supportHeight = zLow - surfaceElement->base_height;
res->Cost += supportHeight < 0 ? MONEY(20, 00) : (supportHeight / 2) * MONEY(5, 00);
int32_t supportHeight = zLow - surfaceElement->GetBaseZ();
res->Cost += supportHeight < 0 ? MONEY(20, 00) : (supportHeight / PATH_HEIGHT_STEP) * MONEY(5, 00);
// Prevent the place sound from being spammed
if (entranceIsSamePath)
@ -190,12 +185,12 @@ private:
res->Cost = MONEY(12, 00);
QuarterTile quarterTile{ 0b1111, 0 };
auto zLow = _loc.z / 8;
auto zHigh = zLow + 4;
auto zLow = _loc.z;
auto zHigh = zLow + PATH_CLEARANCE;
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
{
quarterTile = QuarterTile{ 0b1111, 0b1100 }.Rotate(_slope & TILE_ELEMENT_DIRECTION_MASK);
zHigh += 2;
zHigh += PATH_HEIGHT_STEP;
}
auto entranceElement = map_get_park_entrance_element_at(_loc, false);
@ -216,8 +211,8 @@ private:
: CREATE_CROSSING_MODE_PATH_OVER_TRACK;
if (!entrancePath
&& !map_can_construct_with_clear_at(
{ _loc, zLow * 8, zHigh * 8 }, &map_place_non_scenery_clear_func, quarterTile,
GAME_COMMAND_FLAG_APPLY | GetFlags(), &res->Cost, crossingMode))
{ _loc, zLow, zHigh }, &map_place_non_scenery_clear_func, quarterTile, GAME_COMMAND_FLAG_APPLY | GetFlags(),
&res->Cost, crossingMode))
{
return MakeResult(
GA_ERROR::NO_CLEARANCE, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, gGameCommandErrorText,
@ -231,8 +226,8 @@ private:
{
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE);
}
int32_t supportHeight = zLow - surfaceElement->base_height;
res->Cost += supportHeight < 0 ? MONEY(20, 00) : (supportHeight / 2) * MONEY(5, 00);
int32_t supportHeight = zLow - surfaceElement->GetBaseZ();
res->Cost += supportHeight < 0 ? MONEY(20, 00) : (supportHeight / PATH_HEIGHT_STEP) * MONEY(5, 00);
if (entrancePath)
{
@ -245,11 +240,11 @@ private:
}
else
{
auto tileElement = tile_element_insert({ _loc.x / 32, _loc.y / 32, zLow }, 0b1111);
auto tileElement = tile_element_insert(TileCoordsXYZ(_loc), 0b1111);
assert(tileElement != nullptr);
tileElement->SetType(TILE_ELEMENT_TYPE_PATH);
PathElement* pathElement = tileElement->AsPath();
pathElement->clearance_height = zHigh;
pathElement->SetClearanceZ(zHigh);
pathElement->SetSurfaceEntryIndex(_type & ~FOOTPATH_ELEMENT_INSERT_QUEUE);
pathElement->SetSlopeDirection(_slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK);
if (_slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)

View File

@ -135,8 +135,8 @@ public:
}
}
if (!map_can_construct_with_clear_at(
{ _coords, _height * 8, zCorner * 8 }, &map_set_land_height_clear_func, { 0b1111, 0 }, 0, nullptr,
CREATE_CROSSING_MODE_NONE))
{ _coords, _height * COORDS_Z_STEP, zCorner * COORDS_Z_STEP }, &map_set_land_height_clear_func,
{ 0b1111, 0 }, 0, nullptr, CREATE_CROSSING_MODE_NONE))
{
return std::make_unique<GameActionResult>(
GA_ERROR::DISALLOWED, STR_NONE, gGameCommandErrorText, gCommonFormatArgs);

View File

@ -164,8 +164,8 @@ public:
QuarterTile quarterTile = QuarterTile{ static_cast<uint8_t>(tile->flags >> 12), 0 }.Rotate(_loc.direction);
if (!map_can_construct_with_clear_at(
{ curTile, zLow * 8, zHigh * 8 }, &map_place_scenery_clear_func, quarterTile, GetFlags(), &supportsCost,
CREATE_CROSSING_MODE_NONE))
{ curTile, zLow * COORDS_Z_STEP, zHigh * COORDS_Z_STEP }, &map_place_scenery_clear_func, quarterTile,
GetFlags(), &supportsCost, CREATE_CROSSING_MODE_NONE))
{
return std::make_unique<LargeSceneryPlaceActionResult>(
GA_ERROR::NO_CLEARANCE, gGameCommandErrorText, gCommonFormatArgs);
@ -193,7 +193,7 @@ public:
return std::make_unique<LargeSceneryPlaceActionResult>(GA_ERROR::DISALLOWED, STR_OFF_EDGE_OF_MAP);
}
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !map_is_location_owned({ curTile, zLow * 8 })
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !map_is_location_owned({ curTile, zLow * COORDS_Z_STEP })
&& !gCheatsSandboxMode)
{
return std::make_unique<LargeSceneryPlaceActionResult>(GA_ERROR::DISALLOWED, STR_LAND_NOT_OWNED_BY_PARK);
@ -288,12 +288,12 @@ public:
curTile.x += _loc.x;
curTile.y += _loc.y;
int32_t zLow = (tile->z_offset + maxHeight) / 8;
int32_t zHigh = (tile->z_clearance / 8) + zLow;
int32_t zLow = tile->z_offset + maxHeight;
int32_t zHigh = tile->z_clearance + zLow;
QuarterTile quarterTile = QuarterTile{ static_cast<uint8_t>(tile->flags >> 12), 0 }.Rotate(_loc.direction);
if (!map_can_construct_with_clear_at(
{ curTile, zLow * 8, zHigh * 8 }, &map_place_scenery_clear_func, quarterTile, GetFlags(), &supportsCost,
{ curTile, zLow, zHigh }, &map_place_scenery_clear_func, quarterTile, GetFlags(), &supportsCost,
CREATE_CROSSING_MODE_NONE))
{
return std::make_unique<LargeSceneryPlaceActionResult>(
@ -304,19 +304,19 @@ public:
if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST))
{
footpath_remove_litter({ curTile, zLow * COORDS_Z_STEP });
footpath_remove_litter({ curTile, zLow });
if (!gCheatsDisableClearanceChecks)
{
wall_remove_at({ curTile, zLow * 8, zHigh * 8 });
wall_remove_at({ curTile, zLow, zHigh });
}
}
TileElement* newTileElement = tile_element_insert(
{ curTile.x / 32, curTile.y / 32, zLow }, quarterTile.GetBaseQuarterOccupied());
TileCoordsXYZ(CoordsXYZ{ curTile.x, curTile.y, zLow }), quarterTile.GetBaseQuarterOccupied());
Guard::Assert(newTileElement != nullptr);
map_animation_create(MAP_ANIMATION_TYPE_LARGE_SCENERY, { curTile, zLow * 8 });
map_animation_create(MAP_ANIMATION_TYPE_LARGE_SCENERY, { curTile, zLow });
newTileElement->SetType(TILE_ELEMENT_TYPE_LARGE_SCENERY);
newTileElement->clearance_height = zHigh;
newTileElement->SetClearanceZ(zHigh);
auto newSceneryElement = newTileElement->AsLargeScenery();
SetNewLargeSceneryElement(*newSceneryElement, tileNum);

View File

@ -71,13 +71,13 @@ public:
return res;
}
uint8_t baseHeight = _loc.z / 8;
uint8_t clearanceHeight = (_loc.z + 32) / 8;
auto baseHeight = _loc.z;
auto clearanceHeight = _loc.z + MAZE_CLEARANCE_HEIGHT;
int8_t heightDifference = baseHeight - surfaceElement->base_height;
auto heightDifference = baseHeight - surfaceElement->GetBaseZ();
if (heightDifference >= 0 && !gCheatsDisableSupportLimits)
{
heightDifference = heightDifference >> 1;
heightDifference /= COORDS_Z_PER_TINY_Z;
if (heightDifference > RideData5[RIDE_TYPE_MAZE].max_height)
{
@ -90,7 +90,7 @@ public:
money32 clearCost = 0;
if (!map_can_construct_with_clear_at(
{ _loc.ToTileStart(), baseHeight * 8, clearanceHeight * 8 }, &map_place_non_scenery_clear_func, { 0b1111, 0 },
{ _loc.ToTileStart(), baseHeight, clearanceHeight }, &map_place_non_scenery_clear_func, { 0b1111, 0 },
GetFlags(), &clearCost, CREATE_CROSSING_MODE_NONE))
{
return MakeResult(GA_ERROR::NO_CLEARANCE, res->ErrorTitle, gGameCommandErrorText, gCommonFormatArgs);
@ -154,12 +154,12 @@ public:
wall_remove_at({ _loc.ToTileStart(), _loc.z, _loc.z + 32 });
}
uint8_t baseHeight = _loc.z / 8;
uint8_t clearanceHeight = (_loc.z + 32) / 8;
auto baseHeight = _loc.z;
auto clearanceHeight = _loc.z + MAZE_CLEARANCE_HEIGHT;
money32 clearCost = 0;
if (!map_can_construct_with_clear_at(
{ _loc.ToTileStart(), baseHeight * 8, clearanceHeight * 8 }, &map_place_non_scenery_clear_func, { 0b1111, 0 },
{ _loc.ToTileStart(), baseHeight, clearanceHeight }, &map_place_non_scenery_clear_func, { 0b1111, 0 },
GetFlags() | GAME_COMMAND_FLAG_APPLY, &clearCost, CREATE_CROSSING_MODE_NONE))
{
return MakeResult(GA_ERROR::NO_CLEARANCE, res->ErrorTitle, gGameCommandErrorText, gCommonFormatArgs);
@ -170,10 +170,10 @@ public:
auto startLoc = _loc.ToTileStart();
auto tileElement = tile_element_insert({ TileCoordsXY{ _loc }, baseHeight }, 0b1111);
auto tileElement = tile_element_insert(TileCoordsXYZ(_loc), 0b1111);
assert(tileElement != nullptr);
tileElement->clearance_height = clearanceHeight + 4;
tileElement->SetClearanceZ(clearanceHeight + MAZE_CLEARANCE_HEIGHT);
tileElement->SetType(TILE_ELEMENT_TYPE_TRACK);
tileElement->AsTrack()->SetTrackType(TRACK_ELEM_MAZE);

View File

@ -108,13 +108,13 @@ public:
return res;
}
uint8_t baseHeight = _loc.z / 8;
uint8_t clearanceHeight = (_loc.z + 32) / 8;
auto baseHeight = _loc.z;
auto clearanceHeight = _loc.z + 32;
int8_t heightDifference = baseHeight - surfaceElement->base_height;
auto heightDifference = baseHeight - surfaceElement->GetBaseZ();
if (heightDifference >= 0 && !gCheatsDisableSupportLimits)
{
heightDifference = heightDifference >> 1;
heightDifference /= COORDS_Z_PER_TINY_Z;
if (heightDifference > RideData5[RIDE_TYPE_MAZE].max_height)
{
@ -134,7 +134,7 @@ public:
return res;
}
if (!map_can_construct_at({ _loc.ToTileStart(), baseHeight * 8, clearanceHeight * 8 }, { 0b1111, 0 }))
if (!map_can_construct_at({ _loc.ToTileStart(), baseHeight, clearanceHeight }, { 0b1111, 0 }))
{
return MakeResult(GA_ERROR::NO_CLEARANCE, res->ErrorTitle, gGameCommandErrorText, gCommonFormatArgs);
}
@ -200,9 +200,6 @@ public:
wall_remove_at({ _loc.ToTileStart(), _loc.z, _loc.z + 32 });
}
uint8_t baseHeight = _loc.z / 8;
uint8_t clearanceHeight = (_loc.z + 32) / 8;
auto tileElement = map_get_track_element_at_of_type_from_ride(_loc, TRACK_ELEM_MAZE, _rideIndex);
if (tileElement == nullptr)
{
@ -211,10 +208,10 @@ public:
auto startLoc = _loc.ToTileStart();
tileElement = tile_element_insert({ TileCoordsXY{ _loc }, baseHeight }, 0b1111);
tileElement = tile_element_insert({ TileCoordsXYZ{ _loc } }, 0b1111);
assert(tileElement != nullptr);
tileElement->clearance_height = clearanceHeight;
tileElement->SetClearanceZ(_loc.z + MAZE_CLEARANCE_HEIGHT);
tileElement->SetType(TILE_ELEMENT_TYPE_TRACK);
tileElement->AsTrack()->SetTrackType(TRACK_ELEM_MAZE);

View File

@ -77,8 +77,8 @@ public:
GA_ERROR::INVALID_PARAMETERS, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_ERR_TOO_MANY_PARK_ENTRANCES);
}
int8_t zLow = _loc.z / 8;
int8_t zHigh = zLow + 12;
int8_t zLow = _loc.z;
int8_t zHigh = zLow + ParkEntranceHeight;
CoordsXYZ entranceLoc = _loc;
for (uint8_t index = 0; index < 3; index++)
{
@ -92,7 +92,7 @@ public:
entranceLoc.y += CoordsDirectionDelta[(_loc.direction + 1) & 0x3].y * 2;
}
if (!map_can_construct_at({ entranceLoc, zLow * 8, zHigh * 8 }, { 0b1111, 0 }))
if (!map_can_construct_at({ entranceLoc, zLow, zHigh }, { 0b1111, 0 }))
{
return std::make_unique<GameActionResult>(
GA_ERROR::NO_CLEARANCE, STR_CANT_BUILD_PARK_ENTRANCE_HERE, gGameCommandErrorText, gCommonFormatArgs);
@ -123,8 +123,8 @@ public:
gParkEntrances.push_back(parkEntrance);
int8_t zLow = _loc.z / 8;
int8_t zHigh = zLow + 12;
int8_t zLow = _loc.z;
int8_t zHigh = zLow + ParkEntranceHeight;
CoordsXY entranceLoc = { _loc.x, _loc.y };
for (uint8_t index = 0; index < 3; index++)
{
@ -148,7 +148,8 @@ public:
}
}
TileElement* newElement = tile_element_insert({ entranceLoc.x / 32, entranceLoc.y / 32, zLow }, 0b1111);
TileElement* newElement = tile_element_insert(
TileCoordsXYZ(CoordsXYZ{ entranceLoc.x, entranceLoc.y, zLow }), 0b1111);
Guard::Assert(newElement != nullptr);
newElement->SetType(TILE_ELEMENT_TYPE_ENTRANCE);
auto entranceElement = newElement->AsEntrance();
@ -157,7 +158,7 @@ public:
Guard::Assert(false);
return nullptr;
}
entranceElement->clearance_height = zHigh;
entranceElement->SetClearanceZ(zHigh);
if (flags & GAME_COMMAND_FLAG_GHOST)
{
@ -175,16 +176,16 @@ public:
}
update_park_fences(entranceLoc);
update_park_fences({ entranceLoc.x - 32, entranceLoc.y });
update_park_fences({ entranceLoc.x + 32, entranceLoc.y });
update_park_fences({ entranceLoc.x, entranceLoc.y - 32 });
update_park_fences({ entranceLoc.x, entranceLoc.y + 32 });
update_park_fences({ entranceLoc.x - COORDS_XY_STEP, entranceLoc.y });
update_park_fences({ entranceLoc.x + COORDS_XY_STEP, entranceLoc.y });
update_park_fences({ entranceLoc.x, entranceLoc.y - COORDS_XY_STEP });
update_park_fences({ entranceLoc.x, entranceLoc.y + COORDS_XY_STEP });
map_invalidate_tile({ entranceLoc, newElement->GetBaseZ(), newElement->GetClearanceZ() });
if (index == 0)
{
map_animation_create(MAP_ANIMATION_TYPE_PARK_ENTRANCE, { entranceLoc, zLow * 8 });
map_animation_create(MAP_ANIMATION_TYPE_PARK_ENTRANCE, { entranceLoc, zLow });
}
}

View File

@ -104,10 +104,10 @@ public:
return MakeResult(GA_ERROR::NOT_OWNED, errorTitle);
}
auto clear_z = (z / 8) + (_isExit ? 5 : 7);
auto clear_z = z + (_isExit ? RideExitHeight : RideEntranceHeight);
auto cost = MONEY32_UNDEFINED;
if (!map_can_construct_with_clear_at(
{ _loc, z, clear_z * 8 }, &map_place_non_scenery_clear_func, { 0b1111, 0 }, GetFlags(), &cost,
{ _loc, z, clear_z }, &map_place_non_scenery_clear_func, { 0b1111, 0 }, GetFlags(), &cost,
CREATE_CROSSING_MODE_NONE))
{
return MakeResult(GA_ERROR::NO_CLEARANCE, errorTitle, gGameCommandErrorText, gCommonFormatArgs);
@ -118,15 +118,13 @@ public:
return MakeResult(GA_ERROR::DISALLOWED, errorTitle, STR_RIDE_CANT_BUILD_THIS_UNDERWATER);
}
if (z / 8 > MaxRideEntranceOrExitHeight)
if (z > MaxRideEntranceOrExitHeight)
{
return MakeResult(GA_ERROR::DISALLOWED, errorTitle, STR_TOO_HIGH);
}
auto res = MakeResult();
res->Position.x = _loc.x + 16;
res->Position.y = _loc.y + 16;
res->Position.z = z;
res->Position = { _loc.ToTileCentre(), z };
res->Expenditure = ExpenditureType::RideConstruction;
return res;
}
@ -171,26 +169,24 @@ public:
wall_remove_at_z({ _loc, z });
}
auto clear_z = (z / 8) + (_isExit ? 5 : 7);
auto clear_z = z + (_isExit ? RideExitHeight : RideEntranceHeight);
auto cost = MONEY32_UNDEFINED;
if (!map_can_construct_with_clear_at(
{ _loc, z, clear_z * 8 }, &map_place_non_scenery_clear_func, { 0b1111, 0 },
GetFlags() | GAME_COMMAND_FLAG_APPLY, &cost, CREATE_CROSSING_MODE_NONE))
{ _loc, z, clear_z }, &map_place_non_scenery_clear_func, { 0b1111, 0 }, GetFlags() | GAME_COMMAND_FLAG_APPLY,
&cost, CREATE_CROSSING_MODE_NONE))
{
return MakeResult(GA_ERROR::NO_CLEARANCE, errorTitle, gGameCommandErrorText, gCommonFormatArgs);
}
auto res = MakeResult();
res->Position.x = _loc.x + 16;
res->Position.y = _loc.y + 16;
res->Position.z = z;
res->Position = { _loc.ToTileCentre(), z };
res->Expenditure = ExpenditureType::RideConstruction;
TileElement* tileElement = tile_element_insert({ _loc.x / 32, _loc.y / 32, z / 8 }, 0b1111);
TileElement* tileElement = tile_element_insert(TileCoordsXYZ(CoordsXYZ{ _loc, z }), 0b1111);
assert(tileElement != nullptr);
tileElement->SetType(TILE_ELEMENT_TYPE_ENTRANCE);
tileElement->SetDirection(_direction);
tileElement->clearance_height = clear_z;
tileElement->SetClearanceZ(clear_z);
tileElement->AsEntrance()->SetEntranceType(_isExit ? ENTRANCE_TYPE_RIDE_EXIT : ENTRANCE_TYPE_RIDE_ENTRANCE);
tileElement->AsEntrance()->SetStationIndex(_stationNum);
tileElement->AsEntrance()->SetRideIndex(_rideIndex);
@ -203,12 +199,12 @@ public:
if (_isExit)
{
ride_set_exit_location(
ride, _stationNum, { _loc.x / 32, _loc.y / 32, z / 8, (uint8_t)tileElement->GetDirection() });
ride, _stationNum, TileCoordsXYZD(CoordsXYZD{ _loc, z, (uint8_t)tileElement->GetDirection() }));
}
else
{
ride_set_entrance_location(
ride, _stationNum, { _loc.x / 32, _loc.y / 32, z / 8, (uint8_t)tileElement->GetDirection() });
ride, _stationNum, TileCoordsXYZD(CoordsXYZD{ _loc, z, (uint8_t)tileElement->GetDirection() }));
ride->stations[_stationNum].LastPeepInQueue = SPRITE_INDEX_NULL;
ride->stations[_stationNum].QueueLength = 0;
@ -244,12 +240,11 @@ public:
return MakeResult(GA_ERROR::NOT_OWNED, errorTitle);
}
int16_t baseZ = loc.z / 8;
int16_t clearZ = baseZ + (isExit ? 5 : 7);
int16_t baseZ = loc.z;
int16_t clearZ = baseZ + (isExit ? RideExitHeight : RideEntranceHeight);
auto cost = MONEY32_UNDEFINED;
if (!map_can_construct_with_clear_at(
{ loc, baseZ * 8, clearZ * 8 }, &map_place_non_scenery_clear_func, { 0b1111, 0 }, 0, &cost,
CREATE_CROSSING_MODE_NONE))
{ loc, baseZ, clearZ }, &map_place_non_scenery_clear_func, { 0b1111, 0 }, 0, &cost, CREATE_CROSSING_MODE_NONE))
{
return MakeResult(GA_ERROR::NO_CLEARANCE, errorTitle, gGameCommandErrorText, gCommonFormatArgs);
}
@ -264,9 +259,7 @@ public:
return MakeResult(GA_ERROR::DISALLOWED, errorTitle, STR_TOO_HIGH);
}
auto res = MakeResult();
res->Position.x = loc.x + 16;
res->Position.y = loc.y + 16;
res->Position.z = tile_element_height(loc);
res->Position = { loc.ToTileCentre(), tile_element_height(loc) };
res->Expenditure = ExpenditureType::RideConstruction;
return res;
}

View File

@ -147,20 +147,18 @@ public:
}
// Check if sub tile height is any different compared to actual surface tile height
int32_t x2 = _loc.x;
int32_t y2 = _loc.y;
auto loc2 = _loc;
if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE))
{
x2 += 16;
y2 += 16;
loc2 = loc2.ToTileCentre();
}
else
{
x2 += SceneryQuadrantOffsets[quadrant & 3].x - 1;
y2 += SceneryQuadrantOffsets[quadrant & 3].y - 1;
loc2.x += SceneryQuadrantOffsets[quadrant & 3].x - 1;
loc2.y += SceneryQuadrantOffsets[quadrant & 3].y - 1;
}
landHeight = tile_element_height({ x2, y2 });
waterHeight = tile_element_water_height({ x2, y2 });
landHeight = tile_element_height(loc2);
waterHeight = tile_element_water_height(loc2);
surfaceHeight = landHeight;
// If on water
@ -239,8 +237,8 @@ public:
}
}
int32_t zLow = targetHeight / 8;
int32_t zHigh = zLow + ceil2(sceneryEntry->small_scenery.height, 8) / 8;
int32_t zLow = targetHeight;
int32_t zHigh = zLow + ceil2(sceneryEntry->small_scenery.height, COORDS_Z_STEP);
uint8_t collisionQuadrants = 0b1111;
auto quadRotation{ 0 };
if (!(scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE)))
@ -280,7 +278,7 @@ public:
money32 clearCost = 0;
if (!map_can_construct_with_clear_at(
{ _loc, zLow * 8, zHigh * 8 }, &map_place_scenery_clear_func, quarterTile, GetFlags(), &clearCost,
{ _loc, zLow, zHigh }, &map_place_scenery_clear_func, quarterTile, GetFlags(), &clearCost,
CREATE_CROSSING_MODE_NONE))
{
return std::make_unique<SmallSceneryPlaceActionResult>(
@ -377,8 +375,8 @@ public:
}
}
int32_t zLow = targetHeight / 8;
int32_t zHigh = zLow + ceil2(sceneryEntry->small_scenery.height, 8) / 8;
int32_t zLow = targetHeight;
int32_t zHigh = zLow + ceil2(sceneryEntry->small_scenery.height, 8);
uint8_t collisionQuadrants = 0b1111;
auto quadRotation{ 0 };
if (!(scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_FULL_TILE)))
@ -418,7 +416,7 @@ public:
money32 clearCost = 0;
if (!map_can_construct_with_clear_at(
{ _loc, zLow * 8, zHigh * 8 }, &map_place_scenery_clear_func, quarterTile, GetFlags() | GAME_COMMAND_FLAG_APPLY,
{ _loc, zLow, zHigh }, &map_place_scenery_clear_func, quarterTile, GetFlags() | GAME_COMMAND_FLAG_APPLY,
&clearCost, CREATE_CROSSING_MODE_NONE))
{
return std::make_unique<SmallSceneryPlaceActionResult>(
@ -430,7 +428,8 @@ public:
res->Expenditure = ExpenditureType::Landscaping;
res->Cost = (sceneryEntry->small_scenery.price * 10) + clearCost;
TileElement* newElement = tile_element_insert({ _loc.x / 32, _loc.y / 32, zLow }, quarterTile.GetBaseQuarterOccupied());
TileElement* newElement = tile_element_insert(
TileCoordsXYZ(CoordsXYZ{ _loc, zLow }), quarterTile.GetBaseQuarterOccupied());
assert(newElement != nullptr);
res->tileElement = newElement;
newElement->SetType(TILE_ELEMENT_TYPE_SMALL_SCENERY);

View File

@ -210,7 +210,7 @@ public:
return std::make_unique<TrackPlaceActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_TOO_LOW);
}
int32_t baseZ = mapLoc.z / 8;
int32_t baseZ = mapLoc.z;
int32_t clearanceZ = trackBlock->var_07;
if (trackBlock->var_09 & (1 << 2) && RideData5[ride->type].clearance_height > 24)
@ -222,7 +222,7 @@ public:
clearanceZ += RideData5[ride->type].clearance_height;
}
clearanceZ = (clearanceZ / 8) + baseZ;
clearanceZ += baseZ;
if (clearanceZ > MAX_TRACK_HEIGHT)
{
@ -233,7 +233,7 @@ public:
? CREATE_CROSSING_MODE_TRACK_OVER_PATH
: CREATE_CROSSING_MODE_NONE;
if (!map_can_construct_with_clear_at(
{ mapLoc, baseZ * 8, clearanceZ * 8 }, &map_place_non_scenery_clear_func, quarterTile, GetFlags(), &cost,
{ mapLoc, baseZ, clearanceZ }, &map_place_non_scenery_clear_func, quarterTile, GetFlags(), &cost,
crossingMode))
{
return std::make_unique<TrackPlaceActionResult>(
@ -315,8 +315,7 @@ public:
if (surfaceElement == nullptr)
return std::make_unique<TrackPlaceActionResult>(GA_ERROR::UNKNOWN, STR_NONE);
// TODO: Make everything use big Z coordinates so we can stop dividing and multiplying by COORDS_Z_STEP.
uint8_t waterHeight = surfaceElement->GetWaterHeight() / COORDS_Z_STEP;
auto waterHeight = surfaceElement->GetWaterHeight();
if (waterHeight == 0)
{
return std::make_unique<TrackPlaceActionResult>(GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_ON_WATER);
@ -326,8 +325,8 @@ public:
{
return std::make_unique<TrackPlaceActionResult>(GA_ERROR::DISALLOWED, STR_CAN_ONLY_BUILD_THIS_ON_WATER);
}
waterHeight -= 2;
if (waterHeight == surfaceElement->base_height)
waterHeight -= LAND_HEIGHT_STEP;
if (waterHeight == surfaceElement->GetBaseZ())
{
uint8_t slope = surfaceElement->GetSlope() & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP;
if (slope == TILE_ELEMENT_SLOPE_W_CORNER_DN || slope == TILE_ELEMENT_SLOPE_S_CORNER_DN
@ -349,7 +348,7 @@ public:
}
if ((entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN) && trackBlock->index == 0)
{
if (!track_add_station_element(mapLoc.x, mapLoc.y, baseZ, _origin.direction, _rideIndex, 0))
if (!track_add_station_element(mapLoc.x, mapLoc.y, baseZ / COORDS_Z_STEP, _origin.direction, _rideIndex, 0))
{
return std::make_unique<TrackPlaceActionResult>(GA_ERROR::UNKNOWN, gGameCommandErrorText);
}
@ -362,7 +361,7 @@ public:
if (!gCheatsDisableSupportLimits)
{
int32_t ride_height = clearanceZ - surfaceElement->base_height;
int32_t ride_height = clearanceZ - surfaceElement->GetBaseZ();
if (ride_height >= 0)
{
uint16_t maxHeight;
@ -381,7 +380,7 @@ public:
maxHeight = RideData5[ride->type].max_height;
}
ride_height /= 2;
ride_height /= COORDS_Z_PER_TINY_Z;
if (ride_height > maxHeight && !byte_9D8150)
{
return std::make_unique<TrackPlaceActionResult>(GA_ERROR::DISALLOWED, STR_TOO_HIGH_FOR_SUPPORTS);
@ -389,13 +388,13 @@ public:
}
}
int32_t supportHeight = baseZ - surfaceElement->base_height;
int32_t supportHeight = baseZ - surfaceElement->GetBaseZ();
if (supportHeight < 0)
{
supportHeight = 10;
supportHeight = (10 * COORDS_Z_STEP);
}
cost += ((supportHeight / 2) * RideTrackCosts[ride->type].support_price) * 5;
cost += ((supportHeight / (2 * COORDS_Z_STEP)) * RideTrackCosts[ride->type].support_price) * 5;
}
money32 price = RideTrackCosts[ride->type].track_price;
@ -453,7 +452,6 @@ public:
auto quarterTile = trackBlock->var_08.Rotate(_origin.direction);
int32_t baseZ = mapLoc.z / 8;
int32_t clearanceZ = trackBlock->var_07;
if (trackBlock->var_09 & (1 << 2) && RideData5[ride->type].clearance_height > 24)
{
@ -464,14 +462,15 @@ public:
clearanceZ += RideData5[ride->type].clearance_height;
}
clearanceZ = (clearanceZ / 8) + baseZ;
clearanceZ = clearanceZ + mapLoc.z;
const auto mapLocWithClearance = CoordsXYRangedZ(mapLoc, mapLoc.z, clearanceZ);
uint8_t crossingMode = (ride->type == RIDE_TYPE_MINIATURE_RAILWAY && _trackType == TRACK_ELEM_FLAT)
? CREATE_CROSSING_MODE_TRACK_OVER_PATH
: CREATE_CROSSING_MODE_NONE;
if (!map_can_construct_with_clear_at(
{ mapLoc, baseZ * 8, clearanceZ * 8 }, &map_place_non_scenery_clear_func, quarterTile,
GetFlags() | GAME_COMMAND_FLAG_APPLY, &cost, crossingMode))
mapLocWithClearance, &map_place_non_scenery_clear_func, quarterTile, GetFlags() | GAME_COMMAND_FLAG_APPLY,
&cost, crossingMode))
{
return std::make_unique<TrackPlaceActionResult>(
GA_ERROR::NO_CLEARANCE, gGameCommandErrorText, gCommonFormatArgs);
@ -482,7 +481,7 @@ public:
footpath_remove_litter(mapLoc);
if (rideTypeFlags & RIDE_TYPE_FLAG_TRACK_NO_WALLS)
{
wall_remove_at({ mapLoc, baseZ * 8, clearanceZ * 8 });
wall_remove_at(mapLocWithClearance);
}
else
{
@ -490,11 +489,11 @@ public:
uint8_t intersectingDirections = (*wallEdges)[blockIndex];
intersectingDirections ^= 0x0F;
intersectingDirections = rol4(intersectingDirections, _origin.direction);
for (int32_t i = 0; i < 4; i++)
for (int32_t i = 0; i < NumOrthogonalDirections; i++)
{
if (intersectingDirections & (1 << i))
{
wall_remove_intersecting_walls({ mapLoc, baseZ * 8, clearanceZ * 8 }, i);
wall_remove_intersecting_walls(mapLocWithClearance, i);
}
}
}
@ -514,13 +513,13 @@ public:
if (surfaceElement == nullptr)
return std::make_unique<TrackPlaceActionResult>(GA_ERROR::UNKNOWN, STR_NONE);
int32_t supportHeight = baseZ - surfaceElement->base_height;
int32_t supportHeight = mapLoc.z - surfaceElement->GetBaseZ();
if (supportHeight < 0)
{
supportHeight = 10;
supportHeight = (10 * COORDS_Z_STEP);
}
cost += ((supportHeight / 2) * RideTrackCosts[ride->type].support_price) * 5;
cost += ((supportHeight / (2 * COORDS_Z_STEP)) * RideTrackCosts[ride->type].support_price) * 5;
invalidate_test_results(ride);
switch (_trackType)
@ -532,7 +531,7 @@ public:
if (trackBlock->index != 0)
break;
ride->lifecycle_flags |= RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED;
ride->CableLiftLoc = { mapLoc, baseZ * 8 };
ride->CableLiftLoc = mapLoc;
break;
case TRACK_ELEM_BLOCK_BRAKES:
ride->num_block_brakes++;
@ -583,10 +582,9 @@ public:
ride->overall_view = mapLoc;
}
auto tileElement = tile_element_insert(
{ mapLoc.x / 32, mapLoc.y / 32, baseZ }, quarterTile.GetBaseQuarterOccupied());
auto tileElement = tile_element_insert(TileCoordsXYZ(mapLoc), quarterTile.GetBaseQuarterOccupied());
assert(tileElement != nullptr);
tileElement->clearance_height = clearanceZ;
tileElement->SetClearanceZ(clearanceZ);
tileElement->SetType(TILE_ELEMENT_TYPE_TRACK);
tileElement->SetDirection(_origin.direction);
if (_trackPlaceFlags & CONSTRUCTION_LIFT_HILL_SELECTED)
@ -657,7 +655,7 @@ public:
tempLoc.x += CoordsDirectionDelta[tempDirection].x;
tempLoc.y += CoordsDirectionDelta[tempDirection].y;
tempDirection = direction_reverse(tempDirection);
wall_remove_intersecting_walls({ tempLoc, baseZ * 8, clearanceZ * 8 }, tempDirection & 3);
wall_remove_intersecting_walls(mapLocWithClearance, tempDirection & 3);
}
}
}
@ -668,7 +666,7 @@ public:
if (trackBlock->index == 0)
{
track_add_station_element(
mapLoc.x, mapLoc.y, baseZ, _origin.direction, _rideIndex, GAME_COMMAND_FLAG_APPLY);
mapLoc.x, mapLoc.y, mapLoc.z / COORDS_Z_STEP, _origin.direction, _rideIndex, GAME_COMMAND_FLAG_APPLY);
}
sub_6CB945(ride);
ride->UpdateMaxVehicles();

View File

@ -47,9 +47,7 @@ public:
{
auto res = MakeResult();
res->Expenditure = ExpenditureType::Landscaping;
res->Position.x = _coords.x + 16;
res->Position.y = _coords.y + 16;
res->Position.z = _height * 8;
res->Position = { _coords, _height * COORDS_Z_STEP };
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gCheatsSandboxMode
&& gParkFlags & PARK_FLAGS_FORBID_LANDSCAPE_CHANGES)
@ -78,11 +76,11 @@ public:
return MakeResult(GA_ERROR::UNKNOWN, STR_NONE);
}
int32_t zHigh = surfaceElement->base_height;
int32_t zLow = _height;
int32_t zHigh = surfaceElement->GetBaseZ();
int32_t zLow = _height * COORDS_Z_STEP;
if (surfaceElement->GetWaterHeight() > 0)
{
zHigh = surfaceElement->GetWaterHeight() / COORDS_Z_STEP;
zHigh = surfaceElement->GetWaterHeight();
}
if (zLow > zHigh)
{
@ -91,7 +89,7 @@ public:
zLow = temp;
}
if (!map_can_construct_at({ _coords, zLow * 8, zHigh * 8 }, { 0b1111, 0b1111 }))
if (!map_can_construct_at({ _coords, zLow, zHigh }, { 0b1111, 0b1111 }))
{
return MakeResult(GA_ERROR::NO_CLEARANCE, STR_NONE, gGameCommandErrorText, gCommonFormatArgs);
}
@ -109,9 +107,7 @@ public:
{
auto res = MakeResult();
res->Expenditure = ExpenditureType::Landscaping;
res->Position.x = _coords.x + 16;
res->Position.y = _coords.y + 16;
res->Position.z = _height * 8;
res->Position = { _coords, _height * COORDS_Z_STEP };
int32_t surfaceHeight = tile_element_height(_coords);
footpath_remove_litter({ _coords, surfaceHeight });

View File

@ -654,13 +654,9 @@ static int32_t cc_get(InteractiveConsole& console, const arguments_t& argv)
get_map_coordinates_from_pos(
{ viewport->view_width / 2, viewport->view_height / 2 }, VIEWPORT_INTERACTION_MASK_TERRAIN, mapCoord,
&interactionType, &tileElement, nullptr);
mapCoord.x -= 16;
mapCoord.x /= 32;
mapCoord.y -= 16;
mapCoord.y /= 32;
mapCoord.x++;
mapCoord.y++;
console.WriteFormatLine("location %d %d", mapCoord.x, mapCoord.y);
auto tileMapCoord = TileCoordsXY(mapCoord);
console.WriteFormatLine("location %d %d", tileMapCoord.x, tileMapCoord.y);
}
}
else if (argv[0] == "window_scale")

View File

@ -27,8 +27,8 @@ using namespace OpenRCT2;
// Globals for paint clipping
uint8_t gClipHeight = 128; // Default to middle value
TileCoordsXY gClipSelectionA = { 0, 0 };
TileCoordsXY gClipSelectionB = { MAXIMUM_MAP_SIZE_TECHNICAL - 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1 };
CoordsXY gClipSelectionA = { 0, 0 };
CoordsXY gClipSelectionB = { MAXIMUM_TILE_START_XY, MAXIMUM_TILE_START_XY };
static constexpr const uint8_t BoundBoxDebugColours[] = {
0, // NONE

View File

@ -178,8 +178,8 @@ extern paint_session gPaintSession;
// Globals for paint clipping
extern uint8_t gClipHeight;
extern TileCoordsXY gClipSelectionA;
extern TileCoordsXY gClipSelectionB;
extern CoordsXY gClipSelectionA;
extern CoordsXY gClipSelectionB;
/** rct2: 0x00993CC4. The white ghost that indicates not-yet-built elements. */
#define CONSTRUCTION_MARKER (COLOUR_DARK_GREEN << 19 | COLOUR_GREY << 24 | IMAGE_TYPE_REMAP)

View File

@ -75,15 +75,15 @@ void sprite_paint_setup(paint_session* session, const uint16_t x, const uint16_t
// height of the slope element, and consequently clipped.
if ((session->ViewFlags & VIEWPORT_FLAG_CLIP_VIEW))
{
if (spr->generic.z > (gClipHeight * 8))
if (spr->generic.z > (gClipHeight * COORDS_Z_STEP))
{
continue;
}
if (spr->generic.x / 32 < gClipSelectionA.x || spr->generic.x / 32 > gClipSelectionB.x)
if (spr->generic.x < gClipSelectionA.x || spr->generic.x > gClipSelectionB.x)
{
continue;
}
if (spr->generic.y / 32 < gClipSelectionA.y || spr->generic.y / 32 > gClipSelectionB.y)
if (spr->generic.y < gClipSelectionA.y || spr->generic.y > gClipSelectionB.y)
{
continue;
}

View File

@ -520,9 +520,11 @@ static bool tile_is_inside_clip_view(const tile_descriptor& tile)
if (tile.tile_element->base_height > gClipHeight)
return false;
if (tile.tile_coords.x < gClipSelectionA.x || tile.tile_coords.x > gClipSelectionB.x)
auto coords = tile.tile_coords.ToCoordsXY();
if (coords.x < gClipSelectionA.x || coords.x > gClipSelectionB.x)
return false;
if (tile.tile_coords.y < gClipSelectionA.y || tile.tile_coords.y > gClipSelectionB.y)
if (coords.y < gClipSelectionA.y || coords.y > gClipSelectionB.y)
return false;
return true;
@ -913,7 +915,7 @@ static std::pair<int32_t, int32_t> surface_get_height_above_water(
int32_t waterHeight = surfaceElement.GetWaterHeight();
if (waterHeight > height)
{
localHeight += (2 * COORDS_Z_STEP);
localHeight += LAND_HEIGHT_STEP;
if (waterHeight != localHeight || !(localSurfaceShape & TILE_ELEMENT_SURFACE_DIAGONAL_FLAG))
{

View File

@ -140,9 +140,9 @@ static void sub_68B3FB(paint_session* session, int32_t x, int32_t y)
if ((session->ViewFlags & VIEWPORT_FLAG_CLIP_VIEW))
{
if (x / 32 < gClipSelectionA.x || x / 32 > gClipSelectionB.x)
if (x < gClipSelectionA.x || x > gClipSelectionB.x)
return;
if (y / 32 < gClipSelectionA.y || y / 32 > gClipSelectionB.y)
if (y < gClipSelectionA.y || y > gClipSelectionB.y)
return;
}

View File

@ -3482,8 +3482,8 @@ void Guest::UpdateRideAtEntrance()
int16_t actionZ = z;
if (xy_distance < 16)
{
auto entrance = ride_get_entrance_location(ride, current_ride_station);
actionZ = entrance.z * 8 + 2;
auto entrance = ride_get_entrance_location(ride, current_ride_station).ToCoordsXYZ();
actionZ = entrance.z + 2;
}
MoveTo((*loc).x, (*loc).y, actionZ);
}

View File

@ -134,7 +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->NextLoc, peep->NextLoc.z, peep->NextLoc.z + PATH_HEIGHT };
auto pathPos = CoordsXYRangedZ{ peep->NextLoc, peep->NextLoc.z, peep->NextLoc.z + PATH_CLEARANCE };
Direction randDirection = scenario_rand() & 3;
if (!fence_in_the_way(pathPos, randDirection))

View File

@ -554,8 +554,8 @@ void RCT12TileElement::ClearAs(uint8_t newType)
{
type = newType;
flags = 0;
base_height = 2;
clearance_height = 2;
base_height = MINIMUM_LAND_HEIGHT;
clearance_height = MINIMUM_LAND_HEIGHT;
std::fill_n(pad_04, sizeof(pad_04), 0x00);
}

View File

@ -1088,28 +1088,22 @@ void ride_remove_peeps(Ride* ride)
int8_t stationIndex = ride_get_first_valid_station_start(ride);
// Get exit position and direction
int32_t exitX = 0;
int32_t exitY = 0;
int32_t exitZ = 0;
int32_t exitDirection = INVALID_DIRECTION;
auto exitPosition = CoordsXYZD{ 0, 0, 0, INVALID_DIRECTION };
if (stationIndex != -1)
{
TileCoordsXYZD location = ride_get_exit_location(ride, stationIndex);
auto location = ride_get_exit_location(ride, stationIndex).ToCoordsXYZD();
if (!location.isNull())
{
exitX = location.x;
exitY = location.y;
exitZ = location.z;
exitDirection = location.direction;
exitX = (exitX * 32) - (DirectionOffsets[exitDirection].x * 20) + 16;
exitY = (exitY * 32) - (DirectionOffsets[exitDirection].y * 20) + 16;
exitZ = (exitZ * 8) + 2;
exitPosition = location;
exitPosition.x += (DirectionOffsets[exitPosition.direction].x * 20);
exitPosition.y += (DirectionOffsets[exitPosition.direction].y * 20);
exitPosition = exitPosition.ToTileCentre();
exitPosition.z += 2;
// Reverse direction
exitDirection = direction_reverse(exitDirection);
exitPosition.direction = direction_reverse(exitPosition.direction);
exitDirection *= 8;
exitPosition.direction *= 8;
}
}
@ -1130,7 +1124,7 @@ void ride_remove_peeps(Ride* ride)
peep->Invalidate();
if (exitDirection == INVALID_DIRECTION)
if (exitPosition.direction == INVALID_DIRECTION)
{
CoordsXYZ newLoc = { peep->NextLoc.ToTileCentre(), peep->NextLoc.z };
if (peep->GetNextIsSloped())
@ -1140,8 +1134,8 @@ void ride_remove_peeps(Ride* ride)
}
else
{
sprite_move(exitX, exitY, exitZ, peep);
peep->sprite_direction = exitDirection;
sprite_move(exitPosition.x, exitPosition.y, exitPosition.z, peep);
peep->sprite_direction = exitPosition.direction;
}
peep->Invalidate();

View File

@ -47,6 +47,8 @@ constexpr uint16_t const MAX_INVERSIONS = RCT12_MAX_INVERSIONS;
constexpr uint16_t const MAX_GOLF_HOLES = RCT12_MAX_GOLF_HOLES;
constexpr uint16_t const MAX_HELICES = RCT12_MAX_HELICES;
constexpr uint16_t const MAZE_CLEARANCE_HEIGHT = 4 * COORDS_Z_STEP;
#pragma pack(push, 1)
/**

View File

@ -80,7 +80,7 @@ enum
};
#define MAX_STATION_PLATFORM_LENGTH 32
constexpr uint16_t const MAX_TRACK_HEIGHT = 254;
constexpr uint16_t const MAX_TRACK_HEIGHT = 254 * COORDS_Z_STEP;
enum
{

View File

@ -907,7 +907,7 @@ static bool TrackDesignPlaceSceneryElementRemoveGhost(
return true;
}
int32_t z = (scenery.z * 8 + originZ) / 8;
int32_t z = (scenery.z * COORDS_Z_STEP) + originZ;
uint8_t sceneryRotation = (rotation + scenery.flags) & TILE_ELEMENT_DIRECTION_MASK;
const uint32_t flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND
| GAME_COMMAND_FLAG_GHOST;
@ -929,17 +929,17 @@ static bool TrackDesignPlaceSceneryElementRemoveGhost(
quadrant = 0;
}
ga = std::make_unique<SmallSceneryRemoveAction>(CoordsXYZ{ mapCoord.x, mapCoord.y, z * 8 }, quadrant, entry_index);
ga = std::make_unique<SmallSceneryRemoveAction>(CoordsXYZ{ mapCoord.x, mapCoord.y, z }, quadrant, entry_index);
break;
}
case OBJECT_TYPE_LARGE_SCENERY:
ga = std::make_unique<LargeSceneryRemoveAction>(CoordsXYZD{ mapCoord.x, mapCoord.y, z * 8, sceneryRotation }, 0);
ga = std::make_unique<LargeSceneryRemoveAction>(CoordsXYZD{ mapCoord.x, mapCoord.y, z, sceneryRotation }, 0);
break;
case OBJECT_TYPE_WALLS:
ga = std::make_unique<WallRemoveAction>(CoordsXYZD{ mapCoord.x, mapCoord.y, z * 8, sceneryRotation });
ga = std::make_unique<WallRemoveAction>(CoordsXYZD{ mapCoord.x, mapCoord.y, z, sceneryRotation });
break;
case OBJECT_TYPE_PATHS:
ga = std::make_unique<FootpathRemoveAction>(CoordsXYZ{ mapCoord.x, mapCoord.y, z * 8 });
ga = std::make_unique<FootpathRemoveAction>(CoordsXYZ{ mapCoord.x, mapCoord.y, z });
break;
default:
return true;
@ -1058,7 +1058,7 @@ static bool TrackDesignPlaceSceneryElement(
rotation += scenery.flags;
rotation &= 3;
z = scenery.z * 8 + originZ;
z = scenery.z * COORDS_Z_STEP + originZ;
flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_PATH_SCENERY;
if (_trackDesignPlaceOperation == PTD_OPERATION_PLACE_TRACK_PREVIEW)
@ -1096,7 +1096,7 @@ static bool TrackDesignPlaceSceneryElement(
return true;
}
z = scenery.z * 8 + originZ;
z = scenery.z * COORDS_Z_STEP + originZ;
rotation += scenery.flags;
rotation &= 3;
@ -1132,7 +1132,7 @@ static bool TrackDesignPlaceSceneryElement(
return true;
}
z = (scenery.z * 8 + originZ) / 8;
z = (scenery.z * COORDS_Z_STEP + originZ) / COORDS_Z_STEP;
if (mode == 0)
{
if (scenery.flags & (1 << 7))
@ -1167,7 +1167,7 @@ static bool TrackDesignPlaceSceneryElement(
uint8_t slope = ((bh >> 5) & 0x3) | ((bh >> 2) & 0x4);
uint8_t edges = bh & 0xF;
auto footpathPlaceAction = FootpathPlaceFromTrackAction(
{ mapCoord.x, mapCoord.y, z * 8 }, slope, entry_index, edges);
{ mapCoord.x, mapCoord.y, z * COORDS_Z_STEP }, slope, entry_index, edges);
footpathPlaceAction.SetFlags(flags);
auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&footpathPlaceAction)
: GameActions::QueryNested(&footpathPlaceAction);
@ -1429,10 +1429,10 @@ static int32_t track_design_place_maze(TrackDesign* td6, int16_t x, int16_t y, i
int16_t surfaceZ = surfaceElement->GetBaseZ();
if (surfaceElement->GetSlope() & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP)
{
surfaceZ += 16;
surfaceZ += LAND_HEIGHT_STEP;
if (surfaceElement->GetSlope() & TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT)
{
surfaceZ += 16;
surfaceZ += LAND_HEIGHT_STEP;
}
}
@ -1593,10 +1593,10 @@ static bool track_design_place_ride(TrackDesign* td6, int16_t x, int16_t y, int1
int32_t surfaceZ = surfaceElement->GetBaseZ();
if (surfaceElement->GetSlope() & TILE_ELEMENT_SLOPE_ALL_CORNERS_UP)
{
surfaceZ += 16;
surfaceZ += LAND_HEIGHT_STEP;
if (surfaceElement->GetSlope() & TILE_ELEMENT_SLOPE_DOUBLE_HEIGHT)
{
surfaceZ += 16;
surfaceZ += LAND_HEIGHT_STEP;
}
}
@ -1660,7 +1660,7 @@ static bool track_design_place_ride(TrackDesign* td6, int16_t x, int16_t y, int1
{
auto tile = CoordsXY{ x, y } + CoordsDirectionDelta[rotation];
TileElement* tile_element = map_get_first_element_at(tile);
z = gTrackPreviewOrigin.z / 8;
z = gTrackPreviewOrigin.z / COORDS_Z_STEP;
z += entrance.z;
if (tile_element == nullptr)
{
@ -1716,7 +1716,7 @@ static bool track_design_place_ride(TrackDesign* td6, int16_t x, int16_t y, int1
}
else
{
z = entrance.z * 8;
z = entrance.z * COORDS_Z_STEP;
z += gTrackPreviewOrigin.z;
auto res = RideEntranceExitPlaceAction::TrackPlaceQuery({ x, y, z }, false);

View File

@ -29,12 +29,16 @@ assert_struct_size(rct_entrance_type, 8);
struct TileElement;
constexpr const uint8_t ParkEntranceHeight = 12 * COORDS_Z_STEP;
constexpr const uint8_t RideEntranceHeight = 7 * COORDS_Z_STEP;
constexpr const uint8_t RideExitHeight = 5 * COORDS_Z_STEP;
extern bool gParkEntranceGhostExists;
extern CoordsXYZD gParkEntranceGhostPosition;
#define MAX_PARK_ENTRANCES 4
constexpr int32_t MaxRideEntranceOrExitHeight = 244;
constexpr int32_t MaxRideEntranceOrExitHeight = 244 * COORDS_Z_STEP;
extern std::vector<CoordsXYZD> gParkEntrances;

View File

@ -23,7 +23,7 @@ enum
constexpr auto FootpathMaxHeight = 248;
constexpr auto FootpathMinHeight = 2;
constexpr auto PATH_HEIGHT_STEP = 2 * COORDS_Z_STEP;
constexpr auto PATH_HEIGHT = 4 * COORDS_Z_STEP;
constexpr auto PATH_CLEARANCE = 4 * COORDS_Z_STEP;
#define FOOTPATH_ELEMENT_INSERT_QUEUE 0x80

View File

@ -17,6 +17,7 @@
constexpr const int32_t COORDS_XY_STEP = 32;
constexpr const int32_t COORDS_Z_STEP = 8;
constexpr const int32_t COORDS_Z_PER_TINY_Z = 16;
constexpr const auto NumOrthogonalDirections = 4;
@ -173,12 +174,12 @@ struct CoordsXY
CoordsXY ToTileCentre() const
{
return ToTileStart() + CoordsXY{ 16, 16 };
return ToTileStart() + CoordsXY{ (COORDS_XY_STEP / 2), (COORDS_XY_STEP / 2) };
}
CoordsXY ToTileStart() const
{
return { floor2(x, 32), floor2(y, 32) };
return { floor2(x, COORDS_XY_STEP), floor2(y, COORDS_XY_STEP) };
}
bool isNull() const
@ -226,8 +227,8 @@ struct TileCoordsXY
}
explicit TileCoordsXY(const CoordsXY& c)
: x(c.x / 32)
, y(c.y / 32)
: x(c.x / COORDS_XY_STEP)
, y(c.y / COORDS_XY_STEP)
{
}
@ -252,7 +253,7 @@ struct TileCoordsXY
CoordsXY ToCoordsXY() const
{
return { x * 32, y * 32 };
return { x * COORDS_XY_STEP, y * COORDS_XY_STEP };
}
TileCoordsXY Rotate(int32_t direction) const
@ -337,12 +338,12 @@ struct CoordsXYZ : public CoordsXY
CoordsXYZ ToTileStart() const
{
return { floor2(x, 32), floor2(y, 32), z };
return { floor2(x, COORDS_XY_STEP), floor2(y, COORDS_XY_STEP), z };
}
CoordsXYZ ToTileCentre() const
{
return ToTileStart() + CoordsXYZ{ 16, 16, z };
return ToTileStart() + CoordsXYZ{ (COORDS_XY_STEP / 2), (COORDS_XY_STEP / 2), z };
}
};
@ -401,7 +402,7 @@ struct TileCoordsXYZ : public TileCoordsXY
CoordsXYZ ToCoordsXYZ() const
{
return { x * 32, y * 32, z * 8 };
return { x * COORDS_XY_STEP, y * COORDS_XY_STEP, z * COORDS_Z_STEP };
}
};
@ -488,6 +489,38 @@ struct CoordsXYZD : public CoordsXYZ
{
return !(*this == other);
}
CoordsXYZD& operator+=(const CoordsXY& rhs)
{
x += rhs.x;
y += rhs.y;
return *this;
}
const CoordsXYZD operator+(const CoordsXY& rhs) const
{
return { x + rhs.x, y + rhs.y, z, direction };
}
const CoordsXYZD operator+(const CoordsXYZ& rhs) const
{
return { x + rhs.x, y + rhs.y, z + rhs.z, direction };
}
const CoordsXYZD operator-(const CoordsXYZ& rhs) const
{
return { x - rhs.x, y - rhs.y, z - rhs.z, direction };
}
CoordsXYZD ToTileStart() const
{
return { floor2(x, COORDS_XY_STEP), floor2(y, COORDS_XY_STEP), z, direction };
}
CoordsXYZD ToTileCentre() const
{
return ToTileStart() + CoordsXYZD{ (COORDS_XY_STEP / 2), (COORDS_XY_STEP / 2), z, direction };
}
};
struct TileCoordsXYZD : public TileCoordsXYZ
@ -527,7 +560,7 @@ struct TileCoordsXYZD : public TileCoordsXYZ
CoordsXYZD ToCoordsXYZD() const
{
return { x * 32, y * 32, z * 8, direction };
return { x * COORDS_XY_STEP, y * COORDS_XY_STEP, z * COORDS_Z_STEP, direction };
}
};

View File

@ -416,14 +416,14 @@ int16_t tile_element_height(const CoordsXY& loc)
{
// Off the map
if (!map_is_location_valid(loc))
return 2 * COORDS_Z_STEP;
return MINIMUM_LAND_HEIGHT_BIG;
// Get the surface element for the tile
auto surfaceElement = map_get_surface_element_at(loc);
if (surfaceElement == nullptr)
{
return 2 * COORDS_Z_STEP;
return MINIMUM_LAND_HEIGHT_BIG;
}
uint16_t height = surfaceElement->GetBaseZ();
@ -1679,8 +1679,8 @@ static void clear_element_at(const CoordsXY& loc, TileElement** elementPtr)
switch (element->GetType())
{
case TILE_ELEMENT_TYPE_SURFACE:
element->base_height = 2;
element->clearance_height = 2;
element->base_height = MINIMUM_LAND_HEIGHT;
element->clearance_height = MINIMUM_LAND_HEIGHT;
element->AsSurface()->SetSlope(TILE_ELEMENT_SLOPE_FLAT);
element->AsSurface()->SetSurfaceStyle(TERRAIN_GRASS);
element->AsSurface()->SetEdgeStyle(TERRAIN_EDGE_ROCK);

View File

@ -29,6 +29,7 @@
constexpr const int32_t MAXIMUM_MAP_SIZE_BIG = COORDS_XY_STEP * MAXIMUM_MAP_SIZE_TECHNICAL;
constexpr const int32_t MAXIMUM_TILE_START_XY = MAXIMUM_MAP_SIZE_BIG - COORDS_XY_STEP;
constexpr const int32_t LAND_HEIGHT_STEP = 2 * COORDS_Z_STEP;
constexpr const int32_t MINIMUM_LAND_HEIGHT_BIG = MINIMUM_LAND_HEIGHT * COORDS_Z_STEP;
#define MAP_MINIMUM_X_Y (-MAXIMUM_MAP_SIZE_TECHNICAL)

View File

@ -140,22 +140,22 @@ void update_park_fences(const CoordsXY& coords)
// As map_is_location_in_park sets the error text
// will require to back it up.
rct_string_id previous_error = gGameCommandErrorText;
if (map_is_location_in_park({ coords.x - 32, coords.y }))
if (map_is_location_in_park({ coords.x - COORDS_XY_STEP, coords.y }))
{
newFences |= 0x8;
}
if (map_is_location_in_park({ coords.x, coords.y - 32 }))
if (map_is_location_in_park({ coords.x, coords.y - COORDS_XY_STEP }))
{
newFences |= 0x4;
}
if (map_is_location_in_park({ coords.x + 32, coords.y }))
if (map_is_location_in_park({ coords.x + COORDS_XY_STEP, coords.y }))
{
newFences |= 0x2;
}
if (map_is_location_in_park({ coords.x, coords.y + 32 }))
if (map_is_location_in_park({ coords.x, coords.y + COORDS_XY_STEP }))
{
newFences |= 0x1;
}
@ -176,10 +176,10 @@ void update_park_fences(const CoordsXY& coords)
void update_park_fences_around_tile(const CoordsXY& coords)
{
update_park_fences(coords);
update_park_fences({ coords.x + 32, coords.y });
update_park_fences({ coords.x - 32, coords.y });
update_park_fences({ coords.x, coords.y + 32 });
update_park_fences({ coords.x, coords.y - 32 });
update_park_fences({ coords.x + COORDS_XY_STEP, coords.y });
update_park_fences({ coords.x - COORDS_XY_STEP, coords.y });
update_park_fences({ coords.x, coords.y + COORDS_XY_STEP });
update_park_fences({ coords.x, coords.y - COORDS_XY_STEP });
}
void set_forced_park_rating(int32_t rating)

View File

@ -159,8 +159,8 @@ void TileElement::ClearAs(uint8_t newType)
{
type = newType;
Flags = 0;
base_height = 2;
clearance_height = 2;
base_height = MINIMUM_LAND_HEIGHT;
clearance_height = MINIMUM_LAND_HEIGHT;
std::fill_n(pad_04, sizeof(pad_04), 0x00);
std::fill_n(pad_08, sizeof(pad_08), 0x00);
}

View File

@ -32,8 +32,8 @@ int16_t gMapBaseZ;
bool gTrackDesignSaveMode = false;
uint8_t gTrackDesignSaveRideIndex = RIDE_ID_NULL;
uint8_t gClipHeight = 255;
TileCoordsXY gClipSelectionA = { 0, 0 };
TileCoordsXY gClipSelectionB = { MAXIMUM_MAP_SIZE_TECHNICAL - 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1 };
CoordsXY gClipSelectionA = { 0, 0 };
CoordsXY gClipSelectionB = { MAXIMUM_TILE_START_XY, MAXIMUM_TILE_START_XY };
uint32_t gScenarioTicks;
uint8_t gCurrentRotation;

View File

@ -270,7 +270,7 @@ static uint8_t TestTrackElementPaintCalls(uint8_t rideType, uint8_t trackType, u
TileElement surfaceElement = {};
surfaceElement.SetType(TILE_ELEMENT_TYPE_SURFACE);
surfaceElement.base_height = 2;
surfaceElement.base_height = MINIMUM_LAND_HEIGHT;
gSurfaceElement = &surfaceElement;
gDidPassSurface = true;
@ -433,7 +433,7 @@ static uint8_t TestTrackElementSegmentSupportHeight(
TileElement surfaceElement = {};
surfaceElement.SetType(TILE_ELEMENT_TYPE_SURFACE);
surfaceElement.base_height = 2;
surfaceElement.base_height = MINIMUM_LAND_HEIGHT;
gSurfaceElement = &surfaceElement;
gDidPassSurface = true;
@ -520,7 +520,7 @@ static uint8_t TestTrackElementGeneralSupportHeight(
TileElement surfaceElement = {};
surfaceElement.SetType(TILE_ELEMENT_TYPE_SURFACE);
surfaceElement.base_height = 2;
surfaceElement.base_height = MINIMUM_LAND_HEIGHT;
gSurfaceElement = &surfaceElement;
gDidPassSurface = true;
@ -621,7 +621,7 @@ static uint8_t TestTrackElementSideTunnels(uint8_t rideType, uint8_t trackType,
TileElement surfaceElement = {};
surfaceElement.SetType(TILE_ELEMENT_TYPE_SURFACE);
surfaceElement.base_height = 2;
surfaceElement.base_height = MINIMUM_LAND_HEIGHT;
gSurfaceElement = &surfaceElement;
gDidPassSurface = true;
@ -749,7 +749,7 @@ static uint8_t TestTrackElementVerticalTunnels(uint8_t rideType, uint8_t trackTy
TileElement surfaceElement = {};
surfaceElement.SetType(TILE_ELEMENT_TYPE_SURFACE);
surfaceElement.base_height = 2;
surfaceElement.base_height = MINIMUM_LAND_HEIGHT;
gSurfaceElement = &surfaceElement;
gDidPassSurface = true;