Use named casts on openrct2/ride (#11163)

Excluding subfolders
This commit is contained in:
Tulio Leao authored and GitHub committed 2020-04-17 19:53:33 +02:00
1 parent 116bcb5ccb
commit b449e445f7
9 files changed
+136 -125

No files matched your search

+1 -1
View File
@@ -303,7 +303,7 @@ static bool sub_6DF21B_loop(Vehicle* vehicle)
uint16_t trackProgress = vehicle->track_progress - 1;
const rct_vehicle_info* moveInfo;
if ((int16_t)trackProgress == -1)
if (static_cast<int16_t>(trackProgress) == -1)
{
uint8_t trackType = vehicle->track_type >> 2;
_vehicleVAngleEndF64E36 = TrackDefinitions[trackType].vangle_start;
+31 -29
View File
@@ -179,7 +179,7 @@ ride_id_t GetNextFreeRideId()
{
return RIDE_ID_NULL;
}
return (ride_id_t)result;
return static_cast<ride_id_t>(result);
}
Ride* GetOrAllocateRide(ride_id_t index)
@@ -216,7 +216,7 @@ rct_ride_entry* get_ride_entry(int32_t index)
auto obj = objMgr.GetLoadedObject(OBJECT_TYPE_RIDE, index);
if (obj != nullptr)
{
result = (rct_ride_entry*)obj->GetLegacyData();
result = static_cast<rct_ride_entry*>(obj->GetLegacyData());
}
return result;
@@ -224,7 +224,7 @@ rct_ride_entry* get_ride_entry(int32_t index)
std::string_view get_ride_entry_name(size_t index)
{
if (index >= (size_t)object_entry_group_counts[OBJECT_TYPE_RIDE])
if (index >= static_cast<size_t>(object_entry_group_counts[OBJECT_TYPE_RIDE]))
{
log_error("invalid index %d for ride type", index);
return {};
@@ -245,7 +245,7 @@ rct_ride_entry* Ride::GetRideEntry() const
int32_t ride_get_count()
{
return (int32_t)GetRideManager().size();
return static_cast<int32_t>(GetRideManager().size());
}
int32_t Ride::GetTotalQueueLength() const
@@ -263,7 +263,7 @@ int32_t Ride::GetMaxQueueTime() const
for (i = 0; i < MAX_STATIONS; i++)
if (!ride_get_entrance_location(this, i).isNull())
queueTime = std::max(queueTime, stations[i].QueueTime);
return (int32_t)queueTime;
return static_cast<int32_t>(queueTime);
}
Peep* Ride::GetQueueHeadGuest(StationIndex stationIndex) const
@@ -753,7 +753,7 @@ int32_t ride_find_track_gap(const Ride* ride, CoordsXYE* input, CoordsXYE* outpu
void Ride::FormatStatusTo(void* argsV) const
{
auto args = (uint8_t*)argsV;
auto args = static_cast<uint8_t*>(argsV);
if (lifecycle_flags & RIDE_LIFECYCLE_CRASHED)
{
@@ -1140,7 +1140,7 @@ int32_t sub_6C683D(
uint16_t flags)
{
// Find the relevant track piece, prefer sequence 0 (this ensures correct behaviour for diagonal track pieces)
auto location = CoordsXYZD{ *x, *y, *z, (Direction)direction };
auto location = CoordsXYZD{ *x, *y, *z, static_cast<Direction>(direction) };
auto trackElement = map_get_track_element_at_of_type_seq(location, type, 0);
if (trackElement == nullptr)
{
@@ -1180,14 +1180,14 @@ int32_t sub_6C683D(
map_invalidate_tile_full(cur);
trackElement = map_get_track_element_at_of_type_seq(
{ cur.x, cur.y, cur_z, (Direction)direction }, type, trackBlock[i].index);
{ cur.x, cur.y, cur_z, static_cast<Direction>(direction) }, type, trackBlock[i].index);
if (trackElement == nullptr)
{
return 1;
}
if (i == 0 && output_element != nullptr)
{
*output_element = (TileElement*)trackElement;
*output_element = reinterpret_cast<TileElement*>(trackElement);
}
if (flags & (1 << 0))
{
@@ -1199,11 +1199,11 @@ int32_t sub_6C683D(
}
if (flags & (1 << 2))
{
trackElement->SetColourScheme((uint8_t)(extra_params & 0xFF));
trackElement->SetColourScheme(static_cast<uint8_t>(extra_params & 0xFF));
}
if (flags & (1 << 5))
{
trackElement->SetSeatRotation((uint8_t)(extra_params & 0xFF));
trackElement->SetSeatRotation(static_cast<uint8_t>(extra_params & 0xFF));
}
if (flags & (1 << 3))
{
@@ -2018,7 +2018,7 @@ void Ride::Update()
window_invalidate_flags |= RIDE_INVALIDATE_RIDE_INCOME;
if (upkeep_cost != MONEY16_UNDEFINED)
profit = (income_per_hour - ((money32)upkeep_cost * 16));
profit = (income_per_hour - (static_cast<money32>(upkeep_cost * 16)));
}
// Ride specific updates
@@ -2031,7 +2031,7 @@ void Ride::Update()
// Various things include news messages
if (lifecycle_flags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_DUE_INSPECTION))
if (((gCurrentTicks >> 1) & 255) == (uint32_t)id)
if (((gCurrentTicks >> 1) & 255) == static_cast<uint32_t>(id))
ride_breakdown_status_update(this);
ride_inspection_update(this);
@@ -2305,7 +2305,7 @@ static void ride_breakdown_update(Ride* ride)
// Calculate breakdown probability?
int32_t unreliabilityAccumulator = ride->unreliability_factor + get_age_penalty(ride);
ride->reliability = (uint16_t)std::max(0, (ride->reliability - unreliabilityAccumulator));
ride->reliability = static_cast<uint16_t>(std::max(0, (ride->reliability - unreliabilityAccumulator)));
ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_MAINTENANCE;
// Random probability of a breakdown. Roughly this is 1 in
@@ -2314,7 +2314,8 @@ static void ride_breakdown_update(Ride* ride)
//
// a 0.8% chance, less the breakdown factor which accumulates as the game
// continues.
if ((ride->reliability == 0 || (int32_t)(scenario_rand() & 0x2FFFFF) <= 1 + RIDE_INITIAL_RELIABILITY - ride->reliability)
if ((ride->reliability == 0
|| static_cast<int32_t>(scenario_rand() & 0x2FFFFF) <= 1 + RIDE_INITIAL_RELIABILITY - ride->reliability)
&& !gCheatsDisableAllBreakdowns)
{
int32_t breakdownReason = ride_get_new_breakdown_problem(ride);
@@ -3116,7 +3117,7 @@ void ride_set_vehicle_colours_to_random_preset(Ride* ride, uint8_t preset_index)
else
{
ride->colour_scheme_type = RIDE_COLOUR_SCHEME_DIFFERENT_PER_TRAIN;
uint32_t count = std::min(presetList->count, (uint8_t)32);
uint32_t count = std::min(presetList->count, static_cast<uint8_t>(32));
for (uint32_t i = 0; i < count; i++)
{
vehicle_colour* preset = &presetList->list[i];
@@ -3528,7 +3529,7 @@ int32_t ride_music_params_update(
if (pany2 > 0)
{
pany2 = -((pany2 / 4) - 1024) / 4;
vol1 = (uint8_t)pany2;
vol1 = static_cast<uint8_t>(pany2);
if (pany2 >= 256)
{
vol1 = 255;
@@ -3547,7 +3548,7 @@ int32_t ride_music_params_update(
if (panx2 > 0)
{
panx2 = -((panx2 / 4) - 1024) / 4;
vol2 = (uint8_t)panx2;
vol2 = static_cast<uint8_t>(panx2);
if (panx2 >= 256)
{
vol2 = 255;
@@ -3565,7 +3566,7 @@ int32_t ride_music_params_update(
{
vol1 = vol1 - (gVolumeAdjustZoom * 3);
}
int32_t v32 = -(((uint8_t)(-vol1 - 1) * (uint8_t)(-vol1 - 1)) / 16) - 700;
int32_t v32 = -((static_cast<uint8_t>(-vol1 - 1) * static_cast<uint8_t>(-vol1 - 1)) / 16) - 700;
if (vol1 && v32 >= -4000)
{
if (pan_x > 10000)
@@ -3597,7 +3598,7 @@ int32_t ride_music_params_update(
*tuneId = 0xFF;
return 0;
}
a1 = (uint32_t)Mixer_Channel_GetOffset(gRideMusicList[channel].sound_channel);
a1 = static_cast<uint32_t>(Mixer_Channel_GetOffset(gRideMusicList[channel].sound_channel));
return ride_music_params_update_label_51(a1, tuneId, ride, v32, pan_x, sampleRate);
}
@@ -5939,7 +5940,7 @@ void set_vehicle_type_image_max_sizes(rct_ride_entry_vehicle* vehicle_type, int3
uint8_t bitmap[200][200] = { 0 };
rct_drawpixelinfo dpi = {
/*.bits = */ (uint8_t*)bitmap,
/*.bits = */ reinterpret_cast<uint8_t*>(bitmap),
/*.x = */ -100,
/*.y = */ -100,
/*.width = */ 200,
@@ -6665,7 +6666,7 @@ void Ride::UpdateMaxVehicles()
}
}
int32_t newCarsPerTrain = std::max(proposed_num_cars_per_train, rideEntry->min_cars_in_train);
maxCarsPerTrain = std::max(maxCarsPerTrain, (int32_t)rideEntry->min_cars_in_train);
maxCarsPerTrain = std::max(maxCarsPerTrain, static_cast<int32_t>(rideEntry->min_cars_in_train));
if (!gCheatsDisableTrainLengthLimit)
{
newCarsPerTrain = std::min(maxCarsPerTrain, newCarsPerTrain);
@@ -6743,7 +6744,7 @@ void Ride::UpdateMaxVehicles()
}
max_trains = maxNumTrains;
numCarsPerTrain = std::min(proposed_num_cars_per_train, (uint8_t)newCarsPerTrain);
numCarsPerTrain = std::min(proposed_num_cars_per_train, static_cast<uint8_t>(newCarsPerTrain));
}
else
{
@@ -6757,7 +6758,7 @@ void Ride::UpdateMaxVehicles()
{
maxNumTrains = 31;
}
numVehicles = std::min(proposed_num_vehicles, (uint8_t)maxNumTrains);
numVehicles = std::min(proposed_num_vehicles, static_cast<uint8_t>(maxNumTrains));
// Refresh new current num vehicles / num cars per vehicle
if (numVehicles != num_vehicles || numCarsPerTrain != num_cars_per_train)
@@ -7570,7 +7571,7 @@ void determine_ride_entrance_and_exit_locations()
}
else
{
ride.stations[stationIndex].Entrance.direction = (uint8_t)entranceElement->GetDirection();
ride.stations[stationIndex].Entrance.direction = static_cast<uint8_t>(entranceElement->GetDirection());
}
}
@@ -7585,7 +7586,7 @@ void determine_ride_entrance_and_exit_locations()
}
else
{
ride.stations[stationIndex].Exit.direction = (uint8_t)entranceElement->GetDirection();
ride.stations[stationIndex].Exit.direction = static_cast<uint8_t>(entranceElement->GetDirection());
}
}
@@ -7640,7 +7641,7 @@ void determine_ride_entrance_and_exit_locations()
x,
y,
entranceElement->base_height,
(uint8_t)entranceElement->GetDirection(),
static_cast<uint8_t>(entranceElement->GetDirection()),
};
ride_set_entrance_location(&ride, stationIndex, newEntranceLoc);
alreadyFoundEntrance = true;
@@ -7662,7 +7663,8 @@ void determine_ride_entrance_and_exit_locations()
// Found our exit
ride_set_exit_location(
&ride, stationIndex,
{ x, y, entranceElement->base_height, (uint8_t)entranceElement->GetDirection() });
{ x, y, entranceElement->base_height,
static_cast<uint8_t>(entranceElement->GetDirection()) });
alreadyFoundExit = true;
log_verbose(
@@ -7714,7 +7716,7 @@ std::string Ride::GetName() const
size_t Ride::FormatNameTo(void* argsV) const
{
auto args = (uint8_t*)argsV;
auto args = static_cast<uint8_t*>(argsV);
if (!custom_name.empty())
{
auto str = custom_name.c_str();
+5 -5
View File
@@ -977,7 +977,7 @@ struct RideManager
, _index(beginIndex)
, _endIndex(endIndex)
{
if (_index < _endIndex && _rideManager[(ride_id_t)_index] == nullptr)
if (_index < _endIndex && _rideManager[static_cast<ride_id_t>(_index)] == nullptr)
{
++(*this);
}
@@ -989,7 +989,7 @@ struct RideManager
do
{
_index++;
} while (_index < _endIndex && _rideManager[(ride_id_t)_index] == nullptr);
} while (_index < _endIndex && _rideManager[static_cast<ride_id_t>(_index)] == nullptr);
return *this;
}
Iterator operator++(int)
@@ -1008,7 +1008,7 @@ struct RideManager
}
Ride& operator*()
{
return *_rideManager[(ride_id_t)_index];
return *_rideManager[static_cast<ride_id_t>(_index)];
}
};
@@ -1017,11 +1017,11 @@ struct RideManager
Iterator end();
Iterator begin() const
{
return ((RideManager*)this)->begin();
return (const_cast<RideManager*>(this))->begin();
}
Iterator end() const
{
return ((RideManager*)this)->end();
return (const_cast<RideManager*>(this))->end();
}
};
+20 -12
View File
@@ -454,7 +454,8 @@ static void ride_ratings_score_close_proximity_in_direction(TileElement* inputTi
}
break;
case TILE_ELEMENT_TYPE_PATH:
if (abs((int32_t)inputTileElement->base_height - (int32_t)tileElement->base_height) <= 2)
if (abs(static_cast<int32_t>(inputTileElement->base_height) - static_cast<int32_t>(tileElement->base_height))
<= 2)
{
proximity_score_increment(PROXIMITY_PATH_SIDE_CLOSE);
}
@@ -462,7 +463,9 @@ static void ride_ratings_score_close_proximity_in_direction(TileElement* inputTi
case TILE_ELEMENT_TYPE_TRACK:
if (inputTileElement->AsTrack()->GetRideIndex() != tileElement->AsTrack()->GetRideIndex())
{
if (abs((int32_t)inputTileElement->base_height - (int32_t)tileElement->base_height) <= 2)
if (abs(static_cast<int32_t>(inputTileElement->base_height)
- static_cast<int32_t>(tileElement->base_height))
<= 2)
{
proximity_score_increment(PROXIMITY_FOREIGN_TRACK_SIDE_CLOSE);
}
@@ -500,7 +503,8 @@ static void ride_ratings_score_close_proximity_loops_helper(TileElement* inputTi
{
case TILE_ELEMENT_TYPE_PATH:
{
int32_t zDiff = (int32_t)tileElement->base_height - (int32_t)inputTileElement->base_height;
int32_t zDiff = static_cast<int32_t>(tileElement->base_height)
- static_cast<int32_t>(inputTileElement->base_height);
if (zDiff >= 0 && zDiff <= 16)
{
proximity_score_increment(PROXIMITY_PATH_TROUGH_VERTICAL_LOOP);
@@ -513,7 +517,8 @@ static void ride_ratings_score_close_proximity_loops_helper(TileElement* inputTi
bool elementsAreAt90DegAngle = ((tileElement->GetDirection() ^ inputTileElement->GetDirection()) & 1) != 0;
if (elementsAreAt90DegAngle)
{
int32_t zDiff = (int32_t)tileElement->base_height - (int32_t)inputTileElement->base_height;
int32_t zDiff = static_cast<int32_t>(tileElement->base_height)
- static_cast<int32_t>(inputTileElement->base_height);
if (zDiff >= 0 && zDiff <= 16)
{
proximity_score_increment(PROXIMITY_TRACK_THROUGH_VERTICAL_LOOP);
@@ -669,7 +674,7 @@ static void ride_ratings_score_close_proximity(TileElement* inputTileElement)
}
if (inputTileElement->clearance_height + 2 == tileElement->base_height)
{
if ((uint8_t)(inputTileElement->clearance_height + 10) >= tileElement->base_height)
if (static_cast<uint8_t>(inputTileElement->clearance_height + 10) >= tileElement->base_height)
{
proximity_score_increment(PROXIMITY_FOREIGN_TRACK_CLOSE_ABOVE);
}
@@ -881,7 +886,7 @@ static uint16_t ride_compute_upkeep(Ride* ride)
{
totalLength *= 20;
}
upkeep += (uint16_t)(totalLength >> 10);
upkeep += static_cast<uint16_t>(totalLength >> 10);
if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_RIDE_PHOTO)
{
@@ -963,9 +968,9 @@ static void ride_ratings_apply_adjustments(Ride* ride, rating_tuple* ratings)
// Apply ride entry multipliers
ride_ratings_add(
ratings, (((int32_t)ratings->excitement * rideEntry->excitement_multiplier) >> 7),
(((int32_t)ratings->intensity * rideEntry->intensity_multiplier) >> 7),
(((int32_t)ratings->nausea * rideEntry->nausea_multiplier) >> 7));
ratings, ((static_cast<int32_t>(ratings->excitement) * rideEntry->excitement_multiplier) >> 7),
((static_cast<int32_t>(ratings->intensity) * rideEntry->intensity_multiplier) >> 7),
((static_cast<int32_t>(ratings->nausea) * rideEntry->nausea_multiplier) >> 7));
// Apply total air time
#ifdef ORIGINAL_RATINGS
@@ -1265,7 +1270,8 @@ static rating_tuple get_special_track_elements_rating(uint8_t type, Ride* ride)
int32_t helixesOver5UpTo10 = std::clamp<int32_t>(helixSections - 5, 0, 10);
nausea += (helixesOver5UpTo10 * 0x140000) >> 16;
rating_tuple rating = { (ride_rating)excitement, (ride_rating)intensity, (ride_rating)nausea };
rating_tuple rating = { static_cast<ride_rating>(excitement), static_cast<ride_rating>(intensity),
static_cast<ride_rating>(nausea) };
return rating;
}
@@ -1303,7 +1309,8 @@ static rating_tuple ride_ratings_get_turns_ratings(Ride* ride)
intensity += inversionsRating.intensity;
nausea += inversionsRating.nausea;
rating_tuple rating = { (ride_rating)excitement, (ride_rating)intensity, (ride_rating)nausea };
rating_tuple rating = { static_cast<ride_rating>(excitement), static_cast<ride_rating>(intensity),
static_cast<ride_rating>(nausea) };
return rating;
}
@@ -1341,7 +1348,8 @@ static rating_tuple ride_ratings_get_sheltered_ratings(Ride* ride)
lowerVal = std::min<uint8_t>(lowerVal, 11);
excitement += (lowerVal * 774516) >> 16;
rating_tuple rating = { (ride_rating)excitement, (ride_rating)intensity, (ride_rating)nausea };
rating_tuple rating = { static_cast<ride_rating>(excitement), static_cast<ride_rating>(intensity),
static_cast<ride_rating>(nausea) };
return rating;
}
+1 -1
View File
@@ -17,7 +17,7 @@ using ride_rating = fixed16_2dp;
// Convenience function for writing ride ratings. The result is a 16 bit signed
// integer. To create the ride rating 3.65 type RIDE_RATING(3,65)
#define RIDE_RATING(whole, fraction) FIXED_2DP(whole, fraction)
#define RIDE_RATING_UNDEFINED (ride_rating)(uint16_t) 0xFFFF
#define RIDE_RATING_UNDEFINED static_cast<ride_rating>(static_cast<uint16_t>(0xFFFF))
#pragma pack(push, 1)
+9 -9
View File
@@ -135,8 +135,8 @@ rct_string_id TrackDesign::CreateTrackDesign(const Ride& ride)
num_circuits = ride.num_circuits;
entrance_style = ride.entrance_style;
max_speed = (int8_t)(ride.max_speed / 65536);
average_speed = (int8_t)(ride.average_speed / 65536);
max_speed = static_cast<int8_t>(ride.max_speed / 65536);
average_speed = static_cast<int8_t>(ride.average_speed / 65536);
ride_length = ride_get_total_length(&ride) / 65536;
max_positive_vertical_g = ride.max_positive_vertical_g / 32;
max_negative_vertical_g = ride.max_negative_vertical_g / 32;
@@ -152,7 +152,7 @@ rct_string_id TrackDesign::CreateTrackDesign(const Ride& ride)
{
totalAirTime = 0;
}
total_air_time = (uint8_t)totalAirTime;
total_air_time = static_cast<uint8_t>(totalAirTime);
excitement = ride.ratings.excitement / 10;
intensity = ride.ratings.intensity / 10;
@@ -408,8 +408,8 @@ rct_string_id TrackDesign::CreateTrackDesignMaze(const Ride& ride)
TrackDesignMazeElement mazeEntrance{};
mazeEntrance.direction = entranceDirection;
mazeEntrance.type = 8;
mazeEntrance.x = (int8_t)((entranceLoc.x - startLoc.x) / 32);
mazeEntrance.y = (int8_t)((entranceLoc.y - startLoc.y) / 32);
mazeEntrance.x = static_cast<int8_t>((entranceLoc.x - startLoc.x) / 32);
mazeEntrance.y = static_cast<int8_t>((entranceLoc.y - startLoc.y) / 32);
maze_elements.push_back(mazeEntrance);
location = ride_get_exit_location(&ride, 0);
@@ -437,8 +437,8 @@ rct_string_id TrackDesign::CreateTrackDesignMaze(const Ride& ride)
TrackDesignMazeElement mazeExit{};
mazeExit.direction = exit_direction;
mazeExit.type = 0x80;
mazeExit.x = (int8_t)((exitLoc.x - startLoc.x) / 32);
mazeExit.y = (int8_t)((exitLoc.y - startLoc.y) / 32);
mazeExit.x = static_cast<int8_t>((exitLoc.x - startLoc.x) / 32);
mazeExit.y = static_cast<int8_t>((exitLoc.y - startLoc.y) / 32);
maze_elements.push_back(mazeExit);
// Save global vars as they are still used by scenery????
@@ -670,7 +670,7 @@ static void track_design_mirror_scenery(TrackDesign* td6)
entryIndex = 0;
}
rct_scenery_entry* scenery_entry = (rct_scenery_entry*)object_entry_get_chunk(entry_type, entryIndex);
rct_scenery_entry* scenery_entry = static_cast<rct_scenery_entry*>(object_entry_get_chunk(entry_type, entryIndex));
switch (entry_type)
{
case OBJECT_TYPE_LARGE_SCENERY:
@@ -2103,7 +2103,7 @@ void track_design_draw_preview(TrackDesign* td6, uint8_t* pixels)
*/
static map_backup* track_design_preview_backup_map()
{
map_backup* backup = (map_backup*)malloc(sizeof(map_backup));
map_backup* backup = static_cast<map_backup*>(malloc(sizeof(map_backup)));
if (backup != nullptr)
{
std::memcpy(backup->tile_elements, gTileElements, sizeof(backup->tile_elements));
+1 -1
View File
@@ -141,7 +141,7 @@ static int32_t tile_element_get_total_element_count(TileElement* tileElement)
{
tile++;
elementCount++;
} while (tile->x_offset != (int16_t)(uint16_t)0xFFFF);
} while (tile->x_offset != static_cast<int16_t>(static_cast<uint16_t>(0xFFFF)));
return elementCount;
default:
+33 -32
View File
@@ -818,23 +818,23 @@ bool track_paint_util_draw_station_covers_2(
{
imageId = (baseImageId & ~IMAGE_TYPE_TRANSPARENT) + imageOffset;
sub_98197C(
session, imageId, (int8_t)offset.x, (int8_t)offset.y, bounds.x, bounds.y, (int8_t)bounds.z, offset.z,
boundsOffset.x, boundsOffset.y, boundsOffset.z);
session, imageId, static_cast<int8_t>(offset.x), static_cast<int8_t>(offset.y), bounds.x, bounds.y,
static_cast<int8_t>(bounds.z), offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z);
uint32_t edi = session->TrackColours[SCHEME_TRACK] & (0b11111 << 19);
// weird jump
imageId = (baseImageId | edi) + ((1 << 23) | (1 << 24) | (1 << 25)) + imageOffset + 12;
sub_98199C(
session, imageId, (int8_t)offset.x, (int8_t)offset.y, bounds.x, bounds.y, (int8_t)bounds.z, offset.z,
boundsOffset.x, boundsOffset.y, boundsOffset.z);
session, imageId, static_cast<int8_t>(offset.x), static_cast<int8_t>(offset.y), bounds.x, bounds.y,
static_cast<int8_t>(bounds.z), offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z);
return true;
}
imageId = (baseImageId + imageOffset) | session->TrackColours[SCHEME_TRACK];
sub_98197C(
session, imageId, (int8_t)offset.x, (int8_t)offset.y, bounds.x, bounds.y, (int8_t)bounds.z, offset.z, boundsOffset.x,
boundsOffset.y, boundsOffset.z);
session, imageId, static_cast<int8_t>(offset.x), static_cast<int8_t>(offset.y), bounds.x, bounds.y,
static_cast<int8_t>(bounds.z), offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z);
return true;
}
@@ -1017,8 +1017,8 @@ void track_paint_util_right_helix_up_small_quarter_tiles_paint(
CoordsXYZ boundsOffset = (boundsOffsets == nullptr ? CoordsXYZ(offset, 0) : boundsOffsets[direction][index][0]);
sub_98197C(
session, imageId, (int8_t)offset.x, (int8_t)offset.y, boundsLength.x, boundsLength.y, thickness[0], height,
boundsOffset.x, boundsOffset.y, height + boundsOffset.z);
session, imageId, static_cast<int8_t>(offset.x), static_cast<int8_t>(offset.y), boundsLength.x, boundsLength.y,
thickness[0], height, boundsOffset.x, boundsOffset.y, height + boundsOffset.z);
}
if (sprites[direction][index][1] != 0)
{
@@ -1028,8 +1028,8 @@ void track_paint_util_right_helix_up_small_quarter_tiles_paint(
CoordsXYZ boundsOffset = (boundsOffsets == nullptr ? CoordsXYZ(offset, 0) : boundsOffsets[direction][index][1]);
sub_98197C(
session, imageId, (int8_t)offset.x, (int8_t)offset.y, boundsLength.x, boundsLength.y, thickness[1], height,
boundsOffset.x, boundsOffset.y, height + boundsOffset.z);
session, imageId, static_cast<int8_t>(offset.x), static_cast<int8_t>(offset.y), boundsLength.x, boundsLength.y,
thickness[1], height, boundsOffset.x, boundsOffset.y, height + boundsOffset.z);
}
}
@@ -1115,8 +1115,8 @@ void track_paint_util_right_helix_up_large_quarter_tiles_paint(
CoordsXYZ boundsOffset = (boundsOffsets == nullptr ? CoordsXYZ(offset, 0) : boundsOffsets[direction][index][0]);
sub_98197C(
session, imageId, (int8_t)offset.x, (int8_t)offset.y, boundsLength.x, boundsLength.y, thickness[0], height,
boundsOffset.x, boundsOffset.y, height + boundsOffset.z);
session, imageId, static_cast<int8_t>(offset.x), static_cast<int8_t>(offset.y), boundsLength.x, boundsLength.y,
thickness[0], height, boundsOffset.x, boundsOffset.y, height + boundsOffset.z);
}
if (sprites[direction][index][1] != 0)
{
@@ -1126,8 +1126,8 @@ void track_paint_util_right_helix_up_large_quarter_tiles_paint(
CoordsXYZ boundsOffset = (boundsOffsets == nullptr ? CoordsXYZ(offset, 0) : boundsOffsets[direction][index][1]);
sub_98197C(
session, imageId, (int8_t)offset.x, (int8_t)offset.y, boundsLength.x, boundsLength.y, thickness[1], height,
boundsOffset.x, boundsOffset.y, height + boundsOffset.z);
session, imageId, static_cast<int8_t>(offset.x), static_cast<int8_t>(offset.y), boundsLength.x, boundsLength.y,
thickness[1], height, boundsOffset.x, boundsOffset.y, height + boundsOffset.z);
}
}
@@ -1286,8 +1286,8 @@ void track_paint_util_eighth_to_diag_tiles_paint(
CoordsXYZ boundsOffset = (boundsOffsets == nullptr ? CoordsXYZ(offset, 0) : boundsOffsets[direction][index]);
sub_98197C(
session, imageId, (int8_t)offset.x, (int8_t)offset.y, boundsLength.x, boundsLength.y, thickness[direction][index],
height, boundsOffset.x, boundsOffset.y, height + boundsOffset.z);
session, imageId, static_cast<int8_t>(offset.x), static_cast<int8_t>(offset.y), boundsLength.x, boundsLength.y,
thickness[direction][index], height, boundsOffset.x, boundsOffset.y, height + boundsOffset.z);
}
constexpr CoordsXY defaultDiagTileOffsets[4] = {
@@ -1327,8 +1327,8 @@ void track_paint_util_diag_tiles_paint(
CoordsXYZ boundsOffset = (boundsOffsets == nullptr ? CoordsXYZ(offset, 0) : boundsOffsets[direction]);
sub_98197C(
session, imageId, (int8_t)offset.x, (int8_t)offset.y, boundsLength.x, boundsLength.y, thickness, height, boundsOffset.x,
boundsOffset.y, height + boundsOffset.z);
session, imageId, static_cast<int8_t>(offset.x), static_cast<int8_t>(offset.y), boundsLength.x, boundsLength.y,
thickness, height, boundsOffset.x, boundsOffset.y, height + boundsOffset.z);
}
const uint8_t mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[] = {
@@ -1449,8 +1449,8 @@ void track_paint_util_right_quarter_turn_5_tiles_paint(
CoordsXYZ boundsOffset = (boundsOffsets == nullptr ? CoordsXYZ(offset, 0) : boundsOffsets[direction][index]);
sub_98197C(
session, imageId, (int8_t)offset.x, (int8_t)offset.y, boundsLength.x, boundsLength.y, thickness, height, boundsOffset.x,
boundsOffset.y, height + boundsOffset.z);
session, imageId, static_cast<int8_t>(offset.x), static_cast<int8_t>(offset.y), boundsLength.x, boundsLength.y,
thickness, height, boundsOffset.x, boundsOffset.y, height + boundsOffset.z);
}
void track_paint_util_right_quarter_turn_5_tiles_paint_2(
@@ -1466,9 +1466,9 @@ void track_paint_util_right_quarter_turn_5_tiles_paint_2(
const sprite_bb* spriteBB = &sprites[direction][sprite];
uint32_t imageId = spriteBB->sprite_id | colourFlags;
sub_98197C(
session, imageId, (int8_t)spriteBB->offset.x, (int8_t)spriteBB->offset.y, spriteBB->bb_size.x, spriteBB->bb_size.y,
(int8_t)spriteBB->bb_size.z, height + spriteBB->offset.z, spriteBB->bb_offset.x, spriteBB->bb_offset.y,
height + spriteBB->bb_offset.z);
session, imageId, static_cast<int8_t>(spriteBB->offset.x), static_cast<int8_t>(spriteBB->offset.y), spriteBB->bb_size.x,
spriteBB->bb_size.y, static_cast<int8_t>(spriteBB->bb_size.z), height + spriteBB->offset.z, spriteBB->bb_offset.x,
spriteBB->bb_offset.y, height + spriteBB->bb_offset.z);
}
void track_paint_util_right_quarter_turn_5_tiles_paint_3(
@@ -1484,8 +1484,8 @@ void track_paint_util_right_quarter_turn_5_tiles_paint_3(
const sprite_bb* spriteBB = &sprites[direction][sprite];
uint32_t imageId = spriteBB->sprite_id | colourFlags;
sub_98196C(
session, imageId, (int8_t)spriteBB->offset.x, (int8_t)spriteBB->offset.y, spriteBB->bb_size.x, spriteBB->bb_size.y,
(int8_t)spriteBB->bb_size.z, height + spriteBB->offset.z);
session, imageId, static_cast<int8_t>(spriteBB->offset.x), static_cast<int8_t>(spriteBB->offset.y), spriteBB->bb_size.x,
spriteBB->bb_size.y, static_cast<int8_t>(spriteBB->bb_size.z), height + spriteBB->offset.z);
}
void track_paint_util_right_quarter_turn_5_tiles_tunnel(
@@ -1625,8 +1625,8 @@ void track_paint_util_right_quarter_turn_3_tiles_paint(
CoordsXYZ boundsOffset = (boundsOffsets == nullptr ? CoordsXYZ(offset, 0) : boundsOffsets[direction][index]);
sub_98197C(
session, imageId, (int8_t)offset.x, (int8_t)offset.y, boundsLength.x, boundsLength.y, thickness, height, boundsOffset.x,
boundsOffset.y, height + boundsOffset.z);
session, imageId, static_cast<int8_t>(offset.x), static_cast<int8_t>(offset.y), boundsLength.x, boundsLength.y,
thickness, height, boundsOffset.x, boundsOffset.y, height + boundsOffset.z);
}
void track_paint_util_right_quarter_turn_3_tiles_paint_2(
@@ -1724,9 +1724,10 @@ void track_paint_util_right_quarter_turn_3_tiles_paint_3(
}
const sprite_bb* spriteBB = &sprites[direction][sprite];
sub_98197C(
session, spriteBB->sprite_id | colourFlags, (int8_t)spriteBB->offset.x, (int8_t)spriteBB->offset.y, spriteBB->bb_size.x,
spriteBB->bb_size.y, (int8_t)spriteBB->bb_size.z, spriteBB->offset.z + height, spriteBB->bb_offset.x,
spriteBB->bb_offset.y, height + spriteBB->bb_offset.z);
session, spriteBB->sprite_id | colourFlags, static_cast<int8_t>(spriteBB->offset.x),
static_cast<int8_t>(spriteBB->offset.y), spriteBB->bb_size.x, spriteBB->bb_size.y,
static_cast<int8_t>(spriteBB->bb_size.z), spriteBB->offset.z + height, spriteBB->bb_offset.x, spriteBB->bb_offset.y,
height + spriteBB->bb_offset.z);
}
void track_paint_util_right_quarter_turn_3_tiles_paint_4(
@@ -1742,8 +1743,8 @@ void track_paint_util_right_quarter_turn_3_tiles_paint_4(
const sprite_bb* spriteBB = &sprites[direction][sprite];
uint32_t imageId = spriteBB->sprite_id | colourFlags;
sub_98196C(
session, imageId, (int8_t)spriteBB->offset.x, (int8_t)spriteBB->offset.y, spriteBB->bb_size.x, spriteBB->bb_size.y,
(int8_t)spriteBB->bb_size.z, height + spriteBB->offset.z);
session, imageId, static_cast<int8_t>(spriteBB->offset.x), static_cast<int8_t>(spriteBB->offset.y), spriteBB->bb_size.x,
spriteBB->bb_size.y, static_cast<int8_t>(spriteBB->bb_size.z), height + spriteBB->offset.z);
}
void track_paint_util_right_quarter_turn_3_tiles_tunnel(
+35 -35
View File
@@ -978,7 +978,7 @@ rct_vehicle_sound_params Vehicle::CreateSoundParam(uint16_t priority) const
frequency += 11025;
frequency += 16 * sound_vector_factor;
param.frequency = (uint16_t)frequency;
param.frequency = static_cast<uint16_t>(frequency);
param.id = sprite_index;
param.volume = 0;
@@ -1063,16 +1063,16 @@ static uint8_t vehicle_sounds_update_get_pan_volume(rct_vehicle_sound_params* so
uint8_t vol2 = 0xFF;
int16_t pan_y = std::abs(sound_params->pan_y);
pan_y = std::min((int16_t)0xFFF, pan_y);
pan_y = std::min(static_cast<int16_t>(0xFFF), pan_y);
pan_y -= 0x800;
if (pan_y > 0)
{
pan_y = (0x400 - pan_y) / 4;
vol1 = LOBYTE(pan_y);
if ((int8_t)HIBYTE(pan_y) != 0)
if (static_cast<int8_t>(HIBYTE(pan_y)) != 0)
{
vol1 = 0xFF;
if ((int8_t)HIBYTE(pan_y) < 0)
if (static_cast<int8_t>(HIBYTE(pan_y)) < 0)
{
vol1 = 0;
}
@@ -1080,17 +1080,17 @@ static uint8_t vehicle_sounds_update_get_pan_volume(rct_vehicle_sound_params* so
}
int16_t pan_x = std::abs(sound_params->pan_x);
pan_x = std::min((int16_t)0xFFF, pan_x);
pan_x = std::min(static_cast<int16_t>(0xFFF), pan_x);
pan_x -= 0x800;
if (pan_x > 0)
{
pan_x = (0x400 - pan_x) / 4;
vol2 = LOBYTE(pan_x);
if ((int8_t)HIBYTE(pan_x) != 0)
if (static_cast<int8_t>(HIBYTE(pan_x)) != 0)
{
vol2 = 0xFF;
if ((int8_t)HIBYTE(pan_x) < 0)
if (static_cast<int8_t>(HIBYTE(pan_x)) < 0)
{
vol2 = 0;
}
@@ -1611,7 +1611,7 @@ static void vehicle_update_measurements(Vehicle* vehicle)
ride->max_negative_vertical_g = gForces.VerticalG;
gForces.LateralG = std::abs(gForces.LateralG);
ride->max_lateral_g = std::max(ride->max_lateral_g, (fixed16_2dp)gForces.LateralG);
ride->max_lateral_g = std::max(ride->max_lateral_g, static_cast<fixed16_2dp>(gForces.LateralG));
}
}
@@ -1758,7 +1758,7 @@ static void vehicle_update_measurements(Vehicle* vehicle)
z = abs(z);
if (z > ride->highest_drop_height)
{
ride->highest_drop_height = (uint8_t)z;
ride->highest_drop_height = static_cast<uint8_t>(z);
}
}
}
@@ -1790,7 +1790,7 @@ static void vehicle_update_measurements(Vehicle* vehicle)
z = abs(z);
if (z > ride->highest_drop_height)
{
ride->highest_drop_height = (uint8_t)z;
ride->highest_drop_height = static_cast<uint8_t>(z);
}
}
}
@@ -4713,10 +4713,10 @@ static void vehicle_update_swinging(Vehicle* vehicle)
if (spriteType != -128)
{
vehicle->current_time++;
if ((uint8_t)spriteType != vehicle->vehicle_sprite_type)
if (static_cast<uint8_t>(spriteType) != vehicle->vehicle_sprite_type)
{
// Used to know which sprite to draw
vehicle->vehicle_sprite_type = (uint8_t)spriteType;
vehicle->vehicle_sprite_type = static_cast<uint8_t>(spriteType);
vehicle->Invalidate();
}
return;
@@ -4912,10 +4912,10 @@ static void vehicle_update_rotating(Vehicle* vehicle)
}
time++;
uint8_t sprite = timeToSpriteMap[(uint32_t)time];
uint8_t sprite = timeToSpriteMap[static_cast<uint32_t>(time)];
if (sprite != 0xFF)
{
vehicle->current_time = (uint16_t)time;
vehicle->current_time = static_cast<uint16_t>(time);
if (sprite == vehicle->vehicle_sprite_type)
return;
vehicle->vehicle_sprite_type = sprite;
@@ -5053,7 +5053,7 @@ static void vehicle_update_crooked_house_operating(Vehicle* vehicle)
return;
// Originally used an array of size 1 at 0x009A0AC4 and passed the sub state into it.
if ((uint16_t)(vehicle->current_time + 1) > 600)
if (static_cast<uint16_t>(vehicle->current_time + 1) > 600)
{
vehicle->SetState(VEHICLE_STATUS_ARRIVING);
vehicle->var_C0 = 0;
@@ -5449,9 +5449,9 @@ static void vehicle_update_crash(Vehicle* vehicle)
CoordsXYZ curPosition = { curVehicle->x, curVehicle->y, curVehicle->z };
curPosition.x += (int8_t)(curVehicle->crash_x >> 8);
curPosition.y += (int8_t)(curVehicle->crash_y >> 8);
curPosition.z += (int8_t)(curVehicle->crash_z >> 8);
curPosition.x += static_cast<int8_t>(curVehicle->crash_x >> 8);
curPosition.y += static_cast<int8_t>(curVehicle->crash_y >> 8);
curPosition.z += static_cast<int8_t>(curVehicle->crash_z >> 8);
curVehicle->TrackLocation = { (curVehicle->crash_x << 8), (curVehicle->crash_y << 8), (curVehicle->crash_z << 8) };
if (!map_is_location_valid(curPosition))
@@ -5643,7 +5643,7 @@ produceScream:
if (vehicle->scream_sound_id == SoundId::Null)
{
r = scenario_rand();
if (totalNumPeeps >= (int32_t)(r % 16))
if (totalNumPeeps >= static_cast<int32_t>(r % 16))
{
switch (vehicleEntry->sound_range)
{
@@ -5678,8 +5678,8 @@ produceScream:
*/
GForces vehicle_get_g_forces(const Vehicle* vehicle)
{
int32_t gForceVert = (((int64_t)0x280000) * Unk9A37E4[vehicle->vehicle_sprite_type]) >> 32;
gForceVert = (((int64_t)gForceVert) * Unk9A39C4[vehicle->bank_rotation]) >> 32;
int32_t gForceVert = ((static_cast<int64_t>(0x280000)) * Unk9A37E4[vehicle->vehicle_sprite_type]) >> 32;
gForceVert = ((static_cast<int64_t>(gForceVert)) * Unk9A39C4[vehicle->bank_rotation]) >> 32;
int32_t lateralFactor = 0, vertFactor = 0;
// Note shr has meant some of the below functions cast a known negative number to
@@ -5913,7 +5913,7 @@ GForces vehicle_get_g_forces(const Vehicle* vehicle)
break;
case TRACK_ELEM_HALF_LOOP_UP:
case TRACK_ELEM_FLYER_HALF_LOOP_UP:
vertFactor = (((uint16_t)(-(vehicle->track_progress - 155))) / 2) + 28;
vertFactor = ((static_cast<uint16_t>(-(vehicle->track_progress - 155))) / 2) + 28;
// 6d763E
break;
case TRACK_ELEM_HALF_LOOP_DOWN:
@@ -6093,7 +6093,7 @@ GForces vehicle_get_g_forces(const Vehicle* vehicle)
break;
case TRACK_ELEM_LEFT_LARGE_HALF_LOOP_UP:
case TRACK_ELEM_RIGHT_LARGE_HALF_LOOP_UP:
vertFactor = (((uint16_t)(-(vehicle->track_progress - 311))) / 4) + 46;
vertFactor = ((static_cast<uint16_t>(-(vehicle->track_progress - 311))) / 4) + 46;
// 6d7666
break;
case TRACK_ELEM_RIGHT_LARGE_HALF_LOOP_DOWN:
@@ -6142,7 +6142,7 @@ GForces vehicle_get_g_forces(const Vehicle* vehicle)
case TRACK_ELEM_90_DEG_TO_INVERTED_FLAT_QUARTER_LOOP_UP:
case TRACK_ELEM_MULTIDIM_90_DEG_UP_TO_INVERTED_FLAT_QUARTER_LOOP:
case TRACK_ELEM_MULTIDIM_INVERTED_90_DEG_UP_TO_FLAT_QUARTER_LOOP:
vertFactor = (((uint16_t)(-(vehicle->track_progress - 137))) / 4) + 55;
vertFactor = ((static_cast<uint16_t>(-(vehicle->track_progress - 137))) / 4) + 55;
// 6D7614
break;
case TRACK_ELEM_AIR_THRUST_TOP_CAP:
@@ -6191,7 +6191,7 @@ GForces vehicle_get_g_forces(const Vehicle* vehicle)
gForceLateral *= 10;
gForceVert >>= 16;
gForceLateral >>= 16;
return { (int16_t)(gForceVert & 0xFFFF), (int16_t)(gForceLateral & 0xFFFF) };
return { static_cast<int16_t>(gForceVert & 0xFFFF), static_cast<int16_t>(gForceLateral & 0xFFFF) };
}
void vehicle_set_map_toolbar(const Vehicle* vehicle)
@@ -7243,7 +7243,7 @@ static void vehicle_update_additional_animation(Vehicle* vehicle)
uint8_t al, ah;
uint32_t eax;
uint32_t* var_C8 = (uint32_t*)&vehicle->var_C8;
uint32_t* var_C8 = reinterpret_cast<uint32_t*>(&vehicle->var_C8);
rct_ride_entry_vehicle* vehicleEntry = vehicle_get_vehicle_entry(vehicle);
if (vehicleEntry == nullptr)
{
@@ -8925,7 +8925,7 @@ loc_6DC743:
vehicle->track_progress++;
break;
case 1: // loc_6DC7ED
vehicle->var_D3 = (uint8_t)moveInfo->z;
vehicle->var_D3 = static_cast<uint8_t>(moveInfo->z);
vehicle->track_progress++;
break;
case 2: // loc_6DC800
@@ -9028,7 +9028,7 @@ loc_6DC743:
if (_vehicleVelocityF64E08 >= 0)
{
regs.bp = vehicle->prev_vehicle_on_ride;
vehicle_update_motion_collision_detection(vehicle, x, y, z, (uint16_t*)&regs.bp);
vehicle_update_motion_collision_detection(vehicle, x, y, z, reinterpret_cast<uint16_t*>(&regs.bp));
}
}
goto loc_6DC99A;
@@ -9069,7 +9069,7 @@ loc_6DCA7A:
loc_6DCA9A:
regs.ax = vehicle->track_progress - 1;
if ((uint16_t)regs.ax != 0xFFFF)
if (static_cast<uint16_t>(regs.ax) != 0xFFFF)
{
goto loc_6DCC2C;
}
@@ -9182,7 +9182,7 @@ loc_6DCC2C:
if (_vehicleVelocityF64E08 >= 0)
{
regs.bp = vehicle->var_44;
if (vehicle_update_motion_collision_detection(vehicle, x, y, z, (uint16_t*)&regs.bp))
if (vehicle_update_motion_collision_detection(vehicle, x, y, z, reinterpret_cast<uint16_t*>(&regs.bp)))
{
goto loc_6DCD6B;
}
@@ -9293,11 +9293,11 @@ loc_6DCEB2:
if (_vehicleVelocityF64E08 >= 0)
{
regs.si = vehicle->next_vehicle_on_train;
if ((uint16_t)regs.si == SPRITE_INDEX_NULL)
if (static_cast<uint16_t>(regs.si) == SPRITE_INDEX_NULL)
{
goto loc_6DCEFF;
}
vehicle = GET_VEHICLE((uint16_t)regs.si);
vehicle = GET_VEHICLE(static_cast<uint16_t>(regs.si));
goto loc_6DC40E;
}
@@ -9322,11 +9322,11 @@ loc_6DCEFF:
regs.bp += vehicle->mass;
regs.eax += vehicle->acceleration;
regs.si = vehicle->next_vehicle_on_train;
if ((uint16_t)regs.si == SPRITE_INDEX_NULL)
if (static_cast<uint16_t>(regs.si) == SPRITE_INDEX_NULL)
{
break;
}
vehicle = GET_VEHICLE((uint16_t)regs.si);
vehicle = GET_VEHICLE(static_cast<uint16_t>(regs.si));
}
vehicle = gCurrentVehicle;
@@ -9991,7 +9991,7 @@ Vehicle* Vehicle::GetHead()
const Vehicle* Vehicle::GetHead() const
{
return ((Vehicle*)this)->GetHead();
return (const_cast<Vehicle*>(this)->GetHead());
}
const Vehicle* Vehicle::GetCar(size_t carIndex) const