mirror of https://github.com/OpenRCT2/OpenRCT2.git
Use big Z in more places
This commit is contained in:
parent
7759b54c2f
commit
ad91654a3d
|
@ -147,7 +147,7 @@ public:
|
|||
banner->position.y = _loc.y / 32;
|
||||
newTileElement->SetType(TILE_ELEMENT_TYPE_BANNER);
|
||||
BannerElement* bannerElement = newTileElement->AsBanner();
|
||||
bannerElement->clearance_height = newTileElement->base_height + 2;
|
||||
bannerElement->SetClearanceZ(_loc.z + PATH_CLEARANCE);
|
||||
bannerElement->SetPosition(_loc.direction);
|
||||
bannerElement->ResetAllowedEdges();
|
||||
bannerElement->SetIndex(_bannerIndex);
|
||||
|
|
|
@ -73,7 +73,7 @@ private:
|
|||
res->Position.z = z;
|
||||
res->Expenditure = ExpenditureType::Landscaping;
|
||||
|
||||
uint8_t maxHeight = GetHighestHeight(validRange);
|
||||
auto maxHeight = GetHighestHeight(validRange) / COORDS_Z_STEP;
|
||||
bool hasChanged = false;
|
||||
for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP)
|
||||
{
|
||||
|
@ -125,10 +125,10 @@ private:
|
|||
}
|
||||
|
||||
private:
|
||||
uint8_t GetHighestHeight(MapRange validRange) const
|
||||
uint16_t GetHighestHeight(MapRange validRange) const
|
||||
{
|
||||
// The highest height to raise the water to is the lowest water level in the selection
|
||||
uint8_t maxHeight{ 255 };
|
||||
uint16_t maxHeight = 255 * COORDS_Z_STEP;
|
||||
for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += COORDS_XY_STEP)
|
||||
{
|
||||
for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += COORDS_XY_STEP)
|
||||
|
@ -137,10 +137,10 @@ private:
|
|||
if (surfaceElement == nullptr)
|
||||
continue;
|
||||
|
||||
uint8_t height = surfaceElement->base_height;
|
||||
auto height = surfaceElement->GetBaseZ();
|
||||
if (surfaceElement->GetWaterHeight() > 0)
|
||||
{
|
||||
height = surfaceElement->GetWaterHeight() / COORDS_Z_STEP;
|
||||
height = surfaceElement->GetWaterHeight();
|
||||
}
|
||||
|
||||
if (maxHeight > height)
|
||||
|
|
|
@ -1027,8 +1027,8 @@ public:
|
|||
uint8_t tileElementType = src->GetType();
|
||||
dst->ClearAs(tileElementType);
|
||||
dst->SetDirection(src->GetDirection());
|
||||
dst->base_height = src->base_height;
|
||||
dst->clearance_height = src->clearance_height;
|
||||
dst->SetBaseZ(src->base_height * COORDS_Z_STEP);
|
||||
dst->SetClearanceZ(src->clearance_height * COORDS_Z_STEP);
|
||||
|
||||
// All saved in "flags"
|
||||
dst->SetOccupiedQuadrants(src->GetOccupiedQuadrants());
|
||||
|
|
|
@ -6858,7 +6858,6 @@ void sub_6CB945(Ride* ride)
|
|||
continue;
|
||||
|
||||
CoordsXYZ location = ride->stations[stationId].GetStart();
|
||||
auto tileHeight = TileCoordsXYZ(location).z;
|
||||
uint8_t direction = INVALID_DIRECTION;
|
||||
|
||||
bool specialTrack = false;
|
||||
|
@ -6878,7 +6877,7 @@ void sub_6CB945(Ride* ride)
|
|||
bool trackFound = false;
|
||||
do
|
||||
{
|
||||
if (tileElement->base_height != tileHeight)
|
||||
if (tileElement->GetBaseZ() != location.z)
|
||||
continue;
|
||||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
|
||||
continue;
|
||||
|
|
|
@ -201,12 +201,11 @@ static void ride_ratings_update_state_2()
|
|||
return;
|
||||
}
|
||||
|
||||
int32_t x = gRideRatingsCalcData.proximity_x / 32;
|
||||
int32_t y = gRideRatingsCalcData.proximity_y / 32;
|
||||
int32_t z = gRideRatingsCalcData.proximity_z / 8;
|
||||
auto loc = CoordsXYZ{ gRideRatingsCalcData.proximity_x, gRideRatingsCalcData.proximity_y,
|
||||
gRideRatingsCalcData.proximity_z };
|
||||
int32_t trackType = gRideRatingsCalcData.proximity_track_type;
|
||||
|
||||
TileElement* tileElement = map_get_first_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
|
||||
TileElement* tileElement = map_get_first_element_at(loc);
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
|
||||
|
@ -218,7 +217,7 @@ static void ride_ratings_update_state_2()
|
|||
continue;
|
||||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
|
||||
continue;
|
||||
if (tileElement->base_height != z)
|
||||
if (tileElement->GetBaseZ() != loc.z)
|
||||
continue;
|
||||
if (tileElement->AsTrack()->GetRideIndex() != ride->id)
|
||||
{
|
||||
|
@ -254,19 +253,17 @@ static void ride_ratings_update_state_2()
|
|||
return;
|
||||
}
|
||||
|
||||
x = nextTrackElement.x;
|
||||
y = nextTrackElement.y;
|
||||
z = nextTrackElement.element->GetBaseZ();
|
||||
loc = { nextTrackElement, nextTrackElement.element->GetBaseZ() };
|
||||
tileElement = nextTrackElement.element;
|
||||
if (x == gRideRatingsCalcData.proximity_start_x && y == gRideRatingsCalcData.proximity_start_y
|
||||
&& z == gRideRatingsCalcData.proximity_start_z)
|
||||
if (loc.x == gRideRatingsCalcData.proximity_start_x && loc.y == gRideRatingsCalcData.proximity_start_y
|
||||
&& loc.z == gRideRatingsCalcData.proximity_start_z)
|
||||
{
|
||||
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_CALCULATE;
|
||||
return;
|
||||
}
|
||||
gRideRatingsCalcData.proximity_x = x;
|
||||
gRideRatingsCalcData.proximity_y = y;
|
||||
gRideRatingsCalcData.proximity_z = z;
|
||||
gRideRatingsCalcData.proximity_x = loc.x;
|
||||
gRideRatingsCalcData.proximity_y = loc.y;
|
||||
gRideRatingsCalcData.proximity_z = loc.z;
|
||||
gRideRatingsCalcData.proximity_track_type = tileElement->AsTrack()->GetTrackType();
|
||||
return;
|
||||
}
|
||||
|
@ -318,12 +315,11 @@ static void ride_ratings_update_state_5()
|
|||
return;
|
||||
}
|
||||
|
||||
int32_t x = gRideRatingsCalcData.proximity_x / 32;
|
||||
int32_t y = gRideRatingsCalcData.proximity_y / 32;
|
||||
int32_t z = gRideRatingsCalcData.proximity_z / 8;
|
||||
auto loc = CoordsXYZ{ gRideRatingsCalcData.proximity_x, gRideRatingsCalcData.proximity_y,
|
||||
gRideRatingsCalcData.proximity_z };
|
||||
int32_t trackType = gRideRatingsCalcData.proximity_track_type;
|
||||
|
||||
TileElement* tileElement = map_get_first_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
|
||||
TileElement* tileElement = map_get_first_element_at(loc);
|
||||
if (tileElement == nullptr)
|
||||
{
|
||||
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
|
||||
|
@ -335,7 +331,7 @@ static void ride_ratings_update_state_5()
|
|||
continue;
|
||||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
|
||||
continue;
|
||||
if (tileElement->base_height != z)
|
||||
if (tileElement->GetBaseZ() != loc.z)
|
||||
continue;
|
||||
if (tileElement->AsTrack()->GetRideIndex() != ride->id)
|
||||
{
|
||||
|
@ -348,27 +344,27 @@ static void ride_ratings_update_state_5()
|
|||
{
|
||||
ride_ratings_score_close_proximity(tileElement);
|
||||
|
||||
x = gRideRatingsCalcData.proximity_x;
|
||||
y = gRideRatingsCalcData.proximity_y;
|
||||
loc.x = gRideRatingsCalcData.proximity_x;
|
||||
loc.y = gRideRatingsCalcData.proximity_y;
|
||||
track_begin_end trackBeginEnd;
|
||||
if (!track_block_get_previous(x, y, tileElement, &trackBeginEnd))
|
||||
if (!track_block_get_previous(loc.x, loc.y, tileElement, &trackBeginEnd))
|
||||
{
|
||||
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_CALCULATE;
|
||||
return;
|
||||
}
|
||||
|
||||
x = trackBeginEnd.begin_x;
|
||||
y = trackBeginEnd.begin_y;
|
||||
z = trackBeginEnd.begin_z;
|
||||
if (x == gRideRatingsCalcData.proximity_start_x && y == gRideRatingsCalcData.proximity_start_y
|
||||
&& z == gRideRatingsCalcData.proximity_start_z)
|
||||
loc.x = trackBeginEnd.begin_x;
|
||||
loc.y = trackBeginEnd.begin_y;
|
||||
loc.z = trackBeginEnd.begin_z;
|
||||
if (loc.x == gRideRatingsCalcData.proximity_start_x && loc.y == gRideRatingsCalcData.proximity_start_y
|
||||
&& loc.z == gRideRatingsCalcData.proximity_start_z)
|
||||
{
|
||||
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_CALCULATE;
|
||||
return;
|
||||
}
|
||||
gRideRatingsCalcData.proximity_x = x;
|
||||
gRideRatingsCalcData.proximity_y = y;
|
||||
gRideRatingsCalcData.proximity_z = z;
|
||||
gRideRatingsCalcData.proximity_x = loc.x;
|
||||
gRideRatingsCalcData.proximity_y = loc.y;
|
||||
gRideRatingsCalcData.proximity_z = loc.z;
|
||||
gRideRatingsCalcData.proximity_track_type = trackBeginEnd.begin_element->AsTrack()->GetTrackType();
|
||||
return;
|
||||
}
|
||||
|
@ -613,11 +609,11 @@ static void ride_ratings_score_close_proximity(TileElement* inputTileElement)
|
|||
// Bonus for normal path
|
||||
if (tileElement->AsPath()->GetSurfaceEntryIndex() != 0)
|
||||
{
|
||||
if (tileElement->clearance_height == inputTileElement->base_height)
|
||||
if (tileElement->GetClearanceZ() == inputTileElement->GetBaseZ())
|
||||
{
|
||||
proximity_score_increment(PROXIMITY_PATH_TOUCH_ABOVE);
|
||||
}
|
||||
if (tileElement->base_height == inputTileElement->clearance_height)
|
||||
if (tileElement->GetBaseZ() == inputTileElement->GetClearanceZ())
|
||||
{
|
||||
proximity_score_increment(PROXIMITY_PATH_TOUCH_UNDER);
|
||||
}
|
||||
|
@ -625,15 +621,15 @@ static void ride_ratings_score_close_proximity(TileElement* inputTileElement)
|
|||
else
|
||||
{
|
||||
// Bonus for path in first object entry
|
||||
if (tileElement->clearance_height <= inputTileElement->base_height)
|
||||
if (tileElement->GetClearanceZ() <= inputTileElement->GetBaseZ())
|
||||
{
|
||||
proximity_score_increment(PROXIMITY_PATH_ZERO_OVER);
|
||||
}
|
||||
if (tileElement->clearance_height == inputTileElement->base_height)
|
||||
if (tileElement->GetClearanceZ() == inputTileElement->GetBaseZ())
|
||||
{
|
||||
proximity_score_increment(PROXIMITY_PATH_ZERO_TOUCH_ABOVE);
|
||||
}
|
||||
if (tileElement->base_height == inputTileElement->clearance_height)
|
||||
if (tileElement->GetBaseZ() == inputTileElement->GetClearanceZ())
|
||||
{
|
||||
proximity_score_increment(PROXIMITY_PATH_ZERO_TOUCH_UNDER);
|
||||
}
|
||||
|
@ -656,7 +652,7 @@ static void ride_ratings_score_close_proximity(TileElement* inputTileElement)
|
|||
if (inputTileElement->AsTrack()->GetRideIndex() != tileElement->AsTrack()->GetRideIndex())
|
||||
{
|
||||
proximity_score_increment(PROXIMITY_FOREIGN_TRACK_ABOVE_OR_BELOW);
|
||||
if (tileElement->clearance_height == inputTileElement->base_height)
|
||||
if (tileElement->GetClearanceZ() == inputTileElement->GetBaseZ())
|
||||
{
|
||||
proximity_score_increment(PROXIMITY_FOREIGN_TRACK_TOUCH_ABOVE);
|
||||
}
|
||||
|
@ -705,7 +701,7 @@ static void ride_ratings_score_close_proximity(TileElement* inputTileElement)
|
|||
}
|
||||
}
|
||||
|
||||
if (inputTileElement->clearance_height == tileElement->base_height)
|
||||
if (inputTileElement->GetClearanceZ() == tileElement->GetBaseZ())
|
||||
{
|
||||
proximity_score_increment(PROXIMITY_OWN_TRACK_TOUCH_ABOVE);
|
||||
if (isStation)
|
||||
|
|
|
@ -596,14 +596,14 @@ const rct_preview_track* get_track_def_from_ride_index(ride_id_t rideIndex, int3
|
|||
return get_track_def_from_ride(get_ride(rideIndex), trackType);
|
||||
}
|
||||
|
||||
static TileElement* find_station_element(int32_t x, int32_t y, int32_t z, int32_t direction, ride_id_t rideIndex)
|
||||
static TileElement* find_station_element(const CoordsXYZ& loc, int32_t direction, ride_id_t rideIndex)
|
||||
{
|
||||
TileElement* tileElement = map_get_first_element_at({ x, y });
|
||||
TileElement* tileElement = map_get_first_element_at(loc);
|
||||
if (tileElement == nullptr)
|
||||
return nullptr;
|
||||
do
|
||||
{
|
||||
if (z != tileElement->base_height)
|
||||
if (loc.z != tileElement->GetBaseZ())
|
||||
continue;
|
||||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
|
||||
continue;
|
||||
|
@ -681,7 +681,7 @@ bool track_add_station_element(int32_t x, int32_t y, int32_t z, int32_t directio
|
|||
x -= CoordsDirectionDelta[direction].x;
|
||||
y -= CoordsDirectionDelta[direction].y;
|
||||
|
||||
stationElement = find_station_element(x, y, z, direction, rideIndex);
|
||||
stationElement = find_station_element({ x, y, z * COORDS_Z_STEP }, direction, rideIndex);
|
||||
if (stationElement != nullptr)
|
||||
{
|
||||
if (stationElement->AsTrack()->GetTrackType() == TRACK_ELEM_END_STATION)
|
||||
|
@ -706,7 +706,7 @@ bool track_add_station_element(int32_t x, int32_t y, int32_t z, int32_t directio
|
|||
x += CoordsDirectionDelta[direction].x;
|
||||
y += CoordsDirectionDelta[direction].y;
|
||||
|
||||
stationElement = find_station_element(x, y, z, direction, rideIndex);
|
||||
stationElement = find_station_element({ x, y, z * COORDS_Z_STEP }, direction, rideIndex);
|
||||
if (stationElement != nullptr)
|
||||
{
|
||||
if (stationElement->AsTrack()->GetTrackType() == TRACK_ELEM_END_STATION)
|
||||
|
@ -745,7 +745,7 @@ bool track_add_station_element(int32_t x, int32_t y, int32_t z, int32_t directio
|
|||
{
|
||||
finaliseStationDone = true;
|
||||
|
||||
stationElement = find_station_element(x, y, z, direction, rideIndex);
|
||||
stationElement = find_station_element({ x, y, z * COORDS_Z_STEP }, direction, rideIndex);
|
||||
if (stationElement != nullptr)
|
||||
{
|
||||
int32_t targetTrackType;
|
||||
|
@ -825,7 +825,7 @@ bool track_remove_station_element(int32_t x, int32_t y, int32_t z, int32_t direc
|
|||
// Search backwards for more station
|
||||
x = stationX0;
|
||||
y = stationY0;
|
||||
while ((stationElement = find_station_element(x, y, z, direction, rideIndex)) != nullptr)
|
||||
while ((stationElement = find_station_element({ x, y, z * COORDS_Z_STEP }, direction, rideIndex)) != nullptr)
|
||||
{
|
||||
if (stationElement->AsTrack()->GetTrackType() == TRACK_ELEM_END_STATION)
|
||||
{
|
||||
|
@ -851,7 +851,7 @@ bool track_remove_station_element(int32_t x, int32_t y, int32_t z, int32_t direc
|
|||
x += CoordsDirectionDelta[direction].x;
|
||||
y += CoordsDirectionDelta[direction].y;
|
||||
|
||||
stationElement = find_station_element(x, y, z, direction, rideIndex);
|
||||
stationElement = find_station_element({ x, y, z * COORDS_Z_STEP }, direction, rideIndex);
|
||||
if (stationElement != nullptr)
|
||||
{
|
||||
if (stationElement->AsTrack()->GetTrackType() == TRACK_ELEM_END_STATION)
|
||||
|
@ -891,7 +891,7 @@ bool track_remove_station_element(int32_t x, int32_t y, int32_t z, int32_t direc
|
|||
|
||||
if (x != removeX || y != removeY)
|
||||
{
|
||||
stationElement = find_station_element(x, y, z, direction, rideIndex);
|
||||
stationElement = find_station_element({ x, y, z * COORDS_Z_STEP }, direction, rideIndex);
|
||||
if (stationElement != nullptr)
|
||||
{
|
||||
int32_t targetTrackType;
|
||||
|
|
|
@ -227,20 +227,20 @@ void TileElementBase::SetOccupiedQuadrants(uint8_t quadrants)
|
|||
|
||||
int32_t TileElementBase::GetBaseZ() const
|
||||
{
|
||||
return base_height * 8;
|
||||
return base_height * COORDS_Z_STEP;
|
||||
}
|
||||
|
||||
void TileElementBase::SetBaseZ(int32_t newZ)
|
||||
{
|
||||
base_height = (newZ / 8);
|
||||
base_height = (newZ / COORDS_Z_STEP);
|
||||
}
|
||||
|
||||
int32_t TileElementBase::GetClearanceZ() const
|
||||
{
|
||||
return clearance_height * 8;
|
||||
return clearance_height * COORDS_Z_STEP;
|
||||
}
|
||||
|
||||
void TileElementBase::SetClearanceZ(int32_t newZ)
|
||||
{
|
||||
clearance_height = (newZ / 8);
|
||||
clearance_height = (newZ / COORDS_Z_STEP);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue