mirror of https://github.com/OpenRCT2/OpenRCT2.git
Use CoordsXY and ScreenCoordsXY for rotate in Ride*.*
This commit is contained in:
parent
7bf05d4c04
commit
6f0ebfea27
|
@ -2367,32 +2367,28 @@ static void window_ride_construction_draw_track_piece(
|
|||
while ((trackBlock + 1)->index != 0xFF)
|
||||
trackBlock++;
|
||||
|
||||
int16_t x = trackBlock->x;
|
||||
int16_t z = trackBlock->z;
|
||||
int16_t y = trackBlock->y;
|
||||
CoordsXYZ mapCoords{ trackBlock->x, trackBlock->z, trackBlock->y };
|
||||
if (trackBlock->var_09 & 2)
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
mapCoords.x = 0;
|
||||
mapCoords.y = 0;
|
||||
}
|
||||
|
||||
rotate_map_coordinates(&x, &y, trackDirection & 3);
|
||||
auto rotatedMapCoords = mapCoords.Rotate(trackDirection);
|
||||
// this is actually case 0, but the other cases all jump to it
|
||||
x = 4112 + (x / 2);
|
||||
y = 4112 + (y / 2);
|
||||
z = 1024 + z;
|
||||
mapCoords.x = 4112 + (rotatedMapCoords.x / 2);
|
||||
mapCoords.y = 4112 + (rotatedMapCoords.y / 2);
|
||||
mapCoords.z = 1024 + mapCoords.z;
|
||||
|
||||
int16_t previewZOffset = ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)
|
||||
? FlatRideTrackDefinitions[trackType].preview_z_offset
|
||||
: TrackDefinitions[trackType].preview_z_offset;
|
||||
z -= previewZOffset;
|
||||
mapCoords.z -= previewZOffset;
|
||||
|
||||
const LocationXY16 rotatedCoords = ride_get_rotated_coords(x, y, z);
|
||||
x = rotatedCoords.x;
|
||||
y = rotatedCoords.y;
|
||||
const ScreenCoordsXY rotatedScreenCoords = ride_get_rotated_coords(mapCoords);
|
||||
|
||||
dpi->x += x - width / 2;
|
||||
dpi->y += y - height / 2 - 16;
|
||||
dpi->x += rotatedScreenCoords.x - width / 2;
|
||||
dpi->y += rotatedScreenCoords.y - height / 2 - 16;
|
||||
uint32_t d = unknown << 16;
|
||||
d |= rideIndex;
|
||||
d |= trackType << 8;
|
||||
|
|
|
@ -2899,9 +2899,8 @@ static void ride_music_update(Ride* ride)
|
|||
return;
|
||||
}
|
||||
|
||||
int32_t x = ride->stations[0].Start.x * 32 + 16;
|
||||
int32_t y = ride->stations[0].Start.y * 32 + 16;
|
||||
int32_t z = ride->stations[0].Height * 8;
|
||||
CoordsXYZ rideCoords{ ride->stations[0].Start.x * 32 + 16, ride->stations[0].Start.y * 32 + 16,
|
||||
ride->stations[0].Height * 8 };
|
||||
|
||||
int32_t sampleRate = 22050;
|
||||
|
||||
|
@ -2914,7 +2913,7 @@ static void ride_music_update(Ride* ride)
|
|||
sampleRate += 22050;
|
||||
}
|
||||
|
||||
ride->music_position = ride_music_params_update(x, y, z, ride, sampleRate, ride->music_position, &ride->music_tune_id);
|
||||
ride->music_position = ride_music_params_update(rideCoords, ride, sampleRate, ride->music_position, &ride->music_tune_id);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
@ -3563,12 +3562,11 @@ static int32_t ride_music_params_update_label_58(uint32_t position, uint8_t* tun
|
|||
* @param tuneId (bh)
|
||||
* @returns new position (ebp)
|
||||
*/
|
||||
int32_t ride_music_params_update(
|
||||
int16_t x, int16_t y, int16_t z, Ride* ride, uint16_t sampleRate, uint32_t position, uint8_t* tuneId)
|
||||
int32_t ride_music_params_update(CoordsXYZ rideCoords, Ride* ride, uint16_t sampleRate, uint32_t position, uint8_t* tuneId)
|
||||
{
|
||||
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) && !gGameSoundsOff && g_music_tracking_viewport != nullptr)
|
||||
{
|
||||
const LocationXY16 rotatedCoords = ride_get_rotated_coords(x, y, z);
|
||||
const ScreenCoordsXY rotatedCoords = ride_get_rotated_coords(rideCoords);
|
||||
rct_viewport* viewport = g_music_tracking_viewport;
|
||||
int16_t view_width = viewport->view_width;
|
||||
int16_t view_width2 = view_width * 2;
|
||||
|
@ -7658,12 +7656,10 @@ StationObject* ride_get_station_object(const Ride* ride)
|
|||
return static_cast<StationObject*>(objManager.GetLoadedObject(OBJECT_TYPE_STATION, ride->entrance_style));
|
||||
}
|
||||
|
||||
LocationXY16 ride_get_rotated_coords(int16_t x, int16_t y, int16_t z)
|
||||
ScreenCoordsXY ride_get_rotated_coords(CoordsXYZ coords3d)
|
||||
{
|
||||
CoordsXYZ coords3d = { x, y, z };
|
||||
auto screenCoords = translate_3d_to_2d_with_z(get_current_rotation(), coords3d);
|
||||
LocationXY16 rotatedCoords = { (int16_t)screenCoords.x, (int16_t)screenCoords.y };
|
||||
return rotatedCoords;
|
||||
return screenCoords;
|
||||
}
|
||||
|
||||
// Normally, a station has at most one entrance and one exit, which are at the same height
|
||||
|
|
|
@ -1169,8 +1169,7 @@ int32_t sub_6C683D(
|
|||
int32_t* x, int32_t* y, int32_t* z, int32_t direction, int32_t type, uint16_t extra_params, TileElement** output_element,
|
||||
uint16_t flags);
|
||||
void ride_set_map_tooltip(TileElement* tileElement);
|
||||
int32_t ride_music_params_update(
|
||||
int16_t x, int16_t y, int16_t z, Ride* ride, uint16_t sampleRate, uint32_t position, uint8_t* tuneId);
|
||||
int32_t ride_music_params_update(CoordsXYZ rideCoords, Ride* ride, uint16_t sampleRate, uint32_t position, uint8_t* tuneId);
|
||||
void ride_music_update_final();
|
||||
void ride_prepare_breakdown(Ride* ride, int32_t breakdownReason);
|
||||
TileElement* ride_get_station_start_track_element(Ride* ride, int32_t stationIndex);
|
||||
|
@ -1279,7 +1278,7 @@ StationObject* ride_get_station_object(const Ride* ride);
|
|||
|
||||
void ride_action_modify(Ride* ride, int32_t modifyType, int32_t flags);
|
||||
|
||||
LocationXY16 ride_get_rotated_coords(int16_t x, int16_t y, int16_t z);
|
||||
ScreenCoordsXY ride_get_rotated_coords(CoordsXYZ coords);
|
||||
|
||||
void determine_ride_entrance_and_exit_locations();
|
||||
void ride_clear_leftover_entrances(Ride* ride);
|
||||
|
|
Loading…
Reference in New Issue