Merge pull request #12158 from tupaschoal/ratings-coords

Generic RideRatingCalculationData improvements
This commit is contained in:
Tulio Leao 2020-07-08 15:51:38 -03:00 committed by GitHub
commit 2d169bc5a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 119 additions and 150 deletions

View File

@ -772,24 +772,24 @@ void S6Exporter::ExportRideRatingsCalcData()
{ {
const auto& src = gRideRatingsCalcData; const auto& src = gRideRatingsCalcData;
auto& dst = _s6.ride_ratings_calc_data; auto& dst = _s6.ride_ratings_calc_data;
dst.proximity_x = src.proximity_x; dst.proximity_x = src.Proximity.x;
dst.proximity_y = src.proximity_y; dst.proximity_y = src.Proximity.y;
dst.proximity_z = src.proximity_z; dst.proximity_z = src.Proximity.z;
dst.proximity_start_x = src.proximity_start_x; dst.proximity_start_x = src.ProximityStart.x;
dst.proximity_start_y = src.proximity_start_y; dst.proximity_start_y = src.ProximityStart.y;
dst.proximity_start_z = src.proximity_start_z; dst.proximity_start_z = src.ProximityStart.z;
dst.current_ride = src.current_ride; dst.current_ride = src.CurrentRide;
dst.state = src.state; dst.state = src.State;
dst.proximity_track_type = src.proximity_track_type; dst.proximity_track_type = src.ProximityTrackType;
dst.proximity_base_height = src.proximity_base_height; dst.proximity_base_height = src.ProximityBaseHeight;
dst.proximity_total = src.proximity_total; dst.proximity_total = src.ProximityTotal;
for (size_t i = 0; i < std::size(dst.proximity_scores); i++) for (size_t i = 0; i < std::size(dst.proximity_scores); i++)
{ {
dst.proximity_scores[i] = src.proximity_scores[i]; dst.proximity_scores[i] = src.ProximityScores[i];
} }
dst.num_brakes = src.num_brakes; dst.num_brakes = src.AmountOfBrakes;
dst.num_reversers = src.num_reversers; dst.num_reversers = src.AmountOfReversers;
dst.station_flags = src.station_flags; dst.station_flags = src.StationFlags;
} }
void S6Exporter::ExportRideMeasurements() void S6Exporter::ExportRideMeasurements()

View File

@ -796,24 +796,20 @@ public:
const auto& src = _s6.ride_ratings_calc_data; const auto& src = _s6.ride_ratings_calc_data;
auto& dst = gRideRatingsCalcData; auto& dst = gRideRatingsCalcData;
dst = {}; dst = {};
dst.proximity_x = src.proximity_x; dst.Proximity = { src.proximity_x, src.proximity_y, src.proximity_z };
dst.proximity_y = src.proximity_y; dst.ProximityStart = { src.proximity_start_x, src.proximity_start_y, src.proximity_start_z };
dst.proximity_z = src.proximity_z; dst.CurrentRide = src.current_ride;
dst.proximity_start_x = src.proximity_start_x; dst.State = src.state;
dst.proximity_start_y = src.proximity_start_y; dst.ProximityTrackType = src.proximity_track_type;
dst.proximity_start_z = src.proximity_start_z; dst.ProximityBaseHeight = src.proximity_base_height;
dst.current_ride = src.current_ride; dst.ProximityTotal = src.proximity_total;
dst.state = src.state;
dst.proximity_track_type = src.proximity_track_type;
dst.proximity_base_height = src.proximity_base_height;
dst.proximity_total = src.proximity_total;
for (size_t i = 0; i < std::size(src.proximity_scores); i++) for (size_t i = 0; i < std::size(src.proximity_scores); i++)
{ {
dst.proximity_scores[i] = src.proximity_scores[i]; dst.ProximityScores[i] = src.proximity_scores[i];
} }
dst.num_brakes = src.num_brakes; dst.AmountOfBrakes = src.num_brakes;
dst.num_reversers = src.num_reversers; dst.AmountOfReversers = src.num_reversers;
dst.station_flags = src.station_flags; dst.StationFlags = src.station_flags;
} }
void ImportRideMeasurements() void ImportRideMeasurements()

View File

@ -102,9 +102,9 @@ void ride_ratings_update_ride(const Ride& ride)
{ {
if (ride.status != RIDE_STATUS_CLOSED) if (ride.status != RIDE_STATUS_CLOSED)
{ {
gRideRatingsCalcData.current_ride = ride.id; gRideRatingsCalcData.CurrentRide = ride.id;
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_INITIALISE; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_INITIALISE;
while (gRideRatingsCalcData.state != RIDE_RATINGS_STATE_FIND_NEXT_RIDE) while (gRideRatingsCalcData.State != RIDE_RATINGS_STATE_FIND_NEXT_RIDE)
{ {
ride_ratings_update_state(); ride_ratings_update_state();
} }
@ -125,7 +125,7 @@ void ride_ratings_update_all()
static void ride_ratings_update_state() static void ride_ratings_update_state()
{ {
switch (gRideRatingsCalcData.state) switch (gRideRatingsCalcData.State)
{ {
case RIDE_RATINGS_STATE_FIND_NEXT_RIDE: case RIDE_RATINGS_STATE_FIND_NEXT_RIDE:
ride_ratings_update_state_0(); ride_ratings_update_state_0();
@ -154,7 +154,7 @@ static void ride_ratings_update_state()
*/ */
static void ride_ratings_update_state_0() static void ride_ratings_update_state_0()
{ {
int32_t currentRide = gRideRatingsCalcData.current_ride; int32_t currentRide = gRideRatingsCalcData.CurrentRide;
currentRide++; currentRide++;
if (currentRide == RIDE_ID_NULL) if (currentRide == RIDE_ID_NULL)
@ -165,9 +165,9 @@ static void ride_ratings_update_state_0()
auto ride = get_ride(currentRide); auto ride = get_ride(currentRide);
if (ride != nullptr && ride->status != RIDE_STATUS_CLOSED) if (ride != nullptr && ride->status != RIDE_STATUS_CLOSED)
{ {
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_INITIALISE; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_INITIALISE;
} }
gRideRatingsCalcData.current_ride = currentRide; gRideRatingsCalcData.CurrentRide = currentRide;
} }
/** /**
@ -176,15 +176,15 @@ static void ride_ratings_update_state_0()
*/ */
static void ride_ratings_update_state_1() static void ride_ratings_update_state_1()
{ {
gRideRatingsCalcData.proximity_total = 0; gRideRatingsCalcData.ProximityTotal = 0;
for (int32_t i = 0; i < PROXIMITY_COUNT; i++) for (int32_t i = 0; i < PROXIMITY_COUNT; i++)
{ {
gRideRatingsCalcData.proximity_scores[i] = 0; gRideRatingsCalcData.ProximityScores[i] = 0;
} }
gRideRatingsCalcData.num_brakes = 0; gRideRatingsCalcData.AmountOfBrakes = 0;
gRideRatingsCalcData.num_reversers = 0; gRideRatingsCalcData.AmountOfReversers = 0;
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_2; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_2;
gRideRatingsCalcData.station_flags = 0; gRideRatingsCalcData.StationFlags = 0;
ride_ratings_begin_proximity_loop(); ride_ratings_begin_proximity_loop();
} }
@ -194,22 +194,21 @@ static void ride_ratings_update_state_1()
*/ */
static void ride_ratings_update_state_2() static void ride_ratings_update_state_2()
{ {
const ride_id_t rideIndex = gRideRatingsCalcData.current_ride; const ride_id_t rideIndex = gRideRatingsCalcData.CurrentRide;
auto ride = get_ride(rideIndex); auto ride = get_ride(rideIndex);
if (ride == nullptr || ride->status == RIDE_STATUS_CLOSED) if (ride == nullptr || ride->status == RIDE_STATUS_CLOSED)
{ {
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
return; return;
} }
auto loc = CoordsXYZ{ gRideRatingsCalcData.proximity_x, gRideRatingsCalcData.proximity_y, auto loc = gRideRatingsCalcData.Proximity;
gRideRatingsCalcData.proximity_z }; int32_t trackType = gRideRatingsCalcData.ProximityTrackType;
int32_t trackType = gRideRatingsCalcData.proximity_track_type;
TileElement* tileElement = map_get_first_element_at(loc); TileElement* tileElement = map_get_first_element_at(loc);
if (tileElement == nullptr) if (tileElement == nullptr)
{ {
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
return; return;
} }
do do
@ -233,44 +232,37 @@ static void ride_ratings_update_state_2()
if (trackType == TRACK_ELEM_END_STATION) if (trackType == TRACK_ELEM_END_STATION)
{ {
int32_t entranceIndex = tileElement->AsTrack()->GetStationIndex(); int32_t entranceIndex = tileElement->AsTrack()->GetStationIndex();
gRideRatingsCalcData.station_flags &= ~RIDE_RATING_STATION_FLAG_NO_ENTRANCE; gRideRatingsCalcData.StationFlags &= ~RIDE_RATING_STATION_FLAG_NO_ENTRANCE;
if (ride_get_entrance_location(ride, entranceIndex).isNull()) if (ride_get_entrance_location(ride, entranceIndex).isNull())
{ {
gRideRatingsCalcData.station_flags |= RIDE_RATING_STATION_FLAG_NO_ENTRANCE; gRideRatingsCalcData.StationFlags |= RIDE_RATING_STATION_FLAG_NO_ENTRANCE;
} }
} }
ride_ratings_score_close_proximity(tileElement); ride_ratings_score_close_proximity(tileElement);
CoordsXYE trackElement = { CoordsXYE trackElement = { gRideRatingsCalcData.Proximity, tileElement };
/* .x = */ gRideRatingsCalcData.proximity_x,
/* .y = */ gRideRatingsCalcData.proximity_y,
/* .element = */ tileElement,
};
CoordsXYE nextTrackElement; CoordsXYE nextTrackElement;
if (!track_block_get_next(&trackElement, &nextTrackElement, nullptr, nullptr)) if (!track_block_get_next(&trackElement, &nextTrackElement, nullptr, nullptr))
{ {
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_4; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_4;
return; return;
} }
loc = { nextTrackElement, nextTrackElement.element->GetBaseZ() }; loc = { nextTrackElement, nextTrackElement.element->GetBaseZ() };
tileElement = nextTrackElement.element; tileElement = nextTrackElement.element;
if (loc.x == gRideRatingsCalcData.proximity_start_x && loc.y == gRideRatingsCalcData.proximity_start_y if (loc == gRideRatingsCalcData.ProximityStart)
&& loc.z == gRideRatingsCalcData.proximity_start_z)
{ {
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_CALCULATE; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_CALCULATE;
return; return;
} }
gRideRatingsCalcData.proximity_x = loc.x; gRideRatingsCalcData.Proximity = loc;
gRideRatingsCalcData.proximity_y = loc.y; gRideRatingsCalcData.ProximityTrackType = tileElement->AsTrack()->GetTrackType();
gRideRatingsCalcData.proximity_z = loc.z;
gRideRatingsCalcData.proximity_track_type = tileElement->AsTrack()->GetTrackType();
return; return;
} }
} while (!(tileElement++)->IsLastForTile()); } while (!(tileElement++)->IsLastForTile());
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
} }
/** /**
@ -279,18 +271,18 @@ static void ride_ratings_update_state_2()
*/ */
static void ride_ratings_update_state_3() static void ride_ratings_update_state_3()
{ {
auto ride = get_ride(gRideRatingsCalcData.current_ride); auto ride = get_ride(gRideRatingsCalcData.CurrentRide);
if (ride == nullptr || ride->status == RIDE_STATUS_CLOSED) if (ride == nullptr || ride->status == RIDE_STATUS_CLOSED)
{ {
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
return; return;
} }
ride_ratings_calculate(ride); ride_ratings_calculate(ride);
ride_ratings_calculate_value(ride); ride_ratings_calculate_value(ride);
window_invalidate_by_number(WC_RIDE, gRideRatingsCalcData.current_ride); window_invalidate_by_number(WC_RIDE, gRideRatingsCalcData.CurrentRide);
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
} }
/** /**
@ -299,7 +291,7 @@ static void ride_ratings_update_state_3()
*/ */
static void ride_ratings_update_state_4() static void ride_ratings_update_state_4()
{ {
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_5; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_5;
ride_ratings_begin_proximity_loop(); ride_ratings_begin_proximity_loop();
} }
@ -309,21 +301,20 @@ static void ride_ratings_update_state_4()
*/ */
static void ride_ratings_update_state_5() static void ride_ratings_update_state_5()
{ {
auto ride = get_ride(gRideRatingsCalcData.current_ride); auto ride = get_ride(gRideRatingsCalcData.CurrentRide);
if (ride == nullptr || ride->status == RIDE_STATUS_CLOSED) if (ride == nullptr || ride->status == RIDE_STATUS_CLOSED)
{ {
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
return; return;
} }
auto loc = CoordsXYZ{ gRideRatingsCalcData.proximity_x, gRideRatingsCalcData.proximity_y, auto loc = gRideRatingsCalcData.Proximity;
gRideRatingsCalcData.proximity_z }; int32_t trackType = gRideRatingsCalcData.ProximityTrackType;
int32_t trackType = gRideRatingsCalcData.proximity_track_type;
TileElement* tileElement = map_get_first_element_at(loc); TileElement* tileElement = map_get_first_element_at(loc);
if (tileElement == nullptr) if (tileElement == nullptr)
{ {
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
return; return;
} }
do do
@ -345,33 +336,28 @@ static void ride_ratings_update_state_5()
{ {
ride_ratings_score_close_proximity(tileElement); ride_ratings_score_close_proximity(tileElement);
loc.x = gRideRatingsCalcData.proximity_x;
loc.y = gRideRatingsCalcData.proximity_y;
track_begin_end trackBeginEnd; track_begin_end trackBeginEnd;
if (!track_block_get_previous({ loc, tileElement }, &trackBeginEnd)) if (!track_block_get_previous({ gRideRatingsCalcData.Proximity, tileElement }, &trackBeginEnd))
{ {
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_CALCULATE; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_CALCULATE;
return; return;
} }
loc.x = trackBeginEnd.begin_x; loc.x = trackBeginEnd.begin_x;
loc.y = trackBeginEnd.begin_y; loc.y = trackBeginEnd.begin_y;
loc.z = trackBeginEnd.begin_z; loc.z = trackBeginEnd.begin_z;
if (loc.x == gRideRatingsCalcData.proximity_start_x && loc.y == gRideRatingsCalcData.proximity_start_y if (loc == gRideRatingsCalcData.ProximityStart)
&& loc.z == gRideRatingsCalcData.proximity_start_z)
{ {
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_CALCULATE; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_CALCULATE;
return; return;
} }
gRideRatingsCalcData.proximity_x = loc.x; gRideRatingsCalcData.Proximity = loc;
gRideRatingsCalcData.proximity_y = loc.y; gRideRatingsCalcData.ProximityTrackType = trackBeginEnd.begin_element->AsTrack()->GetTrackType();
gRideRatingsCalcData.proximity_z = loc.z;
gRideRatingsCalcData.proximity_track_type = trackBeginEnd.begin_element->AsTrack()->GetTrackType();
return; return;
} }
} while (!(tileElement++)->IsLastForTile()); } while (!(tileElement++)->IsLastForTile());
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
} }
/** /**
@ -380,16 +366,16 @@ static void ride_ratings_update_state_5()
*/ */
static void ride_ratings_begin_proximity_loop() static void ride_ratings_begin_proximity_loop()
{ {
auto ride = get_ride(gRideRatingsCalcData.current_ride); auto ride = get_ride(gRideRatingsCalcData.CurrentRide);
if (ride == nullptr || ride->status == RIDE_STATUS_CLOSED) if (ride == nullptr || ride->status == RIDE_STATUS_CLOSED)
{ {
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
return; return;
} }
if (ride->type == RIDE_TYPE_MAZE) if (ride->type == RIDE_TYPE_MAZE)
{ {
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_CALCULATE; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_CALCULATE;
return; return;
} }
@ -397,31 +383,27 @@ static void ride_ratings_begin_proximity_loop()
{ {
if (!ride->stations[i].Start.isNull()) if (!ride->stations[i].Start.isNull())
{ {
gRideRatingsCalcData.station_flags &= ~RIDE_RATING_STATION_FLAG_NO_ENTRANCE; gRideRatingsCalcData.StationFlags &= ~RIDE_RATING_STATION_FLAG_NO_ENTRANCE;
if (ride_get_entrance_location(ride, i).isNull()) if (ride_get_entrance_location(ride, i).isNull())
{ {
gRideRatingsCalcData.station_flags |= RIDE_RATING_STATION_FLAG_NO_ENTRANCE; gRideRatingsCalcData.StationFlags |= RIDE_RATING_STATION_FLAG_NO_ENTRANCE;
} }
auto location = ride->stations[i].GetStart(); auto location = ride->stations[i].GetStart();
gRideRatingsCalcData.proximity_x = location.x; gRideRatingsCalcData.Proximity = location;
gRideRatingsCalcData.proximity_y = location.y; gRideRatingsCalcData.ProximityTrackType = 255;
gRideRatingsCalcData.proximity_z = location.z; gRideRatingsCalcData.ProximityStart = location;
gRideRatingsCalcData.proximity_track_type = 255;
gRideRatingsCalcData.proximity_start_x = location.x;
gRideRatingsCalcData.proximity_start_y = location.y;
gRideRatingsCalcData.proximity_start_z = location.z;
return; return;
} }
} }
gRideRatingsCalcData.state = RIDE_RATINGS_STATE_FIND_NEXT_RIDE; gRideRatingsCalcData.State = RIDE_RATINGS_STATE_FIND_NEXT_RIDE;
} }
static void proximity_score_increment(int32_t type) static void proximity_score_increment(int32_t type)
{ {
gRideRatingsCalcData.proximity_scores[type]++; gRideRatingsCalcData.ProximityScores[type]++;
} }
/** /**
@ -430,8 +412,7 @@ static void proximity_score_increment(int32_t type)
*/ */
static void ride_ratings_score_close_proximity_in_direction(TileElement* inputTileElement, int32_t direction) static void ride_ratings_score_close_proximity_in_direction(TileElement* inputTileElement, int32_t direction)
{ {
auto scorePos = CoordsXY{ gRideRatingsCalcData.proximity_x + CoordsDirectionDelta[direction].x, auto scorePos = CoordsXY{ CoordsXY{ gRideRatingsCalcData.Proximity } + CoordsDirectionDelta[direction] };
gRideRatingsCalcData.proximity_y + CoordsDirectionDelta[direction].y };
if (!map_is_location_valid(scorePos)) if (!map_is_location_valid(scorePos))
return; return;
@ -446,7 +427,7 @@ static void ride_ratings_score_close_proximity_in_direction(TileElement* inputTi
switch (tileElement->GetType()) switch (tileElement->GetType())
{ {
case TILE_ELEMENT_TYPE_SURFACE: case TILE_ELEMENT_TYPE_SURFACE:
if (gRideRatingsCalcData.proximity_base_height <= inputTileElement->base_height) if (gRideRatingsCalcData.ProximityBaseHeight <= inputTileElement->base_height)
{ {
if (inputTileElement->clearance_height <= tileElement->base_height) if (inputTileElement->clearance_height <= tileElement->base_height)
{ {
@ -487,9 +468,9 @@ static void ride_ratings_score_close_proximity_in_direction(TileElement* inputTi
} while (!(tileElement++)->IsLastForTile()); } while (!(tileElement++)->IsLastForTile());
} }
static void ride_ratings_score_close_proximity_loops_helper(TileElement* inputTileElement, int32_t x, int32_t y) static void ride_ratings_score_close_proximity_loops_helper(const CoordsXYE& coordsElement)
{ {
TileElement* tileElement = map_get_first_element_at({ x, y }); TileElement* tileElement = map_get_first_element_at(coordsElement);
if (tileElement == nullptr) if (tileElement == nullptr)
return; return;
do do
@ -502,7 +483,7 @@ static void ride_ratings_score_close_proximity_loops_helper(TileElement* inputTi
case TILE_ELEMENT_TYPE_PATH: case TILE_ELEMENT_TYPE_PATH:
{ {
int32_t zDiff = static_cast<int32_t>(tileElement->base_height) int32_t zDiff = static_cast<int32_t>(tileElement->base_height)
- static_cast<int32_t>(inputTileElement->base_height); - static_cast<int32_t>(coordsElement.element->base_height);
if (zDiff >= 0 && zDiff <= 16) if (zDiff >= 0 && zDiff <= 16)
{ {
proximity_score_increment(PROXIMITY_PATH_TROUGH_VERTICAL_LOOP); proximity_score_increment(PROXIMITY_PATH_TROUGH_VERTICAL_LOOP);
@ -512,11 +493,11 @@ static void ride_ratings_score_close_proximity_loops_helper(TileElement* inputTi
case TILE_ELEMENT_TYPE_TRACK: case TILE_ELEMENT_TYPE_TRACK:
{ {
bool elementsAreAt90DegAngle = ((tileElement->GetDirection() ^ inputTileElement->GetDirection()) & 1) != 0; bool elementsAreAt90DegAngle = ((tileElement->GetDirection() ^ coordsElement.element->GetDirection()) & 1) != 0;
if (elementsAreAt90DegAngle) if (elementsAreAt90DegAngle)
{ {
int32_t zDiff = static_cast<int32_t>(tileElement->base_height) int32_t zDiff = static_cast<int32_t>(tileElement->base_height)
- static_cast<int32_t>(inputTileElement->base_height); - static_cast<int32_t>(coordsElement.element->base_height);
if (zDiff >= 0 && zDiff <= 16) if (zDiff >= 0 && zDiff <= 16)
{ {
proximity_score_increment(PROXIMITY_TRACK_THROUGH_VERTICAL_LOOP); proximity_score_increment(PROXIMITY_TRACK_THROUGH_VERTICAL_LOOP);
@ -542,14 +523,11 @@ static void ride_ratings_score_close_proximity_loops(TileElement* inputTileEleme
int32_t trackType = inputTileElement->AsTrack()->GetTrackType(); int32_t trackType = inputTileElement->AsTrack()->GetTrackType();
if (trackType == TRACK_ELEM_LEFT_VERTICAL_LOOP || trackType == TRACK_ELEM_RIGHT_VERTICAL_LOOP) if (trackType == TRACK_ELEM_LEFT_VERTICAL_LOOP || trackType == TRACK_ELEM_RIGHT_VERTICAL_LOOP)
{ {
int32_t x = gRideRatingsCalcData.proximity_x; ride_ratings_score_close_proximity_loops_helper({ gRideRatingsCalcData.Proximity, inputTileElement });
int32_t y = gRideRatingsCalcData.proximity_y;
ride_ratings_score_close_proximity_loops_helper(inputTileElement, x, y);
int32_t direction = inputTileElement->GetDirection(); int32_t direction = inputTileElement->GetDirection();
x = gRideRatingsCalcData.proximity_x + CoordsDirectionDelta[direction].x; ride_ratings_score_close_proximity_loops_helper(
y = gRideRatingsCalcData.proximity_y + CoordsDirectionDelta[direction].y; { CoordsXY{ gRideRatingsCalcData.Proximity } + CoordsDirectionDelta[direction], inputTileElement });
ride_ratings_score_close_proximity_loops_helper(inputTileElement, x, y);
} }
} }
@ -559,15 +537,13 @@ static void ride_ratings_score_close_proximity_loops(TileElement* inputTileEleme
*/ */
static void ride_ratings_score_close_proximity(TileElement* inputTileElement) static void ride_ratings_score_close_proximity(TileElement* inputTileElement)
{ {
if (gRideRatingsCalcData.station_flags & RIDE_RATING_STATION_FLAG_NO_ENTRANCE) if (gRideRatingsCalcData.StationFlags & RIDE_RATING_STATION_FLAG_NO_ENTRANCE)
{ {
return; return;
} }
gRideRatingsCalcData.proximity_total++; gRideRatingsCalcData.ProximityTotal++;
int32_t x = gRideRatingsCalcData.proximity_x; TileElement* tileElement = map_get_first_element_at(gRideRatingsCalcData.Proximity);
int32_t y = gRideRatingsCalcData.proximity_y;
TileElement* tileElement = map_get_first_element_at({ x, y });
if (tileElement == nullptr) if (tileElement == nullptr)
return; return;
do do
@ -579,8 +555,8 @@ static void ride_ratings_score_close_proximity(TileElement* inputTileElement)
switch (tileElement->GetType()) switch (tileElement->GetType())
{ {
case TILE_ELEMENT_TYPE_SURFACE: case TILE_ELEMENT_TYPE_SURFACE:
gRideRatingsCalcData.proximity_base_height = tileElement->base_height; gRideRatingsCalcData.ProximityBaseHeight = tileElement->base_height;
if (tileElement->GetBaseZ() == gRideRatingsCalcData.proximity_z) if (tileElement->GetBaseZ() == gRideRatingsCalcData.Proximity.z)
{ {
proximity_score_increment(PROXIMITY_SURFACE_TOUCH); proximity_score_increment(PROXIMITY_SURFACE_TOUCH);
} }
@ -588,20 +564,20 @@ static void ride_ratings_score_close_proximity(TileElement* inputTileElement)
if (waterHeight != 0) if (waterHeight != 0)
{ {
auto z = waterHeight; auto z = waterHeight;
if (z <= gRideRatingsCalcData.proximity_z) if (z <= gRideRatingsCalcData.Proximity.z)
{ {
proximity_score_increment(PROXIMITY_WATER_OVER); proximity_score_increment(PROXIMITY_WATER_OVER);
if (z == gRideRatingsCalcData.proximity_z) if (z == gRideRatingsCalcData.Proximity.z)
{ {
proximity_score_increment(PROXIMITY_WATER_TOUCH); proximity_score_increment(PROXIMITY_WATER_TOUCH);
} }
z += 16; z += 16;
if (z == gRideRatingsCalcData.proximity_z) if (z == gRideRatingsCalcData.Proximity.z)
{ {
proximity_score_increment(PROXIMITY_WATER_LOW); proximity_score_increment(PROXIMITY_WATER_LOW);
} }
z += 112; z += 112;
if (z <= gRideRatingsCalcData.proximity_z) if (z <= gRideRatingsCalcData.Proximity.z)
{ {
proximity_score_increment(PROXIMITY_WATER_HIGH); proximity_score_increment(PROXIMITY_WATER_HIGH);
} }
@ -731,14 +707,14 @@ static void ride_ratings_score_close_proximity(TileElement* inputTileElement)
ride_ratings_score_close_proximity_in_direction(inputTileElement, (direction - 1) & 3); ride_ratings_score_close_proximity_in_direction(inputTileElement, (direction - 1) & 3);
ride_ratings_score_close_proximity_loops(inputTileElement); ride_ratings_score_close_proximity_loops(inputTileElement);
switch (gRideRatingsCalcData.proximity_track_type) switch (gRideRatingsCalcData.ProximityTrackType)
{ {
case TRACK_ELEM_BRAKES: case TRACK_ELEM_BRAKES:
gRideRatingsCalcData.num_brakes++; gRideRatingsCalcData.AmountOfBrakes++;
break; break;
case TRACK_ELEM_LEFT_REVERSER: case TRACK_ELEM_LEFT_REVERSER:
case TRACK_ELEM_RIGHT_REVERSER: case TRACK_ELEM_RIGHT_REVERSER:
gRideRatingsCalcData.num_reversers++; gRideRatingsCalcData.AmountOfReversers++;
break; break;
} }
} }
@ -926,10 +902,10 @@ static uint16_t ride_compute_upkeep(Ride* ride)
{ {
reverserMaintenanceCost = 10; reverserMaintenanceCost = 10;
} }
upkeep += reverserMaintenanceCost * gRideRatingsCalcData.num_reversers; upkeep += reverserMaintenanceCost * gRideRatingsCalcData.AmountOfReversers;
// Add maintenance cost for brake track pieces // Add maintenance cost for brake track pieces
upkeep += 20 * gRideRatingsCalcData.num_brakes; upkeep += 20 * gRideRatingsCalcData.AmountOfBrakes;
// these seem to be adhoc adjustments to a ride's upkeep/cost, times // these seem to be adhoc adjustments to a ride's upkeep/cost, times
// various variables set on the ride itself. // various variables set on the ride itself.
@ -1084,7 +1060,7 @@ static uint32_t get_proximity_score_helper_3(uint16_t x, uint16_t resultIfNotZer
*/ */
static uint32_t ride_ratings_get_proximity_score() static uint32_t ride_ratings_get_proximity_score()
{ {
const uint16_t* scores = gRideRatingsCalcData.proximity_scores; const uint16_t* scores = gRideRatingsCalcData.ProximityScores;
uint32_t result = 0; uint32_t result = 0;
result += get_proximity_score_helper_1(scores[PROXIMITY_WATER_OVER], 60, 0x00AAAA); result += get_proximity_score_helper_1(scores[PROXIMITY_WATER_OVER], 60, 0x00AAAA);
@ -3393,7 +3369,7 @@ void ride_ratings_calculate_reverser_roller_coaster(Ride* ride)
ride_ratings_apply_max_speed(&ratings, ride, 44281, 88562, 35424); ride_ratings_apply_max_speed(&ratings, ride, 44281, 88562, 35424);
ride_ratings_apply_average_speed(&ratings, ride, 364088, 655360); ride_ratings_apply_average_speed(&ratings, ride, 364088, 655360);
int32_t numReversers = std::min<uint16_t>(gRideRatingsCalcData.num_reversers, 6); int32_t numReversers = std::min<uint16_t>(gRideRatingsCalcData.AmountOfReversers, 6);
ride_rating reverserRating = numReversers * RIDE_RATING(0, 20); ride_rating reverserRating = numReversers * RIDE_RATING(0, 20);
ride_ratings_add(&ratings, reverserRating, reverserRating, reverserRating); ride_ratings_add(&ratings, reverserRating, reverserRating, reverserRating);
@ -3405,7 +3381,7 @@ void ride_ratings_calculate_reverser_roller_coaster(Ride* ride)
ride_ratings_apply_proximity(&ratings, 22367); ride_ratings_apply_proximity(&ratings, 22367);
ride_ratings_apply_scenery(&ratings, ride, 11155); ride_ratings_apply_scenery(&ratings, ride, 11155);
if (gRideRatingsCalcData.num_reversers < 1) if (gRideRatingsCalcData.AmountOfReversers < 1)
{ {
ratings.Excitement /= 8; ratings.Excitement /= 8;
} }

View File

@ -10,6 +10,7 @@
#pragma once #pragma once
#include "../common.h" #include "../common.h"
#include "../world/Location.hpp"
#include "RideTypes.h" #include "RideTypes.h"
using ride_rating = fixed16_2dp; using ride_rating = fixed16_2dp;
@ -39,21 +40,17 @@ enum
struct RideRatingCalculationData struct RideRatingCalculationData
{ {
uint16_t proximity_x; CoordsXYZ Proximity;
uint16_t proximity_y; CoordsXYZ ProximityStart;
uint16_t proximity_z; ride_id_t CurrentRide;
uint16_t proximity_start_x; uint8_t State;
uint16_t proximity_start_y; uint8_t ProximityTrackType;
uint16_t proximity_start_z; uint8_t ProximityBaseHeight;
ride_id_t current_ride; uint16_t ProximityTotal;
uint8_t state; uint16_t ProximityScores[26];
uint8_t proximity_track_type; uint16_t AmountOfBrakes;
uint8_t proximity_base_height; uint16_t AmountOfReversers;
uint16_t proximity_total; uint16_t StationFlags;
uint16_t proximity_scores[26];
uint16_t num_brakes;
uint16_t num_reversers;
uint16_t station_flags;
}; };
extern RideRatingCalculationData gRideRatingsCalcData; extern RideRatingCalculationData gRideRatingsCalcData;