Change ride->overall_view to CoordsXY (#10673)

This commit is contained in:
Michael Steenbeek authored and GitHub committed 2020-02-08 17:19:59 +01:00
1 parent 5da4903430
commit d16fbb0cd2
21 files changed
+46 -66

No files matched your search

+4 -5
View File
@@ -1912,11 +1912,10 @@ static void window_ride_init_viewport(rct_window* w)
}
} while (count >= 0);
auto location = ride->stations[stationIndex].Start;
focus.coordinate.x = location.x * 32;
focus.coordinate.y = location.y * 32;
focus.coordinate.z = ride->stations[stationIndex].GetBaseZ();
auto location = ride->stations[stationIndex].GetStart();
focus.coordinate.x = location.x;
focus.coordinate.y = location.y;
focus.coordinate.z = location.z;
focus.sprite.type |= VIEWPORT_FOCUS_TYPE_COORDINATE;
}
else
@@ -66,9 +66,8 @@ public:
auto banner = GetBanner(_bannerIndex);
res->Expenditure = ExpenditureType::Landscaping;
res->Position.x = banner->position.x * 32 + 16;
res->Position.y = banner->position.y * 32 + 16;
res->Position.z = tile_element_height(res->Position);
auto location = banner->position.ToCoordsXY().ToTileCentre();
res->Position = { location, tile_element_height(location) };
TileElement* tileElement = banner_get_tile_element(_bannerIndex);
@@ -116,9 +115,8 @@ public:
auto banner = GetBanner(_bannerIndex);
res->Expenditure = ExpenditureType::Landscaping;
res->Position.x = banner->position.x * 32 + 16;
res->Position.y = banner->position.y * 32 + 16;
res->Position.z = tile_element_height(res->Position);
auto location = banner->position.ToCoordsXY().ToTileCentre();
res->Position = { location, tile_element_height(location) };
TileElement* tileElement = banner_get_tile_element(_bannerIndex);
@@ -193,8 +193,7 @@ public:
if (ride->maze_tiles == 1)
{
auto tileStartLoc = TileCoordsXY{ startLoc };
ride->overall_view = tileStartLoc;
ride->overall_view = startLoc;
}
return res;
+1 -2
View File
@@ -233,8 +233,7 @@ public:
if (_initialPlacement && !(flags & GAME_COMMAND_FLAG_GHOST))
{
auto tileStartLoc = TileCoordsXY{ startLoc };
ride->overall_view = tileStartLoc;
ride->overall_view = startLoc;
}
}
+4 -10
View File
@@ -241,11 +241,8 @@ private:
if (!ride->overall_view.isNull())
{
int32_t x = (ride->overall_view.x * 32) + 16;
int32_t y = (ride->overall_view.y * 32) + 16;
int32_t z = tile_element_height({ x, y });
res->Position = { x, y, z };
auto xy = ride->overall_view.ToTileCentre();
res->Position = { xy, tile_element_height(xy) };
}
ride->Delete();
@@ -369,11 +366,8 @@ private:
if (!ride->overall_view.isNull())
{
int32_t x = (ride->overall_view.x * 32) + 16;
int32_t y = (ride->overall_view.y * 32) + 16;
int32_t z = tile_element_height({ x, y });
res->Position = { x, y, z };
auto location = ride->overall_view.ToTileCentre();
res->Position = { location, tile_element_height(location) };
}
window_close_by_number(WC_DEMOLISH_RIDE_PROMPT, _rideIndex);
@@ -88,8 +88,7 @@ public:
if (!location.isNull())
{
auto rideEntranceExitRemove = RideEntranceExitRemoveAction(
{ location.x * 32, location.y * 32 }, _rideIndex, _stationNum, _isExit);
auto rideEntranceExitRemove = RideEntranceExitRemoveAction(location.ToCoordsXY(), _rideIndex, _stationNum, _isExit);
rideEntranceExitRemove.SetFlags(GetFlags());
auto result = GameActions::QueryNested(&rideEntranceExitRemove);
@@ -155,8 +154,7 @@ public:
: ride_get_entrance_location(ride, _stationNum);
if (!location.isNull())
{
auto rideEntranceExitRemove = RideEntranceExitRemoveAction(
{ location.x * 32, location.y * 32 }, _rideIndex, _stationNum, _isExit);
auto rideEntranceExitRemove = RideEntranceExitRemoveAction(location.ToCoordsXY(), _rideIndex, _stationNum, _isExit);
rideEntranceExitRemove.SetFlags(GetFlags());
auto result = GameActions::ExecuteNested(&rideEntranceExitRemove);
@@ -161,9 +161,8 @@ public:
auto res = std::make_unique<GameActionResult>();
if (!ride->overall_view.isNull())
{
res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16;
res->Position.z = tile_element_height(res->Position);
auto location = ride->overall_view.ToTileCentre();
res->Position = { location, tile_element_height(location) };
}
return res;
+2 -3
View File
@@ -95,9 +95,8 @@ public:
windowManager->BroadcastIntent(Intent(INTENT_ACTION_REFRESH_GUEST_LIST));
auto res = std::make_unique<GameActionResult>();
res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16;
res->Position.z = tile_element_height(res->Position);
auto location = ride->overall_view.ToTileCentre();
res->Position = { location, tile_element_height(location) };
return res;
}
+2 -3
View File
@@ -95,9 +95,8 @@ public:
if (!ride->overall_view.isNull())
{
res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16;
res->Position.z = tile_element_height(res->Position);
auto location = ride->overall_view.ToTileCentre();
res->Position = { location, tile_element_height(location) };
}
uint32_t shopItem;
+2 -3
View File
@@ -245,9 +245,8 @@ public:
auto res = std::make_unique<GameActionResult>();
if (!ride->overall_view.isNull())
{
res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16;
res->Position.z = tile_element_height(res->Position);
auto location = ride->overall_view.ToTileCentre();
res->Position = { location, tile_element_height(location) };
}
window_invalidate_by_number(WC_RIDE, _rideIndex);
return res;
+2 -3
View File
@@ -122,9 +122,8 @@ public:
ride->FormatNameTo(res->ErrorMessageArgs.data() + 6);
if (!ride->overall_view.isNull())
{
res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16;
res->Position.z = tile_element_height(res->Position);
auto location = ride->overall_view.ToTileCentre();
res->Position = { location, tile_element_height(res->Position) };
}
switch (_status)
@@ -203,9 +203,8 @@ public:
auto res = std::make_unique<GameActionResult>();
if (!ride->overall_view.isNull())
{
res->Position.x = ride->overall_view.x * 32 + 16;
res->Position.y = ride->overall_view.y * 32 + 16;
res->Position.z = tile_element_height(res->Position);
auto location = ride->overall_view.ToTileCentre();
res->Position = { location, tile_element_height(res->Position) };
}
auto intent = Intent(INTENT_ACTION_RIDE_PAINT_RESET_VEHICLE);
+1 -2
View File
@@ -580,8 +580,7 @@ public:
if (entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN || ride->overall_view.isNull())
{
ride->overall_view.x = mapLoc.x / 32;
ride->overall_view.y = mapLoc.y / 32;
ride->overall_view = mapLoc;
}
auto tileElement = tile_element_insert(
+4 -5
View File
@@ -720,12 +720,11 @@ viewport_focus viewport_update_smart_guest_follow(rct_window* window, Peep* peep
auto ride = get_ride(peep->current_ride);
if (ride != nullptr)
{
auto x = (int32_t)ride->overall_view.x * 32 + 16;
auto y = (int32_t)ride->overall_view.y * 32 + 16;
auto xy = ride->overall_view.ToTileCentre();
focus.type = VIEWPORT_FOCUS_TYPE_COORDINATE;
focus.coordinate.x = x;
focus.coordinate.y = y;
focus.coordinate.z = tile_element_height({ x, y }) + 32;
focus.coordinate.x = xy.x;
focus.coordinate.y = xy.y;
focus.coordinate.z = tile_element_height(xy) + (4 * COORDS_Z_STEP);
focus.sprite.type |= VIEWPORT_FOCUS_TYPE_COORDINATE;
}
}
+2 -2
View File
@@ -222,8 +222,8 @@ void news_item_get_subject_location(int32_t type, int32_t subject, int32_t* x, i
*x = LOCATION_NULL;
break;
}
*x = ride->overall_view.x * 32 + 16;
*y = ride->overall_view.y * 32 + 16;
*x = ride->overall_view.x + 16;
*y = ride->overall_view.y + 16;
*z = tile_element_height({ *x, *y });
break;
case NEWS_ITEM_PEEP_ON_RIDE:
+1 -1
View File
@@ -746,7 +746,7 @@ private:
}
else
{
dst->overall_view = { src->overall_view.x, src->overall_view.y };
dst->overall_view = TileCoordsXY{ src->overall_view.x, src->overall_view.y }.ToCoordsXY();
}
for (int32_t i = 0; i < RCT12_MAX_STATIONS_PER_RIDE; i++)
+2 -1
View File
@@ -542,7 +542,8 @@ void S6Exporter::ExportRide(rct2_ride* dst, const Ride* src)
}
else
{
dst->overall_view = { static_cast<uint8_t>(src->overall_view.x), static_cast<uint8_t>(src->overall_view.y) };
auto tileLoc = TileCoordsXY(src->overall_view);
dst->overall_view = { static_cast<uint8_t>(tileLoc.x), static_cast<uint8_t>(tileLoc.y) };
}
for (int32_t i = 0; i < RCT12_MAX_STATIONS_PER_RIDE; i++)
+2 -1
View File
@@ -529,7 +529,8 @@ public:
}
else
{
dst->overall_view = { src->overall_view.x, src->overall_view.y };
auto tileLoc = TileCoordsXY(src->overall_view.x, src->overall_view.y);
dst->overall_view = tileLoc.ToCoordsXY();
}
for (int32_t i = 0; i < RCT12_MAX_STATIONS_PER_RIDE; i++)
+1 -1
View File
@@ -227,7 +227,7 @@ struct Ride
uint8_t status;
std::string custom_name;
uint16_t default_name_number;
TileCoordsXY overall_view;
CoordsXY overall_view;
uint16_t vehicles[MAX_VEHICLES_PER_RIDE + 1]; // Points to the first car in the train
uint8_t depart_flags;
uint8_t num_stations;
+2 -3
View File
@@ -237,11 +237,10 @@ uint8_t banner_get_closest_ride_index(const CoordsXYZ& mapPos)
if (ride_type_has_flag(ride.type, RIDE_TYPE_FLAG_IS_SHOP))
continue;
auto location = ride.overall_view;
if (location.isNull())
auto rideCoords = ride.overall_view;
if (rideCoords.isNull())
continue;
auto rideCoords = location.ToCoordsXY();
int32_t distance = abs(mapPos.x - rideCoords.x) + abs(mapPos.y - rideCoords.y);
if (distance < resultDistance)
{
+3 -3
View File
@@ -416,14 +416,14 @@ int16_t tile_element_height(const CoordsXY& loc)
{
// Off the map
if (!map_is_location_valid(loc))
return 16;
return 2 * COORDS_Z_STEP;
// Get the surface element for the tile
auto surfaceElement = map_get_surface_element_at(loc);
if (surfaceElement == nullptr)
{
return 16;
return 2 * COORDS_Z_STEP;
}
uint16_t height = surfaceElement->GetBaseZ();
@@ -525,7 +525,7 @@ int16_t tile_element_height(const CoordsXY& loc)
return height;
}
// This tile is essentially at the next height level
height += 0x10;
height += LAND_HEIGHT_STEP;
// so we move *down* the slope
if (quad < 0)
{