mirror of https://github.com/OpenRCT2/OpenRCT2.git
Part of #13874: Replace TrackCoordinates
This commit is contained in:
parent
5c261b6d2e
commit
80418efafb
|
@ -594,7 +594,9 @@ static void window_track_place_draw_mini_preview_track(
|
||||||
|
|
||||||
// Change rotation and next position based on track curvature
|
// Change rotation and next position based on track curvature
|
||||||
curTrackRotation &= 3;
|
curTrackRotation &= 3;
|
||||||
const rct_track_coordinates* track_coordinate = &TrackCoordinates[trackType];
|
using namespace OpenRCT2::TrackMetaData;
|
||||||
|
const auto& teDescriptor = GetTrackElementDescriptor(trackType);
|
||||||
|
const rct_track_coordinates* track_coordinate = &teDescriptor.Coordinates;
|
||||||
|
|
||||||
curTrackStart += CoordsXY{ track_coordinate->x, track_coordinate->y }.Rotate(curTrackRotation);
|
curTrackStart += CoordsXY{ track_coordinate->x, track_coordinate->y }.Rotate(curTrackRotation);
|
||||||
curTrackRotation += track_coordinate->rotation_end - track_coordinate->rotation_begin;
|
curTrackRotation += track_coordinate->rotation_end - track_coordinate->rotation_begin;
|
||||||
|
|
|
@ -405,6 +405,9 @@ bool WallPlaceAction::WallCheckObstructionWithTrack(
|
||||||
WallSceneryEntry* wall, int32_t z0, TrackElement* trackElement, bool* wallAcrossTrack) const
|
WallSceneryEntry* wall, int32_t z0, TrackElement* trackElement, bool* wallAcrossTrack) const
|
||||||
{
|
{
|
||||||
track_type_t trackType = trackElement->GetTrackType();
|
track_type_t trackType = trackElement->GetTrackType();
|
||||||
|
|
||||||
|
using namespace OpenRCT2::TrackMetaData;
|
||||||
|
const auto& teDescriptor = GetTrackElementDescriptor(trackType);
|
||||||
int32_t sequence = trackElement->GetSequenceIndex();
|
int32_t sequence = trackElement->GetSequenceIndex();
|
||||||
int32_t direction = (_edge - trackElement->GetDirection()) & TILE_ELEMENT_DIRECTION_MASK;
|
int32_t direction = (_edge - trackElement->GetDirection()) & TILE_ELEMENT_DIRECTION_MASK;
|
||||||
auto ride = get_ride(trackElement->GetRideIndex());
|
auto ride = get_ride(trackElement->GetRideIndex());
|
||||||
|
@ -444,13 +447,13 @@ bool WallPlaceAction::WallCheckObstructionWithTrack(
|
||||||
|
|
||||||
if (TrackDefinitions[trackType].bank_start == 0)
|
if (TrackDefinitions[trackType].bank_start == 0)
|
||||||
{
|
{
|
||||||
if (!(TrackCoordinates[trackType].rotation_begin & 4))
|
if (!(teDescriptor.Coordinates.rotation_begin & 4))
|
||||||
{
|
{
|
||||||
direction = direction_reverse(trackElement->GetDirection());
|
direction = direction_reverse(trackElement->GetDirection());
|
||||||
if (direction == _edge)
|
if (direction == _edge)
|
||||||
{
|
{
|
||||||
const rct_preview_track* trackBlock = &TrackBlocks[trackType][sequence];
|
const rct_preview_track* trackBlock = &TrackBlocks[trackType][sequence];
|
||||||
z = TrackCoordinates[trackType].z_begin;
|
z = teDescriptor.Coordinates.z_begin;
|
||||||
z = trackElement->base_height + ((z - trackBlock->z) * 8);
|
z = trackElement->base_height + ((z - trackBlock->z) * 8);
|
||||||
if (z == z0)
|
if (z == z0)
|
||||||
{
|
{
|
||||||
|
@ -472,20 +475,20 @@ bool WallPlaceAction::WallCheckObstructionWithTrack(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
direction = TrackCoordinates[trackType].rotation_end;
|
direction = teDescriptor.Coordinates.rotation_end;
|
||||||
if (direction & 4)
|
if (direction & 4)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
direction = (trackElement->GetDirection() + TrackCoordinates[trackType].rotation_end) & TILE_ELEMENT_DIRECTION_MASK;
|
direction = (trackElement->GetDirection() + teDescriptor.Coordinates.rotation_end) & TILE_ELEMENT_DIRECTION_MASK;
|
||||||
if (direction != _edge)
|
if (direction != _edge)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
trackBlock = &TrackBlocks[trackType][sequence];
|
trackBlock = &TrackBlocks[trackType][sequence];
|
||||||
z = TrackCoordinates[trackType].z_end;
|
z = teDescriptor.Coordinates.z_end;
|
||||||
z = trackElement->base_height + ((z - trackBlock->z) * 8);
|
z = trackElement->base_height + ((z - trackBlock->z) * 8);
|
||||||
return z == z0;
|
return z == z0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,7 @@
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
using namespace OpenRCT2;
|
using namespace OpenRCT2;
|
||||||
|
using namespace OpenRCT2::TrackMetaData;
|
||||||
|
|
||||||
RideMode& operator++(RideMode& d, int)
|
RideMode& operator++(RideMode& d, int)
|
||||||
{
|
{
|
||||||
|
@ -478,11 +479,12 @@ bool track_block_get_next_from_zero(
|
||||||
if (tileElement->IsGhost() != isGhost)
|
if (tileElement->IsGhost() != isGhost)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
const auto& teDescriptor = GetTrackElementDescriptor(trackElement->GetTrackType());
|
||||||
auto nextTrackBlock = TrackBlocks[trackElement->GetTrackType()];
|
auto nextTrackBlock = TrackBlocks[trackElement->GetTrackType()];
|
||||||
if (nextTrackBlock == nullptr)
|
if (nextTrackBlock == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto nextTrackCoordinate = TrackCoordinates[trackElement->GetTrackType()];
|
auto nextTrackCoordinate = teDescriptor.Coordinates;
|
||||||
uint8_t nextRotation = tileElement->GetDirectionWithOffset(nextTrackCoordinate.rotation_begin)
|
uint8_t nextRotation = tileElement->GetDirectionWithOffset(nextTrackCoordinate.rotation_begin)
|
||||||
| (nextTrackCoordinate.rotation_begin & TRACK_BLOCK_2);
|
| (nextTrackCoordinate.rotation_begin & TRACK_BLOCK_2);
|
||||||
|
|
||||||
|
@ -519,6 +521,7 @@ bool track_block_get_next(CoordsXYE* input, CoordsXYE* output, int32_t* z, int32
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto inputElement = input->element->AsTrack();
|
auto inputElement = input->element->AsTrack();
|
||||||
|
const auto& teDescriptor = GetTrackElementDescriptor(inputElement->GetTrackType());
|
||||||
if (inputElement == nullptr)
|
if (inputElement == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -533,7 +536,7 @@ bool track_block_get_next(CoordsXYE* input, CoordsXYE* output, int32_t* z, int32
|
||||||
|
|
||||||
trackBlock += inputElement->GetSequenceIndex();
|
trackBlock += inputElement->GetSequenceIndex();
|
||||||
|
|
||||||
auto trackCoordinate = TrackCoordinates[inputElement->GetTrackType()];
|
auto trackCoordinate = teDescriptor.Coordinates;
|
||||||
|
|
||||||
int32_t x = input->x;
|
int32_t x = input->x;
|
||||||
int32_t y = input->y;
|
int32_t y = input->y;
|
||||||
|
@ -599,7 +602,8 @@ bool track_block_get_previous_from_zero(
|
||||||
if (nextTrackBlock == nullptr)
|
if (nextTrackBlock == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto nextTrackCoordinate = TrackCoordinates[trackElement->GetTrackType()];
|
const auto& teDesc = GetTrackElementDescriptor(trackElement->GetTrackType());
|
||||||
|
auto nextTrackCoordinate = teDesc.Coordinates;
|
||||||
|
|
||||||
nextTrackBlock += trackElement->GetSequenceIndex();
|
nextTrackBlock += trackElement->GetSequenceIndex();
|
||||||
if ((nextTrackBlock + 1)->index != 255)
|
if ((nextTrackBlock + 1)->index != 255)
|
||||||
|
@ -663,6 +667,7 @@ bool track_block_get_previous(const CoordsXYE& trackPos, track_begin_end* outTra
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto trackElement = trackPos.element->AsTrack();
|
auto trackElement = trackPos.element->AsTrack();
|
||||||
|
const auto& teDescriptor = GetTrackElementDescriptor(trackElement->GetTrackType());
|
||||||
if (trackElement == nullptr)
|
if (trackElement == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -677,7 +682,7 @@ bool track_block_get_previous(const CoordsXYE& trackPos, track_begin_end* outTra
|
||||||
|
|
||||||
trackBlock += trackElement->GetSequenceIndex();
|
trackBlock += trackElement->GetSequenceIndex();
|
||||||
|
|
||||||
auto trackCoordinate = TrackCoordinates[trackElement->GetTrackType()];
|
auto trackCoordinate = teDescriptor.Coordinates;
|
||||||
|
|
||||||
int32_t z = trackElement->GetBaseZ();
|
int32_t z = trackElement->GetBaseZ();
|
||||||
|
|
||||||
|
@ -2857,7 +2862,8 @@ static void ride_set_boat_hire_return_point(Ride* ride, CoordsXYE* startElement)
|
||||||
};
|
};
|
||||||
|
|
||||||
trackType = returnPos.element->AsTrack()->GetTrackType();
|
trackType = returnPos.element->AsTrack()->GetTrackType();
|
||||||
int32_t elementReturnDirection = TrackCoordinates[trackType].rotation_begin;
|
const auto& teDescriptor = GetTrackElementDescriptor(trackType);
|
||||||
|
int32_t elementReturnDirection = teDescriptor.Coordinates.rotation_begin;
|
||||||
ride->boat_hire_return_direction = returnPos.element->GetDirectionWithOffset(elementReturnDirection);
|
ride->boat_hire_return_direction = returnPos.element->GetDirectionWithOffset(elementReturnDirection);
|
||||||
ride->boat_hire_return_position = TileCoordsXY{ returnPos };
|
ride->boat_hire_return_position = TileCoordsXY{ returnPos };
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
const rct_track_coordinates TrackCoordinates[TrackElemType::Count] = {
|
const static rct_track_coordinates TrackCoordinates[TrackElemType::Count] = {
|
||||||
{ 0, 0, 0, 0, 0, 0 }, // ELEM_FLAT
|
{ 0, 0, 0, 0, 0, 0 }, // ELEM_FLAT
|
||||||
{ 0, 0, 0, 0, 0, 0 }, // ELEM_END_STATION
|
{ 0, 0, 0, 0, 0, 0 }, // ELEM_END_STATION
|
||||||
{ 0, 0, 0, 0, 0, 0 }, // ELEM_BEGIN_STATION
|
{ 0, 0, 0, 0, 0, 0 }, // ELEM_BEGIN_STATION
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
constexpr const uint8_t MaxSequencesPerPiece = 16;
|
constexpr const uint8_t MaxSequencesPerPiece = 16;
|
||||||
|
|
||||||
// 0x009968BB, 0x009968BC, 0x009968BD, 0x009968BF, 0x009968C1, 0x009968C3
|
// 0x009968BB, 0x009968BC, 0x009968BD, 0x009968BF, 0x009968C1, 0x009968C3
|
||||||
extern const rct_track_coordinates TrackCoordinates[TrackElemType::Count];
|
|
||||||
|
|
||||||
extern const uint8_t TrackSequenceProperties[TrackElemType::Count][MaxSequencesPerPiece];
|
extern const uint8_t TrackSequenceProperties[TrackElemType::Count][MaxSequencesPerPiece];
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
|
|
||||||
using namespace OpenRCT2;
|
using namespace OpenRCT2;
|
||||||
using namespace OpenRCT2::Drawing;
|
using namespace OpenRCT2::Drawing;
|
||||||
|
using namespace OpenRCT2::TrackMetaData;
|
||||||
|
|
||||||
bool gTrackDesignSceneryToggle;
|
bool gTrackDesignSceneryToggle;
|
||||||
static CoordsXYZ _trackPreviewMin;
|
static CoordsXYZ _trackPreviewMin;
|
||||||
|
@ -182,7 +183,8 @@ rct_string_id TrackDesign::CreateTrackDesignTrack(const Ride& ride)
|
||||||
trackElement.y = newCoords->y;
|
trackElement.y = newCoords->y;
|
||||||
z = newCoords->z;
|
z = newCoords->z;
|
||||||
|
|
||||||
const rct_track_coordinates* trackCoordinates = &TrackCoordinates[trackElement.element->AsTrack()->GetTrackType()];
|
const auto& teDescriptor = GetTrackElementDescriptor(trackElement.element->AsTrack()->GetTrackType());
|
||||||
|
const rct_track_coordinates* trackCoordinates = &teDescriptor.Coordinates;
|
||||||
auto trackBlock = TrackBlocks[trackType];
|
auto trackBlock = TrackBlocks[trackType];
|
||||||
// Used in the following loop to know when we have
|
// Used in the following loop to know when we have
|
||||||
// completed all of the elements and are back at the
|
// completed all of the elements and are back at the
|
||||||
|
@ -1519,6 +1521,7 @@ static std::optional<money32> track_design_place_ride(TrackDesign* td6, const Co
|
||||||
for (const auto& track : td6->track_elements)
|
for (const auto& track : td6->track_elements)
|
||||||
{
|
{
|
||||||
auto trackType = track.type;
|
auto trackType = track.type;
|
||||||
|
const auto& teDescriptor = GetTrackElementDescriptor(trackType);
|
||||||
|
|
||||||
track_design_update_max_min_coordinates(newCoords);
|
track_design_update_max_min_coordinates(newCoords);
|
||||||
|
|
||||||
|
@ -1534,7 +1537,7 @@ static std::optional<money32> track_design_place_ride(TrackDesign* td6, const Co
|
||||||
break;
|
break;
|
||||||
case PTD_OPERATION_REMOVE_GHOST:
|
case PTD_OPERATION_REMOVE_GHOST:
|
||||||
{
|
{
|
||||||
const rct_track_coordinates* trackCoordinates = &TrackCoordinates[trackType];
|
const rct_track_coordinates* trackCoordinates = &teDescriptor.Coordinates;
|
||||||
const rct_preview_track* trackBlock = TrackBlocks[trackType];
|
const rct_preview_track* trackBlock = TrackBlocks[trackType];
|
||||||
int32_t tempZ = newCoords.z - trackCoordinates->z_begin + trackBlock->z;
|
int32_t tempZ = newCoords.z - trackCoordinates->z_begin + trackBlock->z;
|
||||||
auto trackRemoveAction = TrackRemoveAction(
|
auto trackRemoveAction = TrackRemoveAction(
|
||||||
|
@ -1549,7 +1552,7 @@ static std::optional<money32> track_design_place_ride(TrackDesign* td6, const Co
|
||||||
case PTD_OPERATION_PLACE_GHOST:
|
case PTD_OPERATION_PLACE_GHOST:
|
||||||
case PTD_OPERATION_PLACE_TRACK_PREVIEW:
|
case PTD_OPERATION_PLACE_TRACK_PREVIEW:
|
||||||
{
|
{
|
||||||
const rct_track_coordinates* trackCoordinates = &TrackCoordinates[trackType];
|
const rct_track_coordinates* trackCoordinates = &teDescriptor.Coordinates;
|
||||||
|
|
||||||
// di
|
// di
|
||||||
int16_t tempZ = newCoords.z - trackCoordinates->z_begin;
|
int16_t tempZ = newCoords.z - trackCoordinates->z_begin;
|
||||||
|
@ -1606,7 +1609,7 @@ static std::optional<money32> track_design_place_ride(TrackDesign* td6, const Co
|
||||||
}
|
}
|
||||||
case PTD_OPERATION_GET_PLACE_Z:
|
case PTD_OPERATION_GET_PLACE_Z:
|
||||||
{
|
{
|
||||||
int32_t tempZ = newCoords.z - TrackCoordinates[trackType].z_begin;
|
int32_t tempZ = newCoords.z - teDescriptor.Coordinates.z_begin;
|
||||||
for (const rct_preview_track* trackBlock = TrackBlocks[trackType]; trackBlock->index != 0xFF; trackBlock++)
|
for (const rct_preview_track* trackBlock = TrackBlocks[trackType]; trackBlock->index != 0xFF; trackBlock++)
|
||||||
{
|
{
|
||||||
auto tile = CoordsXY{ newCoords } + CoordsXY{ trackBlock->x, trackBlock->y }.Rotate(rotation);
|
auto tile = CoordsXY{ newCoords } + CoordsXY{ trackBlock->x, trackBlock->y }.Rotate(rotation);
|
||||||
|
@ -1646,7 +1649,7 @@ static std::optional<money32> track_design_place_ride(TrackDesign* td6, const Co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const rct_track_coordinates* track_coordinates = &TrackCoordinates[trackType];
|
const rct_track_coordinates* track_coordinates = &teDescriptor.Coordinates;
|
||||||
auto offsetAndRotatedTrack = CoordsXY{ newCoords }
|
auto offsetAndRotatedTrack = CoordsXY{ newCoords }
|
||||||
+ CoordsXY{ track_coordinates->x, track_coordinates->y }.Rotate(rotation);
|
+ CoordsXY{ track_coordinates->x, track_coordinates->y }.Rotate(rotation);
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
|
using namespace OpenRCT2::TrackMetaData;
|
||||||
static bool vehicle_boat_is_location_accessible(const CoordsXYZ& location);
|
static bool vehicle_boat_is_location_accessible(const CoordsXYZ& location);
|
||||||
|
|
||||||
constexpr int16_t VEHICLE_MAX_SPIN_SPEED = 1536;
|
constexpr int16_t VEHICLE_MAX_SPIN_SPEED = 1536;
|
||||||
|
@ -7493,12 +7494,13 @@ static void AnimateSceneryDoor(const CoordsXYZD& doorLocation, const CoordsXYZ&
|
||||||
void Vehicle::UpdateSceneryDoor() const
|
void Vehicle::UpdateSceneryDoor() const
|
||||||
{
|
{
|
||||||
auto trackType = GetTrackType();
|
auto trackType = GetTrackType();
|
||||||
|
const auto& teDescriptor = GetTrackElementDescriptor(trackType);
|
||||||
const rct_preview_track* trackBlock = TrackBlocks[trackType];
|
const rct_preview_track* trackBlock = TrackBlocks[trackType];
|
||||||
while ((trackBlock + 1)->index != 255)
|
while ((trackBlock + 1)->index != 255)
|
||||||
{
|
{
|
||||||
trackBlock++;
|
trackBlock++;
|
||||||
}
|
}
|
||||||
const rct_track_coordinates* trackCoordinates = &TrackCoordinates[trackType];
|
const rct_track_coordinates* trackCoordinates = &teDescriptor.Coordinates;
|
||||||
auto wallCoords = CoordsXYZ{ x, y, TrackLocation.z - trackBlock->z + trackCoordinates->z_end }.ToTileStart();
|
auto wallCoords = CoordsXYZ{ x, y, TrackLocation.z - trackBlock->z + trackCoordinates->z_end }.ToTileStart();
|
||||||
int32_t direction = (GetTrackDirection() + trackCoordinates->rotation_end) & 3;
|
int32_t direction = (GetTrackDirection() + trackCoordinates->rotation_end) & 3;
|
||||||
|
|
||||||
|
@ -7590,8 +7592,9 @@ static void trigger_on_ride_photo(const CoordsXYZ& loc, TileElement* tileElement
|
||||||
void Vehicle::UpdateSceneryDoorBackwards() const
|
void Vehicle::UpdateSceneryDoorBackwards() const
|
||||||
{
|
{
|
||||||
auto trackType = GetTrackType();
|
auto trackType = GetTrackType();
|
||||||
|
const auto& teDescriptor = GetTrackElementDescriptor(trackType);
|
||||||
const rct_preview_track* trackBlock = TrackBlocks[trackType];
|
const rct_preview_track* trackBlock = TrackBlocks[trackType];
|
||||||
const rct_track_coordinates* trackCoordinates = &TrackCoordinates[trackType];
|
const rct_track_coordinates* trackCoordinates = &teDescriptor.Coordinates;
|
||||||
auto wallCoords = CoordsXYZ{ TrackLocation, TrackLocation.z - trackBlock->z + trackCoordinates->z_begin };
|
auto wallCoords = CoordsXYZ{ TrackLocation, TrackLocation.z - trackBlock->z + trackCoordinates->z_begin };
|
||||||
int32_t direction = (GetTrackDirection() + trackCoordinates->rotation_begin) & 3;
|
int32_t direction = (GetTrackDirection() + trackCoordinates->rotation_begin) & 3;
|
||||||
direction = direction_reverse(direction);
|
direction = direction_reverse(direction);
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
|
using namespace OpenRCT2::TrackMetaData;
|
||||||
bool gDisableErrorWindowSound = false;
|
bool gDisableErrorWindowSound = false;
|
||||||
|
|
||||||
uint64_t _enabledRidePieces;
|
uint64_t _enabledRidePieces;
|
||||||
|
@ -90,7 +91,8 @@ money32 place_provisional_track_piece(
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
int16_t z_begin, z_end;
|
int16_t z_begin, z_end;
|
||||||
const rct_track_coordinates& coords = TrackCoordinates[trackType];
|
const auto& teDescriptor = GetTrackElementDescriptor(trackType);
|
||||||
|
const rct_track_coordinates& coords = teDescriptor.Coordinates;
|
||||||
if (!ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_HAS_NO_TRACK))
|
if (!ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_HAS_NO_TRACK))
|
||||||
{
|
{
|
||||||
z_begin = coords.z_begin;
|
z_begin = coords.z_begin;
|
||||||
|
@ -312,7 +314,8 @@ bool window_ride_construction_update_state(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const rct_track_coordinates& trackCoordinates = TrackCoordinates[trackType];
|
const auto& teDescriptor = GetTrackElementDescriptor(trackType);
|
||||||
|
const rct_track_coordinates& trackCoordinates = teDescriptor.Coordinates;
|
||||||
|
|
||||||
x = _currentTrackBegin.x;
|
x = _currentTrackBegin.x;
|
||||||
y = _currentTrackBegin.y;
|
y = _currentTrackBegin.y;
|
||||||
|
|
Loading…
Reference in New Issue