diff --git a/src/openrct2/ride/Track.cpp b/src/openrct2/ride/Track.cpp index 7aa0247ffc..7ce8324615 100644 --- a/src/openrct2/ride/Track.cpp +++ b/src/openrct2/ride/Track.cpp @@ -26,6 +26,7 @@ #include "../rct1.h" #include "../util/sawyercoding.h" #include "../util/util.h" +#include "../world/map.h" #include "../world/map_animation.h" #include "../world/park.h" #include "../world/scenery.h" @@ -37,12 +38,12 @@ #include "station.h" #include "Track.h" #include "track_data.h" -#include "../world/map.h" uint8 gTrackGroundFlags; /** rct2: 0x00997C9D */ -const rct_trackdefinition TrackDefinitions[256] = { +const rct_trackdefinition TrackDefinitions[256] = +{ // TYPE VANGLE END VANGLE START BANK END BANK START SPECIAL { TRACK_FLAT, TRACK_SLOPE_NONE, TRACK_SLOPE_NONE, TRACK_BANK_NONE, TRACK_BANK_NONE, TRACK_NONE }, // ELEM_FLAT { TRACK_STATION_END, TRACK_SLOPE_NONE, TRACK_SLOPE_NONE, TRACK_BANK_NONE, TRACK_BANK_NONE, TRACK_NONE }, // ELEM_END_STATION @@ -303,7 +304,8 @@ const rct_trackdefinition TrackDefinitions[256] = { }; /** rct2: 0x0099849D */ -const rct_trackdefinition FlatRideTrackDefinitions[256] = { +const rct_trackdefinition FlatRideTrackDefinitions[256] = +{ // TYPE VANGLE END VANGLE START BANK END BANK START SPECIAL { TRACK_FLAT, TRACK_SLOPE_NONE, TRACK_SLOPE_NONE, TRACK_BANK_NONE, TRACK_BANK_NONE, 0 }, // 0 { TRACK_STATION_END, TRACK_SLOPE_NONE, TRACK_SLOPE_NONE, TRACK_BANK_NONE, TRACK_BANK_NONE, 0 }, // 1 @@ -565,61 +567,71 @@ const rct_trackdefinition FlatRideTrackDefinitions[256] = { /** * Helper method to determine if a connects to b by its bank and angle, not location. */ -sint32 track_is_connected_by_shape(rct_map_element *a, rct_map_element *b) +sint32 track_is_connected_by_shape(rct_map_element * a, rct_map_element * b) { sint32 trackType, aBank, aAngle, bBank, bAngle; trackType = a->properties.track.type; - aBank = TrackDefinitions[trackType].bank_end; - aAngle = TrackDefinitions[trackType].vangle_end; - aBank = track_get_actual_bank(a, aBank); + aBank = TrackDefinitions[trackType].bank_end; + aAngle = TrackDefinitions[trackType].vangle_end; + aBank = track_get_actual_bank(a, aBank); trackType = b->properties.track.type; - bBank = TrackDefinitions[trackType].bank_start; - bAngle = TrackDefinitions[trackType].vangle_start; - bBank = track_get_actual_bank(b, bBank); + bBank = TrackDefinitions[trackType].bank_start; + bAngle = TrackDefinitions[trackType].vangle_start; + bBank = track_get_actual_bank(b, bBank); return aBank == bBank && aAngle == bAngle; } -const rct_preview_track *get_track_def_from_ride(Ride *ride, sint32 trackType) +const rct_preview_track * get_track_def_from_ride(Ride * ride, sint32 trackType) { return ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE) ? - FlatRideTrackBlocks[trackType] : - TrackBlocks[trackType]; + FlatRideTrackBlocks[trackType] : + TrackBlocks[trackType]; } -const rct_track_coordinates *get_track_coord_from_ride(Ride *ride, sint32 trackType){ +const rct_track_coordinates * get_track_coord_from_ride(Ride * ride, sint32 trackType) +{ return ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE) ? - &FlatTrackCoordinates[trackType] : - &TrackCoordinates[trackType]; + &FlatTrackCoordinates[trackType] : + &TrackCoordinates[trackType]; } -const rct_preview_track *get_track_def_from_ride_index(sint32 rideIndex, sint32 trackType) +const rct_preview_track * get_track_def_from_ride_index(sint32 rideIndex, sint32 trackType) { return get_track_def_from_ride(get_ride(rideIndex), trackType); } -static rct_map_element *find_station_element(sint32 x, sint32 y, sint32 z, sint32 direction, sint32 rideIndex) +static rct_map_element * find_station_element(sint32 x, sint32 y, sint32 z, sint32 direction, sint32 rideIndex) { - rct_map_element *mapElement = map_get_first_element_at(x >> 5, y >> 5); - do { - if (z != mapElement->base_height) continue; - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK) continue; - if (map_element_get_direction(mapElement) != direction) continue; - if (mapElement->properties.track.ride_index != rideIndex) continue; - if (!track_element_is_station(mapElement)) continue; + rct_map_element * mapElement = map_get_first_element_at(x >> 5, y >> 5); + do + { + if (z != mapElement->base_height) + continue; + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK) + continue; + if (map_element_get_direction(mapElement) != direction) + continue; + if (mapElement->properties.track.ride_index != rideIndex) + continue; + if (!track_element_is_station(mapElement)) + continue; return mapElement; - } while (!map_element_is_last_for_tile(mapElement++)); - return NULL; + } + while (!map_element_is_last_for_tile(mapElement++)); + return nullptr; } -static void ride_remove_station(Ride *ride, sint32 x, sint32 y, sint32 z) +static void ride_remove_station(Ride * ride, sint32 x, sint32 y, sint32 z) { for (sint32 i = 0; i < MAX_STATIONS; i++) { - if (ride->station_starts[i].x == (x >> 5) && ride->station_starts[i].y == (y >> 5) && ride->station_heights[i] == z) + if (ride->station_starts[i].x == (x >> 5) && + ride->station_starts[i].y == (y >> 5) && + ride->station_heights[i] == z) { ride->station_starts[i].xy = RCT_XY8_UNDEFINED; ride->num_stations--; @@ -634,15 +646,17 @@ static void ride_remove_station(Ride *ride, sint32 x, sint32 y, sint32 z) */ static bool track_add_station_element(sint32 x, sint32 y, sint32 z, sint32 direction, sint32 rideIndex, sint32 flags) { - sint32 stationX0 = x; - sint32 stationY0 = y; - sint32 stationX1 = x; - sint32 stationY1 = y; + sint32 stationX0 = x; + sint32 stationY0 = y; + sint32 stationX1 = x; + sint32 stationY1 = y; sint32 stationLength = 1; - Ride *ride = get_ride(rideIndex); - if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_3)) { - if (ride->num_stations >= MAX_STATIONS) { + Ride * ride = get_ride(rideIndex); + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_3)) + { + if (ride->num_stations >= MAX_STATIONS) + { gGameCommandErrorText = STR_NO_MORE_STATIONS_ALLOWED_ON_THIS_RIDE; return false; } @@ -653,27 +667,31 @@ static bool track_add_station_element(sint32 x, sint32 y, sint32 z, sint32 direc ride->station_starts[stationIndex].x = (x >> 5); ride->station_starts[stationIndex].y = (y >> 5); - ride->station_heights[stationIndex] = z; - ride->station_depart[stationIndex] = 1; - ride->station_length[stationIndex] = 0; + ride->station_heights[stationIndex] = z; + ride->station_depart[stationIndex] = 1; + ride->station_length[stationIndex] = 0; ride->num_stations++; } return true; } - rct_map_element *stationElement; + rct_map_element * stationElement; // Search backwards for more station x = stationX0; y = stationY0; - do { + do + { x -= TileDirectionDelta[direction].x; y -= TileDirectionDelta[direction].y; stationElement = find_station_element(x, y, z, direction, rideIndex); - if (stationElement != NULL) { - if (stationElement->properties.track.type == TRACK_ELEM_END_STATION) { - if (flags & GAME_COMMAND_FLAG_APPLY) { + if (stationElement != nullptr) + { + if (stationElement->properties.track.type == TRACK_ELEM_END_STATION) + { + if (flags & GAME_COMMAND_FLAG_APPLY) + { ride_remove_station(ride, x, y, z); } } @@ -682,19 +700,24 @@ static bool track_add_station_element(sint32 x, sint32 y, sint32 z, sint32 direc stationY0 = y; stationLength++; } - } while (stationElement != NULL); + } + while (stationElement != nullptr); // Search forwards for more station x = stationX1; y = stationY1; - do { + do + { x += TileDirectionDelta[direction].x; y += TileDirectionDelta[direction].y; stationElement = find_station_element(x, y, z, direction, rideIndex); - if (stationElement != NULL) { - if (stationElement->properties.track.type == TRACK_ELEM_END_STATION) { - if (flags & GAME_COMMAND_FLAG_APPLY) { + if (stationElement != nullptr) + { + if (stationElement->properties.track.type == TRACK_ELEM_END_STATION) + { + if (flags & GAME_COMMAND_FLAG_APPLY) + { ride_remove_station(ride, x, y, z); } } @@ -703,28 +726,34 @@ static bool track_add_station_element(sint32 x, sint32 y, sint32 z, sint32 direc stationY1 = y; stationLength++; } - } while (stationElement != NULL); + } + while (stationElement != nullptr); - if (stationX0 == stationX1 && stationY0 == stationY1 && ride->num_stations >= MAX_STATIONS) { + if (stationX0 == stationX1 && stationY0 == stationY1 && ride->num_stations >= MAX_STATIONS) + { gGameCommandErrorText = STR_NO_MORE_STATIONS_ALLOWED_ON_THIS_RIDE; return false; } - if (stationLength > MAX_STATION_PLATFORM_LENGTH) { + if (stationLength > MAX_STATION_PLATFORM_LENGTH) + { gGameCommandErrorText = STR_STATION_PLATFORM_TOO_LONG; return false; } - if (flags & GAME_COMMAND_FLAG_APPLY) { + if (flags & GAME_COMMAND_FLAG_APPLY) + { x = stationX1; y = stationY1; bool finaliseStationDone; - do { + do + { finaliseStationDone = true; stationElement = find_station_element(x, y, z, direction, rideIndex); - if (stationElement != NULL) { + if (stationElement != nullptr) + { sint32 targetTrackType; if (x == stationX1 && y == stationY1) { @@ -733,28 +762,34 @@ static bool track_add_station_element(sint32 x, sint32 y, sint32 z, sint32 direc ride->station_starts[stationIndex].x = (x >> 5); ride->station_starts[stationIndex].y = (y >> 5); - ride->station_heights[stationIndex] = z; - ride->station_depart[stationIndex] = 1; - ride->station_length[stationIndex] = stationLength; + ride->station_heights[stationIndex] = z; + ride->station_depart[stationIndex] = 1; + ride->station_length[stationIndex] = stationLength; ride->num_stations++; targetTrackType = TRACK_ELEM_END_STATION; - } else if (x == stationX0 && y == stationY0) { + } + else if (x == stationX0 && y == stationY0) + { targetTrackType = TRACK_ELEM_BEGIN_STATION; - } else { + } + else + { targetTrackType = TRACK_ELEM_MIDDLE_STATION; } stationElement->properties.track.type = targetTrackType; map_invalidate_element(x, y, stationElement); - if (x != stationX0 || y != stationY0) { + if (x != stationX0 || y != stationY0) + { x -= TileDirectionDelta[direction].x; y -= TileDirectionDelta[direction].y; finaliseStationDone = false; } } - } while (!finaliseStationDone); + } + while (!finaliseStationDone); } return true; } @@ -765,34 +800,40 @@ static bool track_add_station_element(sint32 x, sint32 y, sint32 z, sint32 direc */ static bool track_remove_station_element(sint32 x, sint32 y, sint32 z, sint32 direction, sint32 rideIndex, sint32 flags) { - sint32 removeX = x; - sint32 removeY = y; - sint32 stationX0 = x; - sint32 stationY0 = y; - sint32 stationX1 = x; - sint32 stationY1 = y; + sint32 removeX = x; + sint32 removeY = y; + sint32 stationX0 = x; + sint32 stationY0 = y; + sint32 stationX1 = x; + sint32 stationY1 = y; sint32 stationLength = 0; - sint32 byte_F441D1 = -1; + sint32 byte_F441D1 = -1; - Ride *ride = get_ride(rideIndex); - if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_3)) { - rct_map_element *mapElement = map_get_track_element_at_with_direction_from_ride(x, y, z, direction, rideIndex); - if (mapElement != NULL) { - if (flags & GAME_COMMAND_FLAG_APPLY) { + Ride * ride = get_ride(rideIndex); + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_3)) + { + rct_map_element * mapElement = map_get_track_element_at_with_direction_from_ride(x, y, z, direction, rideIndex); + if (mapElement != nullptr) + { + if (flags & GAME_COMMAND_FLAG_APPLY) + { ride_remove_station(ride, x, y, z); } } return true; } - rct_map_element *stationElement; + rct_map_element * stationElement; // Search backwards for more station x = stationX0; y = stationY0; - while ((stationElement = find_station_element(x, y, z, direction, rideIndex)) != NULL) { - if (stationElement->properties.track.type == TRACK_ELEM_END_STATION) { - if (flags & GAME_COMMAND_FLAG_APPLY) { + while ((stationElement = find_station_element(x, y, z, direction, rideIndex)) != nullptr) + { + if (stationElement->properties.track.type == TRACK_ELEM_END_STATION) + { + if (flags & GAME_COMMAND_FLAG_APPLY) + { ride_remove_station(ride, x, y, z); } } @@ -808,14 +849,18 @@ static bool track_remove_station_element(sint32 x, sint32 y, sint32 z, sint32 di // Search forwards for more station x = stationX1; y = stationY1; - do { + do + { x += TileDirectionDelta[direction].x; y += TileDirectionDelta[direction].y; stationElement = find_station_element(x, y, z, direction, rideIndex); - if (stationElement != NULL) { - if (stationElement->properties.track.type == TRACK_ELEM_END_STATION) { - if (flags & GAME_COMMAND_FLAG_APPLY) { + if (stationElement != nullptr) + { + if (stationElement->properties.track.type == TRACK_ELEM_END_STATION) + { + if (flags & GAME_COMMAND_FLAG_APPLY) + { ride_remove_station(ride, x, y, z); } } @@ -824,16 +869,21 @@ static bool track_remove_station_element(sint32 x, sint32 y, sint32 z, sint32 di stationY1 = y; stationLength++; } - } while (stationElement != NULL); + } + while (stationElement != nullptr); - if (!(flags & GAME_COMMAND_FLAG_APPLY)) { + if (!(flags & GAME_COMMAND_FLAG_APPLY)) + { if ((removeX != stationX0 || removeY != stationY0) && (removeX != stationX1 || removeY != stationY1) && ride->num_stations >= MAX_STATIONS - ) { + ) + { gGameCommandErrorText = STR_NO_MORE_STATIONS_ALLOWED_ON_THIS_RIDE; return false; - } else { + } + else + { return true; } } @@ -841,12 +891,15 @@ static bool track_remove_station_element(sint32 x, sint32 y, sint32 z, sint32 di x = stationX1; y = stationY1; bool finaliseStationDone; - do { + do + { finaliseStationDone = true; - if (x != removeX || y != removeY) { + if (x != removeX || y != removeY) + { stationElement = find_station_element(x, y, z, direction, rideIndex); - if (stationElement != NULL) { + if (stationElement != nullptr) + { sint32 targetTrackType; if (x == stationX1 && y == stationY1) { @@ -857,26 +910,37 @@ static bool track_remove_station_element(sint32 x, sint32 y, sint32 z, sint32 di ride->station_starts[stationIndex].x = (x >> 5); ride->station_starts[stationIndex].y = (y >> 5); ride->station_heights[stationIndex] = z; - ride->station_depart[stationIndex] = 1; - ride->station_length[stationIndex] = stationLength != 0 ? stationLength : byte_F441D1; + ride->station_depart[stationIndex] = 1; + ride->station_length[stationIndex] = stationLength != 0 ? stationLength : byte_F441D1; ride->num_stations++; - stationLength = 0; + stationLength = 0; targetTrackType = TRACK_ELEM_END_STATION; - } else { + } + else + { if (x + TileDirectionDelta[direction].x == removeX && y + TileDirectionDelta[direction].y == removeY - ) { + ) + { goto loc_6C4BF5; - } else { + } + else + { if (x - TileDirectionDelta[direction].x == removeX && y - TileDirectionDelta[direction].y == removeY - ) { + ) + { targetTrackType = TRACK_ELEM_BEGIN_STATION; - } else { - if (x == stationX0 && y == stationY0) { + } + else + { + if (x == stationX0 && y == stationY0) + { targetTrackType = TRACK_ELEM_BEGIN_STATION; - } else { + } + else + { targetTrackType = TRACK_ELEM_MIDDLE_STATION; } } @@ -888,35 +952,48 @@ static bool track_remove_station_element(sint32 x, sint32 y, sint32 z, sint32 di } } - if (x != stationX0 || y != stationY0) { + if (x != stationX0 || y != stationY0) + { x -= TileDirectionDelta[direction].x; y -= TileDirectionDelta[direction].y; finaliseStationDone = false; } - } while (!finaliseStationDone); + } + while (!finaliseStationDone); return true; } -static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 originY, sint32 originZ, sint32 direction, sint32 brakeSpeed, sint32 colour, sint32 seatRotation, sint32 liftHillAndAlternativeState, sint32 flags) +static money32 track_place(sint32 rideIndex, + sint32 type, + sint32 originX, + sint32 originY, + sint32 originZ, + sint32 direction, + sint32 brakeSpeed, + sint32 colour, + sint32 seatRotation, + sint32 liftHillAndAlternativeState, + sint32 flags) { - Ride *ride = get_ride(rideIndex); - if (ride == NULL) + Ride * ride = get_ride(rideIndex); + if (ride == nullptr) { log_warning("Invalid ride for track placement, rideIndex = %d", rideIndex); return MONEY32_UNDEFINED; } - if (ride->type == RIDE_TYPE_NULL) { + if (ride->type == RIDE_TYPE_NULL) + { log_warning("Invalid ride type, rideIndex = %d", rideIndex); return MONEY32_UNDEFINED; } - rct_ride_entry *rideEntry = get_ride_entry(ride->subtype); - if (rideEntry == NULL) + rct_ride_entry * rideEntry = get_ride_entry(ride->subtype); + if (rideEntry == nullptr) { log_warning("Invalid ride type for track placement, rideIndex = %d", rideIndex); return MONEY32_UNDEFINED; } - rct_map_element *mapElement; + rct_map_element * mapElement; gCommandExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION; gCommandPosition.x = originX + 16; @@ -924,41 +1001,56 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 gCommandPosition.z = originZ; sint16 trackpieceZ = originZ; direction &= 3; - gTrackGroundFlags = 0; + gTrackGroundFlags = 0; uint64 enabledTrackPieces = rideEntry->enabledTrackPieces & RideTypePossibleTrackConfigurations[ride->type]; - uint32 rideTypeFlags = RideProperties[ride->type].flags; + uint32 rideTypeFlags = RideProperties[ride->type].flags; - if ((ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) && type == TRACK_ELEM_END_STATION) { + if ((ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) && type == TRACK_ELEM_END_STATION) + { gGameCommandErrorText = STR_NOT_ALLOWED_TO_MODIFY_STATION; return MONEY32_UNDEFINED; } - if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED)) { - if (game_is_paused() && !gCheatsBuildInPauseMode) { + if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED)) + { + if (game_is_paused() && !gCheatsBuildInPauseMode) + { gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; return MONEY32_UNDEFINED; } } - const uint8 (*wallEdges)[16]; - if (rideTypeFlags & RIDE_TYPE_FLAG_FLAT_RIDE) { + const uint8 (* wallEdges)[16]; + if (rideTypeFlags & RIDE_TYPE_FLAG_FLAT_RIDE) + { wallEdges = &FlatRideTrackSequenceElementAllowedWallEdges[type]; - } else { - if (type == TRACK_ELEM_ON_RIDE_PHOTO) { - if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_RIDE_PHOTO) { + } + else + { + if (type == TRACK_ELEM_ON_RIDE_PHOTO) + { + if (ride->lifecycle_flags & RIDE_LIFECYCLE_ON_RIDE_PHOTO) + { gGameCommandErrorText = STR_ONLY_ONE_ON_RIDE_PHOTO_PER_RIDE; return MONEY32_UNDEFINED; } - } else if (type == TRACK_ELEM_CABLE_LIFT_HILL) { - if (ride->lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED) { + } + else if (type == TRACK_ELEM_CABLE_LIFT_HILL) + { + if (ride->lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED) + { gGameCommandErrorText = STR_ONLY_ONE_CABLE_LIFT_HILL_PER_RIDE; return MONEY32_UNDEFINED; } } // Backwards steep lift hills are allowed, even on roller coasters that do not support forwards steep lift hills. - if ((liftHillAndAlternativeState & CONSTRUCTION_LIFT_HILL_SELECTED) && !(enabledTrackPieces & (1ULL << TRACK_LIFT_HILL_STEEP)) && !gCheatsEnableChainLiftOnAllTrack) { - if (TrackFlags[type] & TRACK_ELEM_FLAG_IS_STEEP_UP) { + if ((liftHillAndAlternativeState & CONSTRUCTION_LIFT_HILL_SELECTED) && + !(enabledTrackPieces & (1ULL << TRACK_LIFT_HILL_STEEP)) && + !gCheatsEnableChainLiftOnAllTrack) + { + if (TrackFlags[type] & TRACK_ELEM_FLAG_IS_STEEP_UP) + { gGameCommandErrorText = STR_TOO_STEEP_FOR_LIFT_HILL; return MONEY32_UNDEFINED; } @@ -967,15 +1059,17 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 wallEdges = &TrackSequenceElementAllowedWallEdges[type]; } - money32 cost = 0; - const rct_preview_track *trackBlock = get_track_def_from_ride(ride, type); - uint32 num_elements = 0; + money32 cost = 0; + const rct_preview_track * trackBlock = get_track_def_from_ride(ride, type); + uint32 num_elements = 0; // First check if any of the track pieces are outside the park - for (; trackBlock->index != 0xFF; trackBlock++) { + for (; trackBlock->index != 0xFF; trackBlock++) + { sint32 offsetX = 0; sint32 offsetY = 0; - switch (direction) { + switch (direction) + { case 0: offsetX = trackBlock->x; offsetY = trackBlock->y; @@ -998,26 +1092,33 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 sint32 y = originY + offsetY; sint32 z = originZ + trackBlock->z; - if (!map_is_location_owned(x, y, z) && !gCheatsSandboxMode) { + if (!map_is_location_owned(x, y, z) && !gCheatsSandboxMode) + { gGameCommandErrorText = STR_LAND_NOT_OWNED_BY_PARK; return MONEY32_UNDEFINED; } num_elements++; } - if (!map_check_free_elements_and_reorganise(num_elements)) { + if (!map_check_free_elements_and_reorganise(num_elements)) + { return MONEY32_UNDEFINED; } - const uint16 *trackFlags = (rideTypeFlags & RIDE_TYPE_FLAG_FLAT_RIDE) ? - FlatTrackFlags : - TrackFlags; - if (trackFlags[type] & TRACK_ELEM_FLAG_STARTS_AT_HALF_HEIGHT) { - if ((originZ & 0x0F) != 8) { + const uint16 * trackFlags = (rideTypeFlags & RIDE_TYPE_FLAG_FLAT_RIDE) ? + FlatTrackFlags : + TrackFlags; + if (trackFlags[type] & TRACK_ELEM_FLAG_STARTS_AT_HALF_HEIGHT) + { + if ((originZ & 0x0F) != 8) + { gGameCommandErrorText = STR_CONSTRUCTION_ERR_UNKNOWN; return MONEY32_UNDEFINED; } - } else { - if ((originZ & 0x0F) != 0) { + } + else + { + if ((originZ & 0x0F) != 0) + { gGameCommandErrorText = STR_CONSTRUCTION_ERR_UNKNOWN; return MONEY32_UNDEFINED; } @@ -1026,12 +1127,14 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 // If that is not the case, then perform the remaining checks trackBlock = get_track_def_from_ride(ride, type); - for (sint32 blockIndex = 0; trackBlock->index != 0xFF; trackBlock++, blockIndex++) { + for (sint32 blockIndex = 0; trackBlock->index != 0xFF; trackBlock++, blockIndex++) + { sint32 offsetX = 0; sint32 offsetY = 0; - sint32 bl = trackBlock->var_08; + sint32 bl = trackBlock->var_08; sint32 bh; - switch (direction) { + switch (direction) + { case 0: offsetX = trackBlock->x; offsetY = trackBlock->y; @@ -1039,9 +1142,9 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 case 1: offsetX = trackBlock->y; offsetY = -trackBlock->x; - bl = rol8(bl, 1); - bh = bl; - bh = ror8(bh, 4); + bl = rol8(bl, 1); + bh = bl; + bh = ror8(bh, 4); bl &= 0xEE; bh &= 0x11; bl |= bh; @@ -1049,9 +1152,9 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 case 2: offsetX = -trackBlock->x; offsetY = -trackBlock->y; - bl = rol8(bl, 2); - bh = bl; - bh = ror8(bh, 4); + bl = rol8(bl, 2); + bh = bl; + bh = ror8(bh, 4); bl &= 0xCC; bh &= 0x33; bl |= bh; @@ -1059,9 +1162,9 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 case 3: offsetX = -trackBlock->y; offsetY = trackBlock->x; - bl = rol8(bl, 3); - bh = bl; - bh = ror8(bh, 4); + bl = rol8(bl, 3); + bh = bl; + bh = ror8(bh, 4); bl &= 0x88; bh &= 0x77; bl |= bh; @@ -1073,7 +1176,8 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 trackpieceZ = z; - if (z < 16) { + if (z < 16) + { gGameCommandErrorText = STR_TOO_LOW; return MONEY32_UNDEFINED; } @@ -1081,16 +1185,19 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 sint32 baseZ = (originZ + trackBlock->z) / 8; sint32 clearanceZ = trackBlock->var_07; - if (trackBlock->var_09 & (1 << 2) && RideData5[ride->type].clearance_height > 24) { + if (trackBlock->var_09 & (1 << 2) && RideData5[ride->type].clearance_height > 24) + { clearanceZ += 24; } - else{ + else + { clearanceZ += RideData5[ride->type].clearance_height; } clearanceZ = (clearanceZ / 8) + baseZ; - if (clearanceZ >= 255) { + if (clearanceZ >= 255) + { gGameCommandErrorText = STR_TOO_HIGH; return MONEY32_UNDEFINED; } @@ -1098,23 +1205,30 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 _currentTrackEndX = x; _currentTrackEndY = y; - if (!gCheatsDisableClearanceChecks || flags & GAME_COMMAND_FLAG_GHOST){ + if (!gCheatsDisableClearanceChecks || flags & GAME_COMMAND_FLAG_GHOST) + { if (!map_can_construct_with_clear_at(x, y, baseZ, clearanceZ, &map_place_non_scenery_clear_func, bl, flags, &cost)) return MONEY32_UNDEFINED; } //6c53dc - if ((flags & GAME_COMMAND_FLAG_APPLY) && !(flags & GAME_COMMAND_FLAG_GHOST) && !gCheatsDisableClearanceChecks) { + if ((flags & GAME_COMMAND_FLAG_APPLY) && !(flags & GAME_COMMAND_FLAG_GHOST) && !gCheatsDisableClearanceChecks) + { footpath_remove_litter(x, y, z); - if (rideTypeFlags & RIDE_TYPE_FLAG_TRACK_NO_WALLS) { + if (rideTypeFlags & RIDE_TYPE_FLAG_TRACK_NO_WALLS) + { wall_remove_at(x, y, baseZ * 8, clearanceZ * 8); - } else { + } + else + { // Remove walls in the directions this track intersects uint8 intersectingDirections = (*wallEdges)[blockIndex]; intersectingDirections ^= 0x0F; - for (sint32 i = 0; i < 4; i++) { - if (intersectingDirections & (1 << i)) { + for (sint32 i = 0; i < 4; i++) + { + if (intersectingDirections & (1 << i)) + { wall_remove_intersecting_walls(x, y, baseZ, clearanceZ, i); } } @@ -1122,68 +1236,87 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 } bh = gMapGroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); - if (gTrackGroundFlags != 0 && (gTrackGroundFlags & bh) == 0) { + if (gTrackGroundFlags != 0 && (gTrackGroundFlags & bh) == 0) + { gGameCommandErrorText = STR_CANT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_GROUND; return MONEY32_UNDEFINED; } gTrackGroundFlags = bh; - if (rideTypeFlags & RIDE_TYPE_FLAG_FLAT_RIDE) { - if (FlatTrackFlags[type] & TRACK_ELEM_FLAG_ONLY_ABOVE_GROUND) { - if (gTrackGroundFlags & TRACK_ELEMENT_LOCATION_IS_UNDERGROUND) { + if (rideTypeFlags & RIDE_TYPE_FLAG_FLAT_RIDE) + { + if (FlatTrackFlags[type] & TRACK_ELEM_FLAG_ONLY_ABOVE_GROUND) + { + if (gTrackGroundFlags & TRACK_ELEMENT_LOCATION_IS_UNDERGROUND) + { gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; return MONEY32_UNDEFINED; } } } - else { - if (TrackFlags[type] & TRACK_ELEM_FLAG_ONLY_ABOVE_GROUND) { - if (gTrackGroundFlags & TRACK_ELEMENT_LOCATION_IS_UNDERGROUND) { + else + { + if (TrackFlags[type] & TRACK_ELEM_FLAG_ONLY_ABOVE_GROUND) + { + if (gTrackGroundFlags & TRACK_ELEMENT_LOCATION_IS_UNDERGROUND) + { gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; return MONEY32_UNDEFINED; } } } - if (rideTypeFlags & RIDE_TYPE_FLAG_FLAT_RIDE) { - if (FlatTrackFlags[type] & TRACK_ELEM_FLAG_ONLY_UNDERWATER) { - if (!(gMapGroundFlags & ELEMENT_IS_UNDERWATER)) { + if (rideTypeFlags & RIDE_TYPE_FLAG_FLAT_RIDE) + { + if (FlatTrackFlags[type] & TRACK_ELEM_FLAG_ONLY_UNDERWATER) + { + if (!(gMapGroundFlags & ELEMENT_IS_UNDERWATER)) + { gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_UNDERWATER; return MONEY32_UNDEFINED; } } } - else { - if (TrackFlags[type] & TRACK_ELEM_FLAG_ONLY_UNDERWATER) { // No element has this flag - if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) { + else + { + if (TrackFlags[type] & TRACK_ELEM_FLAG_ONLY_UNDERWATER) + { // No element has this flag + if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) + { gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_UNDERWATER; return MONEY32_UNDEFINED; } } } - if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) { + if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) + { gGameCommandErrorText = STR_RIDE_CANT_BUILD_THIS_UNDERWATER; return MONEY32_UNDEFINED; } - if ((rideTypeFlags & RIDE_TYPE_FLAG_TRACK_MUST_BE_ON_WATER) && !byte_9D8150) { + if ((rideTypeFlags & RIDE_TYPE_FLAG_TRACK_MUST_BE_ON_WATER) && !byte_9D8150) + { mapElement = map_get_surface_element_at(x / 32, y / 32); uint8 water_height = map_get_water_height(mapElement) * 2; - if (water_height == 0) { + if (water_height == 0) + { gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ON_WATER; return MONEY32_UNDEFINED; } - if (water_height != baseZ) { + if (water_height != baseZ) + { gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ON_WATER; return MONEY32_UNDEFINED; } water_height -= 2; - if (water_height == mapElement->base_height) { + if (water_height == mapElement->base_height) + { bh = mapElement->properties.surface.slope & 0x0F; - if (bh == 7 || bh == 11 || bh == 13 || bh == 14) { + if (bh == 7 || bh == 11 || bh == 13 || bh == 14) + { gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ON_WATER; return MONEY32_UNDEFINED; } @@ -1191,26 +1324,36 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 } sint32 entranceDirections; - if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) { + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) + { entranceDirections = FlatRideTrackSequenceProperties[type][0]; } - else { + else + { entranceDirections = TrackSequenceProperties[type][0]; } - if ((entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN) && trackBlock->index == 0) { - if (!track_add_station_element(x, y, baseZ, direction, rideIndex, 0)) { + if ((entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN) && trackBlock->index == 0) + { + if (!track_add_station_element(x, y, baseZ, direction, rideIndex, 0)) + { return MONEY32_UNDEFINED; } } //6c55be - if (entranceDirections & TRACK_SEQUENCE_FLAG_CONNECTS_TO_PATH) { + if (entranceDirections & TRACK_SEQUENCE_FLAG_CONNECTS_TO_PATH) + { entranceDirections &= 0x0F; - if (entranceDirections != 0) { - if (!(flags & GAME_COMMAND_FLAG_APPLY) && !(flags & GAME_COMMAND_FLAG_GHOST) && !gCheatsDisableClearanceChecks) { + if (entranceDirections != 0) + { + if (!(flags & GAME_COMMAND_FLAG_APPLY) && + !(flags & GAME_COMMAND_FLAG_GHOST) && + !gCheatsDisableClearanceChecks) + { uint8 _bl = entranceDirections; - for (sint32 dl = bitscanforward(_bl); dl != -1; dl = bitscanforward(_bl)){ + for (sint32 dl = bitscanforward(_bl); dl != -1; dl = bitscanforward(_bl)) + { _bl &= ~(1 << dl); - sint32 temp_x = x, temp_y = y; + sint32 temp_x = x, temp_y = y; sint32 temp_direction = (direction + dl) & 3; temp_x += TileDirectionDelta[temp_direction].x; temp_y += TileDirectionDelta[temp_direction].y; @@ -1222,29 +1365,39 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 } //6c5648 12 push mapElement = map_get_surface_element_at(x / 32, y / 32); - if (!gCheatsDisableSupportLimits){ + if (!gCheatsDisableSupportLimits) + { sint32 ride_height = clearanceZ - mapElement->base_height; - if (ride_height >= 0) { + if (ride_height >= 0) + { uint16 maxHeight; - if (gConfigInterface.select_by_track_type) { - if (ride_type_has_ride_groups(ride->type)) { + if (gConfigInterface.select_by_track_type) + { + if (ride_type_has_ride_groups(ride->type)) + { const RideGroup * rideGroup = get_ride_group(ride->type, rideEntry); maxHeight = rideGroup->MaximumHeight; - } else { + } + else + { maxHeight = RideData5[ride->type].max_height; } - } else { + } + else + { maxHeight = rideEntry->max_height; // If a rideEntry specifies 0 as max height, it means OpenRCT2 // should fall back on the default for the track type. - if (maxHeight == 0) { + if (maxHeight == 0) + { maxHeight = RideData5[ride->type].max_height; } } ride_height /= 2; - if (ride_height > maxHeight && !byte_9D8150) { + if (ride_height > maxHeight && !byte_9D8150) + { gGameCommandErrorText = STR_TOO_HIGH_FOR_SUPPORTS; return MONEY32_UNDEFINED; } @@ -1252,7 +1405,8 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 } sint32 _support_height = baseZ - mapElement->base_height; - if (_support_height < 0) { + if (_support_height < 0) + { _support_height = 10; } @@ -1264,7 +1418,8 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 continue; invalidate_test_results(rideIndex); - switch (type){ + switch (type) + { case TRACK_ELEM_ON_RIDE_PHOTO: ride->lifecycle_flags |= RIDE_LIFECYCLE_ON_RIDE_PHOTO; break; @@ -1279,14 +1434,18 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 case TRACK_ELEM_BLOCK_BRAKES: ride->num_block_brakes++; ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_OPERATING; + ride->mode = RIDE_MODE_CONTINUOUS_CIRCUIT_BLOCK_SECTIONED; if (ride->type == RIDE_TYPE_LIM_LAUNCHED_ROLLER_COASTER) ride->mode = RIDE_MODE_POWERED_LAUNCH_BLOCK_SECTIONED; + break; } - if (trackBlock->index == 0){ - switch (type){ + if (trackBlock->index == 0) + { + switch (type) + { case TRACK_ELEM_25_DEG_UP_TO_FLAT: case TRACK_ELEM_60_DEG_UP_TO_FLAT: case TRACK_ELEM_DIAG_25_DEG_UP_TO_FLAT: @@ -1301,42 +1460,49 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 } entranceDirections = 0; - if (ride->overall_view.xy != RCT_XY8_UNDEFINED){ - if (!(flags & GAME_COMMAND_FLAG_5)){ - if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) { + if (ride->overall_view.xy != RCT_XY8_UNDEFINED) + { + if (!(flags & GAME_COMMAND_FLAG_5)) + { + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) + { entranceDirections = FlatRideTrackSequenceProperties[type][0]; } - else { + else + { entranceDirections = TrackSequenceProperties[type][0]; } } } - if (entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN || ride->overall_view.xy == RCT_XY8_UNDEFINED){ + if (entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN || ride->overall_view.xy == RCT_XY8_UNDEFINED) + { ride->overall_view.x = x / 32; ride->overall_view.y = y / 32; } mapElement = map_element_insert(x / 32, y / 32, baseZ, bl & 0xF); - assert(mapElement != NULL); + assert(mapElement != nullptr); mapElement->clearance_height = clearanceZ; uint8 map_type = direction; map_type |= MAP_ELEMENT_TYPE_TRACK; - if (liftHillAndAlternativeState & CONSTRUCTION_LIFT_HILL_SELECTED){ + if (liftHillAndAlternativeState & CONSTRUCTION_LIFT_HILL_SELECTED) + { map_type |= (1 << 7); } mapElement->type = map_type; map_element_set_track_sequence(mapElement, trackBlock->index); mapElement->properties.track.ride_index = rideIndex; - mapElement->properties.track.type = type; - mapElement->properties.track.colour = 0; + mapElement->properties.track.type = type; + mapElement->properties.track.colour = 0; if (flags & GAME_COMMAND_FLAG_GHOST) { mapElement->flags |= MAP_ELEMENT_FLAG_GHOST; } - switch (type) { + switch (type) + { case TRACK_ELEM_WATERFALL: map_animation_create(MAP_ANIMATION_TYPE_TRACK_WATERFALL, x, y, mapElement->base_height); break; @@ -1365,34 +1531,41 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 } track_element_set_colour_scheme(mapElement, colour); - if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) { + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) + { entranceDirections = FlatRideTrackSequenceProperties[type][0]; } - else { + else + { entranceDirections = TrackSequenceProperties[type][0]; } - if (entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN) { - if (trackBlock->index == 0) { + if (entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN) + { + if (trackBlock->index == 0) + { track_add_station_element(x, y, baseZ, direction, rideIndex, GAME_COMMAND_FLAG_APPLY); } sub_6CB945(rideIndex); ride_update_max_vehicles(rideIndex); } - if (rideTypeFlags & RIDE_TYPE_FLAG_TRACK_MUST_BE_ON_WATER){ - rct_map_element* surfaceElement = map_get_surface_element_at(x / 32, y / 32); + if (rideTypeFlags & RIDE_TYPE_FLAG_TRACK_MUST_BE_ON_WATER) + { + rct_map_element * surfaceElement = map_get_surface_element_at(x / 32, y / 32); surfaceElement->type |= (1 << 6); mapElement = surfaceElement; } - if (!gCheatsDisableClearanceChecks || !(flags & GAME_COMMAND_FLAG_GHOST)) { + if (!gCheatsDisableClearanceChecks || !(flags & GAME_COMMAND_FLAG_GHOST)) + { footpath_connect_edges(x, y, mapElement, flags); } map_invalidate_tile_full(x, y); } - if (gGameCommandNestLevel == 1) { + if (gGameCommandNestLevel == 1) + { LocationXYZ16 coord; coord.x = originX + 16; coord.y = originY + 16; @@ -1408,10 +1581,12 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 price >>= 16; price = cost + ((price / 2) * 10); - if (gParkFlags & PARK_FLAGS_NO_MONEY) { + if (gParkFlags & PARK_FLAGS_NO_MONEY) + { return 0; } - else { + else + { return price; } } @@ -1420,50 +1595,66 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32 * * rct2: 0x006C511D */ -void game_command_place_track(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp) +void game_command_place_track(sint32 * eax, + sint32 * ebx, + sint32 * ecx, + sint32 * edx, + sint32 * esi, + sint32 * edi, + sint32 * ebp) { *ebx = track_place( *edx & 0xFF, (*edx >> 8) & 0xFF, - (sint16)(*eax & 0xFFFF), - (sint16)(*ecx & 0xFFFF), - (sint16)(*edi & 0xFFFF), + (sint16) (*eax & 0xFFFF), + (sint16) (*ecx & 0xFFFF), + (sint16) (*edi & 0xFFFF), (*ebx >> 8) & 0xFF, (*edi >> 16) & 0xFF, (*edi >> 24) & 0x0F, (*edi >> 28) & 0x0F, (*edx >> 16), *ebx & 0xFF - ); + ); } -static money32 track_remove(uint8 type, uint8 sequence, sint16 originX, sint16 originY, sint16 originZ, uint8 rotation, uint8 flags){ +static money32 track_remove(uint8 type, + uint8 sequence, + sint16 originX, + sint16 originY, + sint16 originZ, + uint8 rotation, + uint8 flags) +{ gCommandExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION; gCommandPosition.x = originX + 16; gCommandPosition.y = originY + 16; gCommandPosition.z = originZ; sint16 trackpieceZ = originZ; - switch (type){ + switch (type) + { case TRACK_ELEM_BEGIN_STATION: case TRACK_ELEM_MIDDLE_STATION: type = TRACK_ELEM_END_STATION; break; } - if (!(flags & (1 << 3)) && game_is_paused() && !gCheatsBuildInPauseMode){ + if (!(flags & (1 << 3)) && game_is_paused() && !gCheatsBuildInPauseMode) + { gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; return MONEY32_UNDEFINED; } uint8 found = 0; - rct_map_element* mapElement = map_get_first_element_at(originX / 32, originY / 32); - if (mapElement == NULL) + rct_map_element * mapElement = map_get_first_element_at(originX / 32, originY / 32); + if (mapElement == nullptr) { log_warning("Invalid coordinates for track removal. x = %d, y = %d", originX, originY); return MONEY32_UNDEFINED; } - do{ + do + { if (mapElement->base_height * 8 != originZ) continue; @@ -1479,7 +1670,8 @@ static money32 track_remove(uint8 type, uint8 sequence, sint16 originX, sint16 o // Probably should add a check for ghost here as well! uint8 track_type = mapElement->properties.track.type; - switch (track_type){ + switch (track_type) + { case TRACK_ELEM_BEGIN_STATION: case TRACK_ELEM_MIDDLE_STATION: track_type = TRACK_ELEM_END_STATION; @@ -1491,13 +1683,16 @@ static money32 track_remove(uint8 type, uint8 sequence, sint16 originX, sint16 o found = 1; break; - } while (!map_element_is_last_for_tile(mapElement++)); + } + while (!map_element_is_last_for_tile(mapElement++)); - if (!found){ + if (!found) + { return MONEY32_UNDEFINED; } - if (mapElement->flags & MAP_ELEMENT_FLAG_INDESTRUCTIBLE_TRACK_PIECE){ + if (mapElement->flags & MAP_ELEMENT_FLAG_INDESTRUCTIBLE_TRACK_PIECE) + { gGameCommandErrorText = STR_YOU_ARE_NOT_ALLOWED_TO_REMOVE_THIS_SECTION; return MONEY32_UNDEFINED; } @@ -1506,12 +1701,13 @@ static money32 track_remove(uint8 type, uint8 sequence, sint16 originX, sint16 o type = mapElement->properties.track.type; bool isLiftHill = track_element_is_lift_hill(mapElement); - Ride* ride = get_ride(rideIndex); - const rct_preview_track* trackBlock = get_track_def_from_ride(ride, type); + Ride * ride = get_ride(rideIndex); + const rct_preview_track * trackBlock = get_track_def_from_ride(ride, type); trackBlock += map_element_get_track_sequence(mapElement); uint8 originDirection = map_element_get_direction(mapElement); - switch (originDirection){ + switch (originDirection) + { case 0: originX -= trackBlock->x; originY -= trackBlock->y; @@ -1535,10 +1731,12 @@ static money32 track_remove(uint8 type, uint8 sequence, sint16 originX, sint16 o money32 cost = 0; trackBlock = get_track_def_from_ride(ride, type); - for (; trackBlock->index != 255; trackBlock++){ + for (; trackBlock->index != 255; trackBlock++) + { sint16 x = originX, y = originY, z = originZ; - switch (originDirection){ + switch (originDirection) + { case 0: x += trackBlock->x; y += trackBlock->y; @@ -1563,10 +1761,11 @@ static money32 track_remove(uint8 type, uint8 sequence, sint16 originX, sint16 o trackpieceZ = z; - found = 0; + found = 0; mapElement = map_get_first_element_at(x / 32, y / 32); - do{ - if (mapElement == NULL) + do + { + if (mapElement == nullptr) break; if (mapElement->base_height != z / 8) @@ -1586,34 +1785,42 @@ static money32 track_remove(uint8 type, uint8 sequence, sint16 originX, sint16 o found = 1; break; - } while (!map_element_is_last_for_tile(mapElement++)); + } + while (!map_element_is_last_for_tile(mapElement++)); - if (!found){ + if (!found) + { log_error("Track map element part not found!"); return MONEY32_UNDEFINED; } sint32 entranceDirections; - if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) { + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) + { entranceDirections = FlatRideTrackSequenceProperties[type][0]; } - else { + else + { entranceDirections = TrackSequenceProperties[type][0]; } - if (entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN && (map_element_get_track_sequence(mapElement) == 0)){ - if (!track_remove_station_element(x, y, z / 8, rotation, rideIndex, 0)) { + if (entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN && (map_element_get_track_sequence(mapElement) == 0)) + { + if (!track_remove_station_element(x, y, z / 8, rotation, rideIndex, 0)) + { return MONEY32_UNDEFINED; } } - rct_map_element* surfaceElement = map_get_surface_element_at(x / 32, y / 32); - if (surfaceElement == NULL){ + rct_map_element * surfaceElement = map_get_surface_element_at(x / 32, y / 32); + if (surfaceElement == nullptr) + { return MONEY32_UNDEFINED; } sint8 _support_height = mapElement->base_height - surfaceElement->base_height; - if (_support_height < 0){ + if (_support_height < 0) + { _support_height = 10; } @@ -1622,30 +1829,37 @@ static money32 track_remove(uint8 type, uint8 sequence, sint16 originX, sint16 o if (!(flags & GAME_COMMAND_FLAG_APPLY)) continue; - if (entranceDirections & (1 << 4) && (map_element_get_track_sequence(mapElement) == 0)){ - if (!track_remove_station_element(x, y, z / 8, rotation, rideIndex, GAME_COMMAND_FLAG_APPLY)) { + if (entranceDirections & (1 << 4) && (map_element_get_track_sequence(mapElement) == 0)) + { + if (!track_remove_station_element(x, y, z / 8, rotation, rideIndex, GAME_COMMAND_FLAG_APPLY)) + { return MONEY32_UNDEFINED; } } - if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_MUST_BE_ON_WATER)){ + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_TRACK_MUST_BE_ON_WATER)) + { surfaceElement->type &= ~(1 << 6); } invalidate_test_results(rideIndex); footpath_queue_chain_reset(); - if (!gCheatsDisableClearanceChecks || !(mapElement->flags & MAP_ELEMENT_FLAG_GHOST)) { + if (!gCheatsDisableClearanceChecks || !(mapElement->flags & MAP_ELEMENT_FLAG_GHOST)) + { footpath_remove_edges_at(x, y, mapElement); } map_element_remove(mapElement); - if (!(flags & GAME_COMMAND_FLAG_GHOST)){ + if (!(flags & GAME_COMMAND_FLAG_GHOST)) + { sub_6CB945(rideIndex); ride_update_max_vehicles(rideIndex); } } - if (flags & GAME_COMMAND_FLAG_APPLY){ - switch (type){ + if (flags & GAME_COMMAND_FLAG_APPLY) + { + switch (type) + { case TRACK_ELEM_ON_RIDE_PHOTO: ride->lifecycle_flags &= ~RIDE_LIFECYCLE_ON_RIDE_PHOTO; break; @@ -1654,17 +1868,20 @@ static money32 track_remove(uint8 type, uint8 sequence, sint16 originX, sint16 o break; case TRACK_ELEM_BLOCK_BRAKES: ride->num_block_brakes--; - if (ride->num_block_brakes == 0){ + if (ride->num_block_brakes == 0) + { ride->window_invalidate_flags |= RIDE_INVALIDATE_RIDE_OPERATING; ride->mode = RIDE_MODE_CONTINUOUS_CIRCUIT; - if (ride->type == RIDE_TYPE_LIM_LAUNCHED_ROLLER_COASTER){ + if (ride->type == RIDE_TYPE_LIM_LAUNCHED_ROLLER_COASTER) + { ride->mode = RIDE_MODE_POWERED_LAUNCH; } } break; } - switch (type){ + switch (type) + { case TRACK_ELEM_25_DEG_UP_TO_FLAT: case TRACK_ELEM_60_DEG_UP_TO_FLAT: case TRACK_ELEM_DIAG_25_DEG_UP_TO_FLAT: @@ -1679,20 +1896,23 @@ static money32 track_remove(uint8 type, uint8 sequence, sint16 originX, sint16 o } money32 price = RideTrackCosts[ride->type].track_price; - if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) { + if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_FLAT_RIDE)) + { price *= FlatRideTrackPricing[type]; } - else { + else + { price *= TrackPricing[type]; } price >>= 16; - price = (price + cost) / 2; + price = (price + cost) / 2; if (ride->lifecycle_flags & RIDE_LIFECYCLE_EVER_BEEN_OPENED) price *= -7; else price *= -10; - if (gGameCommandNestLevel == 1) { + if (gGameCommandNestLevel == 1) + { LocationXYZ16 coord; coord.x = originX + 16; coord.y = originY + 16; @@ -1710,7 +1930,13 @@ static money32 track_remove(uint8 type, uint8 sequence, sint16 originX, sint16 o * * rct2: 0x006C5B69 */ -void game_command_remove_track(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp) +void game_command_remove_track(sint32 * eax, + sint32 * ebx, + sint32 * ecx, + sint32 * edx, + sint32 * esi, + sint32 * edi, + sint32 * ebp) { *ebx = track_remove( *edx & 0xFF, @@ -1720,23 +1946,27 @@ void game_command_remove_track(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *ed *edi & 0xFFFF, (*ebx >> 8) & 0xFF, *ebx & 0xFF - ); + ); return; } -static uint8 maze_element_get_segment_bit(uint16 x, uint16 y) { +static uint8 maze_element_get_segment_bit(uint16 x, uint16 y) +{ uint8 minorX = x & 0x1F; // 0 or 16 uint8 minorY = y & 0x1F; // 0 or 16 - if (minorX == 0 && minorY == 0) { + if (minorX == 0 && minorY == 0) + { return 3; } - if (minorY == 16 && minorX == 16) { + if (minorY == 16 && minorX == 16) + { return 11; } - if (minorY == 0) { + if (minorY == 0) + { return 15; } @@ -1746,9 +1976,9 @@ static uint8 maze_element_get_segment_bit(uint16 x, uint16 y) { /** rct2: 0x00993CE9 */ static const uint8 byte_993CE9[] = { 0xFF, 0xE0, 0xFF, - 14, 0, 1, 2, - 6, 2, 4, 5, - 9, 10, 6, 8, + 14, 0, 1, 2, + 6, 2, 4, 5, + 9, 10, 6, 8, 12, 13, 14, 10, }; @@ -1762,7 +1992,8 @@ static const uint8 byte_993D0C[] = { 3, 0, 0xFF, 0xFF, 0, 1, 0xFF, 0xFF, 1, 2, 0xFF, 0xFF, 2, 3, 0xFF, 0xFF }; -static money32 set_maze_track(uint16 x, uint8 flags, uint8 direction, uint16 y, uint8 rideIndex, uint8 mode, uint16 z) { +static money32 set_maze_track(uint16 x, uint8 flags, uint8 direction, uint16 y, uint8 rideIndex, uint8 mode, uint16 z) +{ gCommandExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION; gCommandPosition.x = x + 8; gCommandPosition.y = y + 8; @@ -1770,77 +2001,93 @@ static money32 set_maze_track(uint16 x, uint8 flags, uint8 direction, uint16 y, money32 cost = 0; - if (!map_check_free_elements_and_reorganise(1)) { + if (!map_check_free_elements_and_reorganise(1)) + { return MONEY32_UNDEFINED; } - if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && !gCheatsBuildInPauseMode && game_is_paused()) { + if (!(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED) && !gCheatsBuildInPauseMode && game_is_paused()) + { gGameCommandErrorText = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; return MONEY32_UNDEFINED; } - if ((z & 0xF) != 0) { + if ((z & 0xF) != 0) + { gGameCommandErrorText = STR_CONSTRUCTION_ERR_UNKNOWN; return MONEY32_UNDEFINED; } - if ((flags & GAME_COMMAND_FLAG_APPLY) != 0) { - if (!(flags & GAME_COMMAND_FLAG_GHOST) && !(flags & GAME_COMMAND_FLAG_2)) { + if ((flags & GAME_COMMAND_FLAG_APPLY) != 0) + { + if (!(flags & GAME_COMMAND_FLAG_GHOST) && !(flags & GAME_COMMAND_FLAG_2)) + { footpath_remove_litter(x, y, z); wall_remove_at(floor2(x, 32), floor2(y, 32), z, z + 32); } } - if (!map_is_location_owned(floor2(x, 32), floor2(y, 32), z) && !gCheatsSandboxMode) { + if (!map_is_location_owned(floor2(x, 32), floor2(y, 32), z) && !gCheatsSandboxMode) + { return MONEY32_UNDEFINED; } - rct_map_element *mapElement = map_get_surface_element_at(x / 32, y / 32); - if (mapElement == NULL) { + rct_map_element * mapElement = map_get_surface_element_at(x / 32, y / 32); + if (mapElement == nullptr) + { return MONEY32_UNDEFINED; } - uint8 baseHeight = z >> 3; + uint8 baseHeight = z >> 3; uint8 clearanceHeight = (z + 32) >> 3; sint8 heightDifference = baseHeight - mapElement->base_height; - if (heightDifference >= 0 && !gCheatsDisableSupportLimits) { + if (heightDifference >= 0 && !gCheatsDisableSupportLimits) + { heightDifference = heightDifference >> 1; - if (heightDifference > RideData5[RIDE_TYPE_MAZE].max_height) { + if (heightDifference > RideData5[RIDE_TYPE_MAZE].max_height) + { gGameCommandErrorText = STR_TOO_HIGH_FOR_SUPPORTS; return MONEY32_UNDEFINED; } } mapElement = map_get_track_element_at_of_type_from_ride(x, y, baseHeight, TRACK_ELEM_MAZE, rideIndex); - if (mapElement == NULL) { - if (mode != GC_SET_MAZE_TRACK_BUILD) { + if (mapElement == nullptr) + { + if (mode != GC_SET_MAZE_TRACK_BUILD) + { gGameCommandErrorText = 0; return MONEY32_UNDEFINED; } - if (!map_can_construct_at(floor2(x, 32), floor2(y, 32), baseHeight, clearanceHeight, 0x0F)) { + if (!map_can_construct_at(floor2(x, 32), floor2(y, 32), baseHeight, clearanceHeight, 0x0F)) + { return MONEY32_UNDEFINED; } - if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) { + if (gMapGroundFlags & ELEMENT_IS_UNDERWATER) + { gGameCommandErrorText = STR_RIDE_CANT_BUILD_THIS_UNDERWATER; return MONEY32_UNDEFINED; } - if (gMapGroundFlags & ELEMENT_IS_UNDERGROUND) { + if (gMapGroundFlags & ELEMENT_IS_UNDERGROUND) + { gGameCommandErrorText = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; return MONEY32_UNDEFINED; } - Ride *ride = get_ride(rideIndex); + Ride * ride = get_ride(rideIndex); money32 price = (((RideTrackCosts[ride->type].track_price * TrackPricing[TRACK_ELEM_MAZE]) >> 16)); cost = price / 2 * 10; - if (!(flags & GAME_COMMAND_FLAG_APPLY)) { - if (gParkFlags & PARK_FLAGS_NO_MONEY) { + if (!(flags & GAME_COMMAND_FLAG_APPLY)) + { + if (gParkFlags & PARK_FLAGS_NO_MONEY) + { return 0; } @@ -1851,14 +2098,15 @@ static money32 set_maze_track(uint16 x, uint8 flags, uint8 direction, uint16 y, uint16 flooredY = floor2(y, 32); mapElement = map_element_insert(x / 32, y / 32, baseHeight, 0xF); - assert(mapElement != NULL); - mapElement->clearance_height = clearanceHeight; - mapElement->type = MAP_ELEMENT_TYPE_TRACK; - mapElement->properties.track.type = TRACK_ELEM_MAZE; + assert(mapElement != nullptr); + mapElement->clearance_height = clearanceHeight; + mapElement->type = MAP_ELEMENT_TYPE_TRACK; + mapElement->properties.track.type = TRACK_ELEM_MAZE; mapElement->properties.track.ride_index = rideIndex; mapElement->properties.track.maze_entry = 0xFFFF; - if (flags & GAME_COMMAND_FLAG_GHOST) { + if (flags & GAME_COMMAND_FLAG_GHOST) + { mapElement->flags |= MAP_ELEMENT_FLAG_GHOST; } @@ -1868,16 +2116,20 @@ static money32 set_maze_track(uint16 x, uint8 flags, uint8 direction, uint16 y, ride->station_heights[0] = mapElement->base_height; ride->station_starts[0].xy = 0; - if (direction == 4) { - if (!(flags & GAME_COMMAND_FLAG_GHOST)) { + if (direction == 4) + { + if (!(flags & GAME_COMMAND_FLAG_GHOST)) + { ride->overall_view.x = flooredX / 32; ride->overall_view.y = flooredY / 32; } } } - if (!(flags & GAME_COMMAND_FLAG_APPLY)) { - if (gParkFlags & PARK_FLAGS_NO_MONEY) { + if (!(flags & GAME_COMMAND_FLAG_APPLY)) + { + if (gParkFlags & PARK_FLAGS_NO_MONEY) + { return 0; } @@ -1885,26 +2137,37 @@ static money32 set_maze_track(uint16 x, uint8 flags, uint8 direction, uint16 y, } - switch (mode) { + switch (mode) + { case GC_SET_MAZE_TRACK_BUILD: { uint8 segmentOffset = maze_element_get_segment_bit(x, y); mapElement->properties.track.maze_entry &= ~(1 << segmentOffset); - if (direction != 4) { + if (direction != 4) + { segmentOffset = byte_993CE9[(direction + segmentOffset)]; mapElement->properties.track.maze_entry &= ~(1 << segmentOffset); uint8 temp_edx = byte_993CFC[segmentOffset]; - if (temp_edx != 0xFF) { + if (temp_edx != 0xFF) + { uint16 previousElementX = floor2(x, 32) - TileDirectionDelta[direction].x; uint16 previousElementY = floor2(y, 32) - TileDirectionDelta[direction].y; - rct_map_element *previousMapElement = map_get_track_element_at_of_type_from_ride(previousElementX, previousElementY, baseHeight, TRACK_ELEM_MAZE, rideIndex); - if (previousMapElement != NULL) { + rct_map_element * previousMapElement = map_get_track_element_at_of_type_from_ride( + previousElementX, + previousElementY, + baseHeight, + TRACK_ELEM_MAZE, + rideIndex); + if (previousMapElement != nullptr) + { previousMapElement->properties.track.maze_entry &= ~(1 << temp_edx); - } else { + } + else + { mapElement->properties.track.maze_entry |= (1 << segmentOffset); } } @@ -1917,13 +2180,20 @@ static money32 set_maze_track(uint16 x, uint8 flags, uint8 direction, uint16 y, break; case GC_SET_MAZE_TRACK_FILL: - if (direction != 4) { + if (direction != 4) + { uint16 previousSegmentX = x - TileDirectionDelta[direction].x / 2; uint16 previousSegmentY = y - TileDirectionDelta[direction].y / 2; - mapElement = map_get_track_element_at_of_type_from_ride(previousSegmentX, previousSegmentY, baseHeight, TRACK_ELEM_MAZE, rideIndex); + mapElement = map_get_track_element_at_of_type_from_ride( + previousSegmentX, + previousSegmentY, + baseHeight, + TRACK_ELEM_MAZE, + rideIndex); map_invalidate_tile_full(floor2(previousSegmentX, 32), floor2(previousSegmentY, 32)); - if (mapElement == NULL) { + if (mapElement == nullptr) + { log_error("No surface found"); return MONEY32_UNDEFINED; } @@ -1937,34 +2207,44 @@ static money32 set_maze_track(uint16 x, uint8 flags, uint8 direction, uint16 y, mapElement->properties.track.maze_entry |= (1 << segmentBit); segmentBit = (segmentBit + 3) & 0x0F; - do { + do + { mapElement->properties.track.maze_entry |= (1 << segmentBit); - uint32 direction1 = byte_993D0C[segmentBit]; + uint32 direction1 = byte_993D0C[segmentBit]; uint16 nextElementX = floor2(previousSegmentX, 32) + TileDirectionDelta[direction1].x; uint16 nextElementY = floor2(previousSegmentY, 32) + TileDirectionDelta[direction1].y; - rct_map_element *tmp_mapElement = map_get_track_element_at_of_type_from_ride(nextElementX, nextElementY, baseHeight, TRACK_ELEM_MAZE, rideIndex); - if (tmp_mapElement != NULL) { + rct_map_element * tmp_mapElement = map_get_track_element_at_of_type_from_ride( + nextElementX, + nextElementY, + baseHeight, + TRACK_ELEM_MAZE, + rideIndex); + if (tmp_mapElement != nullptr) + { uint8 edx11 = byte_993CFC[segmentBit]; tmp_mapElement->properties.track.maze_entry |= 1 << (edx11); } segmentBit--; - } while ((segmentBit & 0x3) != 0x3); + } + while ((segmentBit & 0x3) != 0x3); } break; } map_invalidate_tile(floor2(x, 32), floor2(y, 32), mapElement->base_height * 8, mapElement->clearance_height * 8); - if ((mapElement->properties.track.maze_entry & 0x8888) == 0x8888) { + if ((mapElement->properties.track.maze_entry & 0x8888) == 0x8888) + { map_element_remove(mapElement); sub_6CB945(rideIndex); get_ride(rideIndex)->maze_tiles--; } - if (gParkFlags & PARK_FLAGS_NO_MONEY) { + if (gParkFlags & PARK_FLAGS_NO_MONEY) + { return 0; } @@ -1975,15 +2255,21 @@ static money32 set_maze_track(uint16 x, uint8 flags, uint8 direction, uint16 y, * * rct2: 0x006CD8CE */ -void game_command_set_maze_track(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp) +void game_command_set_maze_track(sint32 * eax, + sint32 * ebx, + sint32 * ecx, + sint32 * edx, + sint32 * esi, + sint32 * edi, + sint32 * ebp) { - uint16 x = (*eax & 0xFFFF); // AX - uint8 flags = (*ebx & 0xFF); // BL - uint8 direction = ((*ebx & 0xFF00) >> 8); // BH - uint16 y = (*ecx & 0xFFFF); // CX - uint8 rideIndex = (*edx & 0xFF); // DL - uint8 mode = ((*edx & 0xFF00) >> 8); // DH - uint16 z = (*edi & 0xFFFF); // DI + uint16 x = (*eax & 0xFFFF); // AX + uint8 flags = (*ebx & 0xFF); // BL + uint8 direction = ((*ebx & 0xFF00) >> 8); // BH + uint16 y = (*ecx & 0xFFFF); // CX + uint8 rideIndex = (*edx & 0xFF); // DL + uint8 mode = ((*edx & 0xFF00) >> 8); // DH + uint16 z = (*edi & 0xFFFF); // DI *ebx = set_maze_track(x, flags, direction, y, rideIndex, mode, z); } @@ -1992,35 +2278,40 @@ void game_command_set_maze_track(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 * * * rct2: 0x006C5AE9 */ -void game_command_set_brakes_speed(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp) +void game_command_set_brakes_speed(sint32 * eax, + sint32 * ebx, + sint32 * ecx, + sint32 * edx, + sint32 * esi, + sint32 * edi, + sint32 * ebp) { - rct_map_element *mapElement; - sint32 x, y, z, trackType, brakesSpeed; - - x = (*eax & 0xFFFF); - y = (*ecx & 0xFFFF); - z = (*edi & 0xFFFF); - trackType = (*edx & 0xFF); - brakesSpeed = ((*ebx >> 8) & 0xFF); + sint32 x = (*eax & 0xFFFF); + sint32 y = (*ecx & 0xFFFF); + sint32 z = (*edi & 0xFFFF); + sint32 trackType = (*edx & 0xFF); + sint32 brakesSpeed = ((*ebx >> 8) & 0xFF); gCommandExpenditureType = RCT_EXPENDITURE_TYPE_RIDE_CONSTRUCTION; gCommandPosition.x = x + 16; gCommandPosition.y = y + 16; gCommandPosition.z = z; - if (*ebx & GAME_COMMAND_FLAG_APPLY) { + if (*ebx & GAME_COMMAND_FLAG_APPLY) + { *ebx = 0; return; } - mapElement = map_get_first_element_at(x >> 5, y >> 5); - if (mapElement == NULL) + rct_map_element * mapElement = map_get_first_element_at(x >> 5, y >> 5); + if (mapElement == nullptr) { log_warning("Invalid game command for setting brakes speed. x = %d, y = %d", x, y); *ebx = MONEY32_UNDEFINED; return; } - do { + do + { if (mapElement->base_height * 8 != z) continue; if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK) @@ -2031,112 +2322,130 @@ void game_command_set_brakes_speed(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 map_element_set_brake_booster_speed(mapElement, brakesSpeed); break; - } while (!map_element_is_last_for_tile(mapElement++)); + } + while (!map_element_is_last_for_tile(mapElement++)); *ebx = 0; } -void track_circuit_iterator_begin(track_circuit_iterator *it, rct_xy_element first) +void track_circuit_iterator_begin(track_circuit_iterator * it, rct_xy_element first) { - it->last = first; - it->first = NULL; + it->last = first; + it->first = nullptr; it->firstIteration = true; - it->looped = false; + it->looped = false; } -bool track_circuit_iterator_previous(track_circuit_iterator *it) +bool track_circuit_iterator_previous(track_circuit_iterator * it) { track_begin_end trackBeginEnd; - if (it->first == NULL) { + if (it->first == nullptr) + { if (!track_block_get_previous(it->last.x, it->last.y, it->last.element, &trackBeginEnd)) return false; - it->current.x = trackBeginEnd.begin_x; - it->current.y = trackBeginEnd.begin_y; - it->current.element = trackBeginEnd.begin_element; - it->currentZ = trackBeginEnd.begin_z; + it->current.x = trackBeginEnd.begin_x; + it->current.y = trackBeginEnd.begin_y; + it->current.element = trackBeginEnd.begin_element; + it->currentZ = trackBeginEnd.begin_z; it->currentDirection = trackBeginEnd.begin_direction; it->first = it->current.element; return true; - } else { - if (!it->firstIteration && it->first == it->current.element) { + } + else + { + if (!it->firstIteration && it->first == it->current.element) + { it->looped = true; return false; } it->firstIteration = false; - it->last = it->current; + it->last = it->current; - if (track_block_get_previous(it->last.x, it->last.y, it->last.element, &trackBeginEnd)) { - it->current.x = trackBeginEnd.end_x; - it->current.y = trackBeginEnd.end_y; - it->current.element = trackBeginEnd.begin_element; - it->currentZ = trackBeginEnd.begin_z; + if (track_block_get_previous(it->last.x, it->last.y, it->last.element, &trackBeginEnd)) + { + it->current.x = trackBeginEnd.end_x; + it->current.y = trackBeginEnd.end_y; + it->current.element = trackBeginEnd.begin_element; + it->currentZ = trackBeginEnd.begin_z; it->currentDirection = trackBeginEnd.begin_direction; return true; - } else { + } + else + { return false; } } } -bool track_circuit_iterator_next(track_circuit_iterator *it) +bool track_circuit_iterator_next(track_circuit_iterator * it) { - if (it->first == NULL) { + if (it->first == nullptr) + { if (!track_block_get_next(&it->last, &it->current, &it->currentZ, &it->currentDirection)) return false; it->first = it->current.element; return true; - } else { - if (!it->firstIteration && it->first == it->current.element) { + } + else + { + if (!it->firstIteration && it->first == it->current.element) + { it->looped = true; return false; } it->firstIteration = false; - it->last = it->current; + it->last = it->current; return track_block_get_next(&it->last, &it->current, &it->currentZ, &it->currentDirection); } } -void track_get_back(rct_xy_element *input, rct_xy_element *output) +void track_get_back(rct_xy_element * input, rct_xy_element * output) { - rct_xy_element lastTrack; + rct_xy_element lastTrack; track_begin_end currentTrack; - bool result; + bool result; lastTrack = *input; - do { + do + { result = track_block_get_previous(lastTrack.x, lastTrack.y, lastTrack.element, ¤tTrack); - if (result) { - lastTrack.x = currentTrack.begin_x; - lastTrack.y = currentTrack.begin_y; + if (result) + { + lastTrack.x = currentTrack.begin_x; + lastTrack.y = currentTrack.begin_y; lastTrack.element = currentTrack.begin_element; } - } while (result); + } + while (result); *output = lastTrack; } -void track_get_front(rct_xy_element *input, rct_xy_element *output) +void track_get_front(rct_xy_element * input, rct_xy_element * output) { rct_xy_element lastTrack, currentTrack; - sint32 z, direction; - bool result; + sint32 z, direction; + bool result; lastTrack = *input; - do { + do + { result = track_block_get_next(&lastTrack, ¤tTrack, &z, &direction); - if (result) { + if (result) + { lastTrack = currentTrack; } - } while (result); + } + while (result); *output = lastTrack; } -bool track_element_is_lift_hill(rct_map_element *trackElement) +bool track_element_is_lift_hill(rct_map_element * trackElement) { return trackElement->type & TRACK_ELEMENT_FLAG_CHAIN_LIFT; } @@ -2146,9 +2455,10 @@ bool track_element_is_lift_hill(rct_map_element *trackElement) * A beginning of a block can be the end of a station, the end of a lift hill, * or a block brake. */ -bool track_element_is_block_start(rct_map_element *trackElement) +bool track_element_is_block_start(rct_map_element * trackElement) { - switch (trackElement->properties.track.type) { + switch (trackElement->properties.track.type) + { case TRACK_ELEM_END_STATION: case TRACK_ELEM_CABLE_LIFT_HILL: case TRACK_ELEM_BLOCK_BRAKES: @@ -2157,7 +2467,8 @@ bool track_element_is_block_start(rct_map_element *trackElement) case TRACK_ELEM_60_DEG_UP_TO_FLAT: case TRACK_ELEM_DIAG_25_DEG_UP_TO_FLAT: case TRACK_ELEM_DIAG_60_DEG_UP_TO_FLAT: - if (track_element_is_lift_hill(trackElement)) { + if (track_element_is_lift_hill(trackElement)) + { return true; } break; @@ -2165,15 +2476,18 @@ bool track_element_is_block_start(rct_map_element *trackElement) return false; } -bool track_element_is_cable_lift(rct_map_element *trackElement) { +bool track_element_is_cable_lift(rct_map_element * trackElement) +{ return trackElement->properties.track.colour & TRACK_ELEMENT_COLOUR_FLAG_CABLE_LIFT; } -void track_element_set_cable_lift(rct_map_element *trackElement) { +void track_element_set_cable_lift(rct_map_element * trackElement) +{ trackElement->properties.track.colour |= TRACK_ELEMENT_COLOUR_FLAG_CABLE_LIFT; } -void track_element_clear_cable_lift(rct_map_element *trackElement) { +void track_element_clear_cable_lift(rct_map_element * trackElement) +{ trackElement->properties.track.colour &= ~TRACK_ELEMENT_COLOUR_FLAG_CABLE_LIFT; } @@ -2194,20 +2508,25 @@ void track_element_set_inverted(rct_map_element * mapElement, bool inverted) } } -sint32 track_get_actual_bank(rct_map_element *mapElement, sint32 bank) +sint32 track_get_actual_bank(rct_map_element * mapElement, sint32 bank) { - Ride *ride = get_ride(mapElement->properties.track.ride_index); + Ride * ride = get_ride(mapElement->properties.track.ride_index); sint32 trackColour = mapElement->properties.track.colour; return track_get_actual_bank_2(ride->type, trackColour, bank); } sint32 track_get_actual_bank_2(sint32 rideType, sint32 trackColour, sint32 bank) { - if (RideData4[rideType].flags & RIDE_TYPE_FLAG4_HAS_ALTERNATIVE_TRACK_TYPE) { - if (trackColour & TRACK_ELEMENT_COLOUR_FLAG_INVERTED) { - if (bank == TRACK_BANK_NONE) { + if (RideData4[rideType].flags & RIDE_TYPE_FLAG4_HAS_ALTERNATIVE_TRACK_TYPE) + { + if (trackColour & TRACK_ELEMENT_COLOUR_FLAG_INVERTED) + { + if (bank == TRACK_BANK_NONE) + { bank = TRACK_BANK_UPSIDE_DOWN; - } else if (bank == TRACK_BANK_UPSIDE_DOWN) { + } + else if (bank == TRACK_BANK_UPSIDE_DOWN) + { bank = TRACK_BANK_NONE; } } @@ -2215,19 +2534,20 @@ sint32 track_get_actual_bank_2(sint32 rideType, sint32 trackColour, sint32 bank) return bank; } -sint32 track_get_actual_bank_3(rct_vehicle *vehicle, rct_map_element *mapElement) +sint32 track_get_actual_bank_3(rct_vehicle * vehicle, rct_map_element * mapElement) { - uint8 colourThingToXor = (vehicle->update_flags >> 9) & 0xFF; - sint32 trackType = mapElement->properties.track.type; - sint32 rideType = get_ride(mapElement->properties.track.ride_index)->type; - sint32 trackColour = mapElement->properties.track.colour ^ colourThingToXor; - sint32 bankStart = TrackDefinitions[trackType].bank_start; + uint8 colourThingToXor = (vehicle->update_flags >> 9) & 0xFF; + sint32 trackType = mapElement->properties.track.type; + sint32 rideType = get_ride(mapElement->properties.track.ride_index)->type; + sint32 trackColour = mapElement->properties.track.colour ^ colourThingToXor; + sint32 bankStart = TrackDefinitions[trackType].bank_start; return track_get_actual_bank_2(rideType, trackColour, bankStart); } -bool track_element_is_station(rct_map_element *trackElement) +bool track_element_is_station(rct_map_element * trackElement) { - switch (trackElement->properties.track.type) { + switch (trackElement->properties.track.type) + { case TRACK_ELEM_END_STATION: case TRACK_ELEM_BEGIN_STATION: case TRACK_ELEM_MIDDLE_STATION: @@ -2239,7 +2559,8 @@ bool track_element_is_station(rct_map_element *trackElement) bool track_element_is_covered(sint32 trackElementType) { - switch (trackElementType) { + switch (trackElementType) + { case TRACK_ELEM_FLAT_COVERED: case TRACK_ELEM_25_DEG_UP_COVERED: case TRACK_ELEM_60_DEG_UP_COVERED: diff --git a/src/openrct2/ride/Track.h b/src/openrct2/ride/Track.h index f5aead25de..80879036b7 100644 --- a/src/openrct2/ride/Track.h +++ b/src/openrct2/ride/Track.h @@ -14,15 +14,15 @@ *****************************************************************************/ #pragma endregion -#ifndef _TRACK_H_ -#define _TRACK_H_ +#pragma once #include "../common.h" #include "../object.h" #include "ride.h" #pragma pack(push, 1) -typedef struct rct_trackdefinition { +typedef struct rct_trackdefinition +{ uint8 type; uint8 vangle_end; uint8 vangle_start; @@ -37,41 +37,45 @@ assert_struct_size(rct_trackdefinition, 8); /** * Size: 0x0A */ -typedef struct rct_preview_track { - uint8 index; // 0x00 +typedef struct rct_preview_track +{ + uint8 index; // 0x00 sint16 x; // 0x01 sint16 y; // 0x03 sint16 z; // 0x05 - uint8 var_07; - uint8 var_08; - uint8 var_09; + uint8 var_07; + uint8 var_08; + uint8 var_09; } rct_preview_track; /* size 0x0A */ -typedef struct rct_track_coordinates { - sint8 rotation_begin; // 0x00 - sint8 rotation_end; // 0x01 +typedef struct rct_track_coordinates +{ + sint8 rotation_begin; // 0x00 + sint8 rotation_end; // 0x01 sint16 z_begin; // 0x02 sint16 z_end; // 0x04 sint16 x; // 0x06 sint16 y; // 0x08 } rct_track_coordinates; -enum { +enum +{ TRACK_ELEMENT_FLAG_TERMINAL_STATION = 1 << 3, TRACK_ELEMENT_FLAG_INVERTED = 1 << 6, TRACK_ELEMENT_FLAG_CHAIN_LIFT = 1 << 7, }; -enum { +enum +{ // Not anything to do with colour but uses // that field in the map element // Used for multi-dimension coaster - TRACK_ELEMENT_COLOUR_FLAG_INVERTED = (1 << 2), + TRACK_ELEMENT_COLOUR_FLAG_INVERTED = (1 << 2), // Used for giga coaster - TRACK_ELEMENT_COLOUR_FLAG_CABLE_LIFT = (1 << 3), + TRACK_ELEMENT_COLOUR_FLAG_CABLE_LIFT = (1 << 3), }; #define TRACK_ELEMENT_FLAG_MAGNITUDE_MASK 0x0F @@ -80,10 +84,11 @@ enum { #define MAX_STATION_PLATFORM_LENGTH 32 -enum { +enum +{ TRACK_NONE = 0, - TRACK_FLAT = 0, + TRACK_FLAT = 0, TRACK_STRAIGHT, TRACK_STATION_END, TRACK_LIFT_HILL, @@ -140,75 +145,81 @@ enum { TRACK_HALF_LOOP_INVERTED, TRACK_BOOSTER = TRACK_ROTATION_CONTROL_TOGGLE, - TRACK_WATERFALL = 152, - TRACK_WHIRLPOOL = 152, + TRACK_WATERFALL = 152, + TRACK_WHIRLPOOL = 152, TRACK_BRAKE_FOR_DROP = 172, - TRACK_190 = 190, - TRACK_192 = 192, - TRACK_194 = 194, + TRACK_190 = 190, + TRACK_192 = 192, + TRACK_194 = 194, TRACK_MINI_GOLF_HOLE = 195, }; -enum { - TRACK_CURVE_LEFT_VERY_SMALL = 5, - TRACK_CURVE_LEFT_SMALL = 3, - TRACK_CURVE_LEFT = 1, - TRACK_CURVE_LEFT_LARGE = 7, - TRACK_CURVE_NONE = 0, - TRACK_CURVE_RIGHT_LARGE = 8, - TRACK_CURVE_RIGHT = 2, - TRACK_CURVE_RIGHT_SMALL = 4, +enum +{ + TRACK_CURVE_LEFT_VERY_SMALL = 5, + TRACK_CURVE_LEFT_SMALL = 3, + TRACK_CURVE_LEFT = 1, + TRACK_CURVE_LEFT_LARGE = 7, + TRACK_CURVE_NONE = 0, + TRACK_CURVE_RIGHT_LARGE = 8, + TRACK_CURVE_RIGHT = 2, + TRACK_CURVE_RIGHT_SMALL = 4, TRACK_CURVE_RIGHT_VERY_SMALL = 6 }; -enum { - TRACK_SLOPE_NONE = 0, - TRACK_SLOPE_UP_25 = 2, - TRACK_SLOPE_UP_60 = 4, +enum +{ + TRACK_SLOPE_NONE = 0, + TRACK_SLOPE_UP_25 = 2, + TRACK_SLOPE_UP_60 = 4, TRACK_SLOPE_DOWN_25 = 6, TRACK_SLOPE_DOWN_60 = 8, - TRACK_SLOPE_UP_90 = 10, + TRACK_SLOPE_UP_90 = 10, TRACK_SLOPE_DOWN_90 = 18, - TRACK_VANGLE_TOWER = 10, + TRACK_VANGLE_TOWER = 10, TRACK_VANGLE_REVERSE_FREEFALL = 10 }; -enum { - TRACK_BANK_NONE = 0, - TRACK_BANK_LEFT = 2, - TRACK_BANK_RIGHT = 4, +enum +{ + TRACK_BANK_NONE = 0, + TRACK_BANK_LEFT = 2, + TRACK_BANK_RIGHT = 4, TRACK_BANK_UPSIDE_DOWN = 15, }; -enum { - TRACK_HALF_LOOP_UP = 64, - TRACK_HALF_LOOP_DOWN = -64, +enum +{ + TRACK_HALF_LOOP_UP = 64, + TRACK_HALF_LOOP_DOWN = -64, TRACK_UNKNOWN_VERTICAL_LOOP = -48, - TRACK_216 = -40, - TRACK_CORKSCREW_DOWN = -32 + TRACK_216 = -40, + TRACK_CORKSCREW_DOWN = -32 }; -enum { - TRACK_ELEM_FLAG_ONLY_UNDERWATER = (1 << 0), - TRACK_ELEM_FLAG_TURN_LEFT = (1 << 1), - TRACK_ELEM_FLAG_TURN_RIGHT = (1 << 2), - TRACK_ELEM_FLAG_TURN_BANKED = (1 << 3), - TRACK_ELEM_FLAG_TURN_SLOPED = (1 << 4), - TRACK_ELEM_FLAG_DOWN = (1 << 5), - TRACK_ELEM_FLAG_UP = (1 << 6), - TRACK_ELEM_FLAG_NORMAL_TO_INVERSION = (1 << 7), +enum +{ + TRACK_ELEM_FLAG_ONLY_UNDERWATER = (1 << 0), + TRACK_ELEM_FLAG_TURN_LEFT = (1 << 1), + TRACK_ELEM_FLAG_TURN_RIGHT = (1 << 2), + TRACK_ELEM_FLAG_TURN_BANKED = (1 << 3), + TRACK_ELEM_FLAG_TURN_SLOPED = (1 << 4), + TRACK_ELEM_FLAG_DOWN = (1 << 5), + TRACK_ELEM_FLAG_UP = (1 << 6), + TRACK_ELEM_FLAG_NORMAL_TO_INVERSION = (1 << 7), TRACK_ELEM_FLAG_STARTS_AT_HALF_HEIGHT = (1 << 8), - TRACK_ELEM_FLAG_ONLY_ABOVE_GROUND = (1 << 9), - TRACK_ELEM_FLAG_IS_STEEP_UP = (1 << 10), // Used to allow steep backwards lifts on roller coasters that do not allow steep forward lift hills - TRACK_ELEM_FLAG_HELIX = (1 << 11), - TRACK_ELEM_FLAG_ALLOW_LIFT_HILL = (1 << 12), - TRACK_ELEM_FLAG_CURVE_ALLOWS_LIFT = (1 << 13), - TRACK_ELEM_FLAG_INVERSION_TO_NORMAL = (1 << 14), - TRACK_ELEM_FLAG_BANKED = (1 << 15), // Also set on Spinning Tunnel and Log Flume reverser, probably to save a flag. + TRACK_ELEM_FLAG_ONLY_ABOVE_GROUND = (1 << 9), + TRACK_ELEM_FLAG_IS_STEEP_UP = (1 << 10), // Used to allow steep backwards lifts on roller coasters that do not allow steep forward lift hills + TRACK_ELEM_FLAG_HELIX = (1 << 11), + TRACK_ELEM_FLAG_ALLOW_LIFT_HILL = (1 << 12), + TRACK_ELEM_FLAG_CURVE_ALLOWS_LIFT = (1 << 13), + TRACK_ELEM_FLAG_INVERSION_TO_NORMAL = (1 << 14), + TRACK_ELEM_FLAG_BANKED = (1 << 15), // Also set on Spinning Tunnel and Log Flume reverser, probably to save a flag. }; -enum { +enum +{ TRACK_ELEM_FLAT, TRACK_ELEM_END_STATION, TRACK_ELEM_BEGIN_STATION, @@ -219,7 +230,7 @@ enum { TRACK_ELEM_25_DEG_UP_TO_60_DEG_UP, TRACK_ELEM_60_DEG_UP_TO_25_DEG_UP, TRACK_ELEM_25_DEG_UP_TO_FLAT, - TRACK_ELEM_25_DEG_DOWN = 10, + TRACK_ELEM_25_DEG_DOWN = 10, TRACK_ELEM_60_DEG_DOWN, TRACK_ELEM_FLAT_TO_25_DEG_DOWN, TRACK_ELEM_25_DEG_DOWN_TO_60_DEG_DOWN, @@ -229,7 +240,7 @@ enum { TRACK_ELEM_RIGHT_QUARTER_TURN_5_TILES, TRACK_ELEM_FLAT_TO_LEFT_BANK, TRACK_ELEM_FLAT_TO_RIGHT_BANK, - TRACK_ELEM_LEFT_BANK_TO_FLAT = 20, + TRACK_ELEM_LEFT_BANK_TO_FLAT = 20, TRACK_ELEM_RIGHT_BANK_TO_FLAT, TRACK_ELEM_BANKED_LEFT_QUARTER_TURN_5_TILES, TRACK_ELEM_BANKED_RIGHT_QUARTER_TURN_5_TILES, @@ -239,7 +250,7 @@ enum { TRACK_ELEM_25_DEG_UP_TO_RIGHT_BANK, TRACK_ELEM_LEFT_BANK_TO_25_DEG_DOWN, TRACK_ELEM_RIGHT_BANK_TO_25_DEG_DOWN, - TRACK_ELEM_25_DEG_DOWN_TO_LEFT_BANK = 30, + TRACK_ELEM_25_DEG_DOWN_TO_LEFT_BANK = 30, TRACK_ELEM_25_DEG_DOWN_TO_RIGHT_BANK, TRACK_ELEM_LEFT_BANK, TRACK_ELEM_RIGHT_BANK, @@ -249,7 +260,7 @@ enum { TRACK_ELEM_RIGHT_QUARTER_TURN_5_TILES_25_DEG_DOWN, TRACK_ELEM_S_BEND_LEFT, TRACK_ELEM_S_BEND_RIGHT, - TRACK_ELEM_LEFT_VERTICAL_LOOP = 40, + TRACK_ELEM_LEFT_VERTICAL_LOOP = 40, TRACK_ELEM_RIGHT_VERTICAL_LOOP, TRACK_ELEM_LEFT_QUARTER_TURN_3_TILES, TRACK_ELEM_RIGHT_QUARTER_TURN_3_TILES, @@ -259,7 +270,7 @@ enum { TRACK_ELEM_RIGHT_QUARTER_TURN_3_TILES_25_DEG_UP, TRACK_ELEM_LEFT_QUARTER_TURN_3_TILES_25_DEG_DOWN, TRACK_ELEM_RIGHT_QUARTER_TURN_3_TILES_25_DEG_DOWN, - TRACK_ELEM_LEFT_QUARTER_TURN_1_TILE = 50, + TRACK_ELEM_LEFT_QUARTER_TURN_1_TILE = 50, TRACK_ELEM_RIGHT_QUARTER_TURN_1_TILE, TRACK_ELEM_LEFT_TWIST_DOWN_TO_UP, TRACK_ELEM_RIGHT_TWIST_DOWN_TO_UP, @@ -269,7 +280,7 @@ enum { TRACK_ELEM_HALF_LOOP_DOWN, TRACK_ELEM_LEFT_CORKSCREW_UP, TRACK_ELEM_RIGHT_CORKSCREW_UP, - TRACK_ELEM_LEFT_CORKSCREW_DOWN = 60, + TRACK_ELEM_LEFT_CORKSCREW_DOWN = 60, TRACK_ELEM_RIGHT_CORKSCREW_DOWN, TRACK_ELEM_FLAT_TO_60_DEG_UP, TRACK_ELEM_60_DEG_UP_TO_FLAT, @@ -279,7 +290,7 @@ enum { TRACK_ELEM_TOWER_SECTION, TRACK_ELEM_FLAT_COVERED, TRACK_ELEM_25_DEG_UP_COVERED, - TRACK_ELEM_60_DEG_UP_COVERED = 70, + TRACK_ELEM_60_DEG_UP_COVERED = 70, TRACK_ELEM_FLAT_TO_25_DEG_UP_COVERED, TRACK_ELEM_25_DEG_UP_TO_60_DEG_UP_COVERED, TRACK_ELEM_60_DEG_UP_TO_25_DEG_UP_COVERED, @@ -289,7 +300,7 @@ enum { TRACK_ELEM_FLAT_TO_25_DEG_DOWN_COVERED, TRACK_ELEM_25_DEG_DOWN_TO_60_DEG_DOWN_COVERED, TRACK_ELEM_60_DEG_DOWN_TO_25_DEG_DOWN_COVERED, - TRACK_ELEM_25_DEG_DOWN_TO_FLAT_COVERED = 80, + TRACK_ELEM_25_DEG_DOWN_TO_FLAT_COVERED = 80, TRACK_ELEM_LEFT_QUARTER_TURN_5_TILES_COVERED, TRACK_ELEM_RIGHT_QUARTER_TURN_5_TILES_COVERED, TRACK_ELEM_S_BEND_LEFT_COVERED, @@ -299,7 +310,7 @@ enum { TRACK_ELEM_LEFT_HALF_BANKED_HELIX_UP_SMALL, TRACK_ELEM_RIGHT_HALF_BANKED_HELIX_UP_SMALL, TRACK_ELEM_LEFT_HALF_BANKED_HELIX_DOWN_SMALL, - TRACK_ELEM_RIGHT_HALF_BANKED_HELIX_DOWN_SMALL = 90, + TRACK_ELEM_RIGHT_HALF_BANKED_HELIX_DOWN_SMALL = 90, TRACK_ELEM_LEFT_HALF_BANKED_HELIX_UP_LARGE, TRACK_ELEM_RIGHT_HALF_BANKED_HELIX_UP_LARGE, TRACK_ELEM_LEFT_HALF_BANKED_HELIX_DOWN_LARGE, @@ -309,11 +320,11 @@ enum { TRACK_ELEM_LEFT_QUARTER_TURN_1_TILE_60_DEG_DOWN, TRACK_ELEM_RIGHT_QUARTER_TURN_1_TILE_60_DEG_DOWN, TRACK_ELEM_BRAKES, - TRACK_ELEM_ROTATION_CONTROL_TOGGLE = 100, - TRACK_ELEM_BOOSTER = 100, - TRACK_ELEM_INVERTED_90_DEG_UP_TO_FLAT_QUARTER_LOOP = 101, - TRACK_ELEM_MAZE = 101, - TRACK_ELEM_255_ALIAS = 101, // Used by the multi-dimension coaster, as TD6 cannot handle index 255. + TRACK_ELEM_ROTATION_CONTROL_TOGGLE = 100, + TRACK_ELEM_BOOSTER = 100, + TRACK_ELEM_INVERTED_90_DEG_UP_TO_FLAT_QUARTER_LOOP = 101, + TRACK_ELEM_MAZE = 101, + TRACK_ELEM_255_ALIAS = 101, // Used by the multi-dimension coaster, as TD6 cannot handle index 255. TRACK_ELEM_LEFT_QUARTER_BANKED_HELIX_LARGE_UP, TRACK_ELEM_RIGHT_QUARTER_BANKED_HELIX_LARGE_UP, TRACK_ELEM_LEFT_QUARTER_BANKED_HELIX_LARGE_DOWN, @@ -322,7 +333,7 @@ enum { TRACK_ELEM_RIGHT_QUARTER_HELIX_LARGE_UP, TRACK_ELEM_LEFT_QUARTER_HELIX_LARGE_DOWN, TRACK_ELEM_RIGHT_QUARTER_HELIX_LARGE_DOWN, - TRACK_ELEM_25_DEG_UP_LEFT_BANKED = 110, + TRACK_ELEM_25_DEG_UP_LEFT_BANKED = 110, TRACK_ELEM_25_DEG_UP_RIGHT_BANKED, TRACK_ELEM_WATERFALL, TRACK_ELEM_RAPIDS, @@ -332,7 +343,7 @@ enum { TRACK_ELEM_WATER_SPLASH, TRACK_ELEM_FLAT_TO_60_DEG_UP_LONG_BASE, TRACK_ELEM_60_DEG_UP_TO_FLAT_LONG_BASE, - TRACK_ELEM_WHIRLPOOL = 120, + TRACK_ELEM_WHIRLPOOL = 120, TRACK_ELEM_FLAT_TO_60_DEG_DOWN_LONG_BASE, TRACK_ELEM_60_DEG_UP_TO_FLAT_LONG_BASE_122, TRACK_ELEM_CABLE_LIFT_HILL, @@ -342,7 +353,7 @@ enum { TRACK_ELEM_90_DEG_DOWN, TRACK_ELEM_60_DEG_UP_TO_90_DEG_UP, TRACK_ELEM_90_DEG_DOWN_TO_60_DEG_DOWN, - TRACK_ELEM_90_DEG_UP_TO_60_DEG_UP = 130, + TRACK_ELEM_90_DEG_UP_TO_60_DEG_UP = 130, TRACK_ELEM_60_DEG_DOWN_TO_90_DEG_DOWN, TRACK_ELEM_BRAKE_FOR_DROP, TRACK_ELEM_LEFT_EIGHTH_TO_DIAG, @@ -352,7 +363,7 @@ enum { TRACK_ELEM_LEFT_EIGHTH_BANK_TO_DIAG, TRACK_ELEM_RIGHT_EIGHTH_BANK_TO_DIAG, TRACK_ELEM_LEFT_EIGHTH_BANK_TO_ORTHOGONAL, - TRACK_ELEM_RIGHT_EIGHTH_BANK_TO_ORTHOGONAL = 140, + TRACK_ELEM_RIGHT_EIGHTH_BANK_TO_ORTHOGONAL = 140, TRACK_ELEM_DIAG_FLAT, TRACK_ELEM_DIAG_25_DEG_UP, TRACK_ELEM_DIAG_60_DEG_UP, @@ -362,7 +373,7 @@ enum { TRACK_ELEM_DIAG_25_DEG_UP_TO_FLAT, TRACK_ELEM_DIAG_25_DEG_DOWN, TRACK_ELEM_DIAG_60_DEG_DOWN, - TRACK_ELEM_DIAG_FLAT_TO_25_DEG_DOWN = 150, + TRACK_ELEM_DIAG_FLAT_TO_25_DEG_DOWN = 150, TRACK_ELEM_DIAG_25_DEG_DOWN_TO_60_DEG_DOWN, TRACK_ELEM_DIAG_60_DEG_DOWN_TO_25_DEG_DOWN, TRACK_ELEM_DIAG_25_DEG_DOWN_TO_FLAT, @@ -372,7 +383,7 @@ enum { TRACK_ELEM_DIAG_60_DEG_DOWN_TO_FLAT, TRACK_ELEM_DIAG_FLAT_TO_LEFT_BANK, TRACK_ELEM_DIAG_FLAT_TO_RIGHT_BANK, - TRACK_ELEM_DIAG_LEFT_BANK_TO_FLAT = 160, + TRACK_ELEM_DIAG_LEFT_BANK_TO_FLAT = 160, TRACK_ELEM_DIAG_RIGHT_BANK_TO_FLAT, TRACK_ELEM_DIAG_LEFT_BANK_TO_25_DEG_UP, TRACK_ELEM_DIAG_RIGHT_BANK_TO_25_DEG_UP, @@ -382,7 +393,7 @@ enum { TRACK_ELEM_DIAG_RIGHT_BANK_TO_25_DEG_DOWN, TRACK_ELEM_DIAG_25_DEG_DOWN_TO_LEFT_BANK, TRACK_ELEM_DIAG_25_DEG_DOWN_TO_RIGHT_BANK, - TRACK_ELEM_DIAG_LEFT_BANK = 170, + TRACK_ELEM_DIAG_LEFT_BANK = 170, TRACK_ELEM_DIAG_RIGHT_BANK, TRACK_ELEM_LOG_FLUME_REVERSER, TRACK_ELEM_SPINNING_TUNNEL, @@ -402,7 +413,7 @@ enum { TRACK_ELEM_LEFT_FLYER_TWIST_UP, TRACK_ELEM_RIGHT_FLYER_TWIST_UP, TRACK_ELEM_LEFT_FLYER_TWIST_DOWN, - TRACK_ELEM_RIGHT_FLYER_TWIST_DOWN = 190, + TRACK_ELEM_RIGHT_FLYER_TWIST_DOWN = 190, TRACK_ELEM_FLYER_HALF_LOOP_UP, TRACK_ELEM_FLYER_HALF_LOOP_DOWN, TRACK_ELEM_LEFT_FLYER_CORKSCREW_UP, @@ -412,7 +423,7 @@ enum { TRACK_ELEM_HEARTLINE_TRANSFER_UP, TRACK_ELEM_HEARTLINE_TRANSFER_DOWN, TRACK_ELEM_LEFT_HEARTLINE_ROLL, - TRACK_ELEM_RIGHT_HEARTLINE_ROLL = 200, + TRACK_ELEM_RIGHT_HEARTLINE_ROLL = 200, TRACK_ELEM_MINI_GOLF_HOLE_A, TRACK_ELEM_MINI_GOLF_HOLE_B, TRACK_ELEM_MINI_GOLF_HOLE_C, @@ -422,7 +433,7 @@ enum { TRACK_ELEM_90_DEG_TO_INVERTED_FLAT_QUARTER_LOOP_UP, TRACK_ELEM_INVERTED_FLAT_TO_90_DEG_QUARTER_LOOP_DOWN, TRACK_ELEM_LEFT_CURVED_LIFT_HILL, - TRACK_ELEM_RIGHT_CURVED_LIFT_HILL = 210, + TRACK_ELEM_RIGHT_CURVED_LIFT_HILL = 210, TRACK_ELEM_LEFT_REVERSER, TRACK_ELEM_RIGHT_REVERSER, TRACK_ELEM_AIR_THRUST_TOP_CAP, @@ -470,46 +481,51 @@ enum { TRACK_ELEM_255, }; -enum { +enum +{ FLAT_TRACK_ELEM_1_X_4_A = 95, - FLAT_TRACK_ELEM_2_X_2 = 110, - FLAT_TRACK_ELEM_4_X_4 = 111, - FLAT_TRACK_ELEM_1_X_5 = 116, + FLAT_TRACK_ELEM_2_X_2 = 110, + FLAT_TRACK_ELEM_4_X_4 = 111, + FLAT_TRACK_ELEM_1_X_5 = 116, FLAT_TRACK_ELEM_1_X_1_A = 118, FLAT_TRACK_ELEM_1_X_4_B = 119, FLAT_TRACK_ELEM_1_X_1_B = 121, FLAT_TRACK_ELEM_1_X_4_C = 122, - FLAT_TRACK_ELEM_3_X_3 = 123, + FLAT_TRACK_ELEM_3_X_3 = 123, }; -enum { - TRACK_SEQUENCE_FLAG_DIRECTION_0 = (1 << 0), - TRACK_SEQUENCE_FLAG_DIRECTION_1 = (1 << 1), - TRACK_SEQUENCE_FLAG_DIRECTION_2 = (1 << 2), - TRACK_SEQUENCE_FLAG_DIRECTION_3 = (1 << 3), - TRACK_SEQUENCE_FLAG_ORIGIN = (1 << 4), // 0x10 +enum +{ + TRACK_SEQUENCE_FLAG_DIRECTION_0 = (1 << 0), + TRACK_SEQUENCE_FLAG_DIRECTION_1 = (1 << 1), + TRACK_SEQUENCE_FLAG_DIRECTION_2 = (1 << 2), + TRACK_SEQUENCE_FLAG_DIRECTION_3 = (1 << 3), + TRACK_SEQUENCE_FLAG_ORIGIN = (1 << 4), // 0x10 TRACK_SEQUENCE_FLAG_CONNECTS_TO_PATH = (1 << 5), // 0x20 - TRACK_SEQUENCE_FLAG_DISALLOW_DOORS = (1 << 6), // 0x40 + TRACK_SEQUENCE_FLAG_DISALLOW_DOORS = (1 << 6), // 0x40 }; -enum { +enum +{ TRACK_ELEMENT_LOCATION_IS_UNDERGROUND = 2, }; -enum { +enum +{ GC_SET_MAZE_TRACK_BUILD = 0, - GC_SET_MAZE_TRACK_MOVE = 1, - GC_SET_MAZE_TRACK_FILL = 2, + GC_SET_MAZE_TRACK_MOVE = 1, + GC_SET_MAZE_TRACK_FILL = 2, }; -typedef struct track_circuit_iterator { - rct_xy_element last; - rct_xy_element current; - sint32 currentZ; - sint32 currentDirection; - rct_map_element *first; - bool firstIteration; - bool looped; +typedef struct track_circuit_iterator +{ + rct_xy_element last; + rct_xy_element current; + sint32 currentZ; + sint32 currentDirection; + rct_map_element * first; + bool firstIteration; + bool looped; } track_circuit_iterator; #ifdef __cplusplus @@ -521,37 +537,37 @@ extern const rct_trackdefinition TrackDefinitions[256]; extern uint8 gTrackGroundFlags; -sint32 track_is_connected_by_shape(rct_map_element *a, rct_map_element *b); +sint32 track_is_connected_by_shape(rct_map_element * a, rct_map_element * b); -const rct_preview_track *get_track_def_from_ride(Ride *ride, sint32 trackType); -const rct_preview_track *get_track_def_from_ride_index(sint32 rideIndex, sint32 trackType); -const rct_track_coordinates *get_track_coord_from_ride(Ride *ride, sint32 trackType); +const rct_preview_track * get_track_def_from_ride(Ride * ride, sint32 trackType); +const rct_preview_track * get_track_def_from_ride_index(sint32 rideIndex, sint32 trackType); +const rct_track_coordinates * get_track_coord_from_ride(Ride * ride, sint32 trackType); -void track_circuit_iterator_begin(track_circuit_iterator *it, rct_xy_element first); -bool track_circuit_iterator_previous(track_circuit_iterator *it); -bool track_circuit_iterator_next(track_circuit_iterator *it); +void track_circuit_iterator_begin(track_circuit_iterator * it, rct_xy_element first); +bool track_circuit_iterator_previous(track_circuit_iterator * it); +bool track_circuit_iterator_next(track_circuit_iterator * it); -void track_get_back(rct_xy_element *input, rct_xy_element *output); -void track_get_front(rct_xy_element *input, rct_xy_element *output); +void track_get_back(rct_xy_element * input, rct_xy_element * output); +void track_get_front(rct_xy_element * input, rct_xy_element * output); -bool track_element_is_block_start(rct_map_element *trackElement); +bool track_element_is_block_start(rct_map_element * trackElement); bool track_element_is_covered(sint32 trackElementType); -bool track_element_is_station(rct_map_element *trackElement); -bool track_element_is_lift_hill(rct_map_element *trackElement); -bool track_element_is_cable_lift(rct_map_element *trackElement); -void track_element_set_cable_lift(rct_map_element *trackElement); -void track_element_clear_cable_lift(rct_map_element *trackElement); +bool track_element_is_station(rct_map_element * trackElement); +bool track_element_is_lift_hill(rct_map_element * trackElement); +bool track_element_is_cable_lift(rct_map_element * trackElement); +void track_element_set_cable_lift(rct_map_element * trackElement); +void track_element_clear_cable_lift(rct_map_element * trackElement); bool track_element_is_inverted(rct_map_element * mapElement); void track_element_set_inverted(rct_map_element * mapElement, bool inverted); -sint32 track_get_actual_bank(rct_map_element *mapElement, sint32 bank); +sint32 track_get_actual_bank(rct_map_element * mapElement, sint32 bank); sint32 track_get_actual_bank_2(sint32 rideType, sint32 trackColour, sint32 bank); -sint32 track_get_actual_bank_3(rct_vehicle *vehicle, rct_map_element *mapElement); +sint32 track_get_actual_bank_3(rct_vehicle * vehicle, rct_map_element * mapElement); -void game_command_place_track(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp); -void game_command_remove_track(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp); -void game_command_set_maze_track(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp); -void game_command_set_brakes_speed(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32 *edx, sint32 *esi, sint32 *edi, sint32 *ebp); +void game_command_place_track(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp); +void game_command_remove_track(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp); +void game_command_set_maze_track(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp); +void game_command_set_brakes_speed(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp); bool track_element_is_booster(uint8 rideType, uint8 trackType); bool track_element_has_speed_setting(uint8 trackType); uint8 track_element_get_seat_rotation(const rct_map_element * mapElement); @@ -562,5 +578,3 @@ void track_element_set_colour_scheme(rct_map_element * mapElement, uint8 colourS #ifdef __cplusplus } #endif - -#endif