Remove direct usage of map element track sequence field

This commit is contained in:
Michael Steenbeek authored and GitHub committed 2017-07-27 16:19:01 +02:00
1 parent 7e8aa5f655
commit 41b5e8bbca
17 files changed
+184 -59

No files matched your search

+13 -13
View File
@@ -555,7 +555,7 @@ bool track_block_get_next_from_zero(sint16 x, sint16 y, sint16 z_start, uint8 ri
if (mapElement->properties.track.ride_index != rideIndex)
continue;
if ((mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK) != 0)
if (map_element_get_track_sequence(mapElement) != 0)
continue;
const rct_preview_track* nextTrackBlock = get_track_def_from_ride(ride, mapElement->properties.track.type);
@@ -599,7 +599,7 @@ bool track_block_get_next(rct_xy_element *input, rct_xy_element *output, sint32
rct_ride* ride = get_ride(rideIndex);
const rct_preview_track* trackBlock = get_track_def_from_ride(ride, input->element->properties.track.type);
uint8 sequence = input->element->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
uint8 sequence = map_element_get_track_sequence(input->element);
trackBlock += sequence;
const rct_track_coordinates* trackCoordinate = get_track_coord_from_ride(ride, input->element->properties.track.type);
@@ -683,7 +683,7 @@ bool track_block_get_previous_from_zero(sint16 x, sint16 y, sint16 z, uint8 ride
const rct_preview_track* nextTrackBlock = get_track_def_from_ride(ride, mapElement->properties.track.type);
const rct_track_coordinates* nextTrackCoordinate = get_track_coord_from_ride(ride, mapElement->properties.track.type);
nextTrackBlock += mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
nextTrackBlock += map_element_get_track_sequence(mapElement);
if ((nextTrackBlock + 1)->index != 255)
continue;
@@ -759,7 +759,7 @@ bool track_block_get_previous(sint32 x, sint32 y, rct_map_element *mapElement, t
rct_ride* ride = get_ride(rideIndex);
const rct_preview_track* trackBlock = get_track_def_from_ride(ride, mapElement->properties.track.type);
uint8 sequence = mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
uint8 sequence = map_element_get_track_sequence(mapElement);
trackBlock += sequence;
const rct_track_coordinates* trackCoordinate = get_track_coord_from_ride(ride, mapElement->properties.track.type);
@@ -1258,7 +1258,7 @@ sint32 sub_6C683D(sint32* x, sint32* y, sint32* z, sint32 direction, sint32 type
continue;
successMapElement = mapElement;
if ((mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK) == 0)
if (map_element_get_track_sequence(mapElement) == 0)
break;
} while (!map_element_is_last_for_tile(mapElement++));
@@ -1269,7 +1269,7 @@ sint32 sub_6C683D(sint32* x, sint32* y, sint32* z, sint32 direction, sint32 type
// Possibly z should be & 0xF8
const rct_preview_track *trackBlock = get_track_def_from_ride_index(mapElement->properties.track.ride_index, type);
sint32 sequence = mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
sint32 sequence = map_element_get_track_sequence(mapElement);
uint8 mapDirection = mapElement->type & MAP_ELEMENT_DIRECTION_MASK;
switch (mapDirection){
@@ -1330,7 +1330,7 @@ sint32 sub_6C683D(sint32* x, sint32* y, sint32* z, sint32 direction, sint32 type
if ((mapElement->type & MAP_ELEMENT_DIRECTION_MASK) != direction)
continue;
if ((mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK) != trackBlock[i].index)
if (map_element_get_track_sequence(mapElement) != trackBlock[i].index)
continue;
if (type == mapElement->properties.track.type) {
@@ -1420,7 +1420,7 @@ void ride_remove_provisional_track_piece()
next_track.x,
105 | ((direction & 3) << 8),
next_track.y,
next_track.element->properties.track.type | ((next_track.element->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK) << 8),
next_track.element->properties.track.type | (map_element_get_track_sequence(next_track.element) << 8),
GAME_COMMAND_REMOVE_TRACK,
z,
0
@@ -4788,7 +4788,7 @@ static void ride_create_vehicles_find_first_block(rct_ride *ride, rct_xy_element
do {
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK) continue;
if (mapElement->properties.track.type != trackType) continue;
if ((mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK) != 0) continue;
if (map_element_get_track_sequence(mapElement) != 0) continue;
if (mapElement->base_height != trackBeginEnd.begin_z / 8) continue;
outXYElement->x = trackBeginEnd.begin_x;
outXYElement->y = trackBeginEnd.begin_y;
@@ -5723,7 +5723,7 @@ sint32 ride_get_refund_price(sint32 ride_id)
x,
GAME_COMMAND_FLAG_APPLY | (rotation << 8),
y,
type | ((it.element->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK) << 8),
type | (map_element_get_track_sequence(it.element) << 8),
GAME_COMMAND_REMOVE_TRACK,
z,
0);
@@ -7282,7 +7282,7 @@ void ride_get_entrance_or_exit_position_from_screen_position(sint32 screenX, sin
continue;
sint32 eax = (direction + 2 - mapElement->type) & MAP_ELEMENT_DIRECTION_MASK;
if (FlatRideTrackSequenceProperties[mapElement->properties.track.type][mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK] & (1 << eax)) {
if (FlatRideTrackSequenceProperties[mapElement->properties.track.type][map_element_get_track_sequence(mapElement)] & (1 << eax)) {
gRideEntranceExitPlaceDirection = direction ^ 2;
*outDirection = direction ^ 2;
return;
@@ -8034,7 +8034,7 @@ void sub_6CB945(sint32 rideIndex)
if (mapElement->base_height != location.z) continue;
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK) continue;
if (mapElement->properties.track.ride_index != rideIndex) continue;
if ((mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK) != 0) continue;
if (map_element_get_track_sequence(mapElement) != 0) continue;
if (!(TrackSequenceProperties[mapElement->properties.track.type][0] & TRACK_SEQUENCE_FLAG_ORIGIN)) continue;
trackFound = true;
@@ -8139,7 +8139,7 @@ void sub_6CB945(sint32 rideIndex)
if (trackElement->base_height != mapElement->base_height) continue;
uint8 trackType = trackElement->properties.track.type;
uint8 trackSequence = trackElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
uint8 trackSequence = map_element_get_track_sequence(mapElement);
uint8 direction = (map_element_get_direction(mapElement) - map_element_get_direction(trackElement) + 2) & 3;
+2 -2
View File
@@ -202,7 +202,7 @@ static void ride_ratings_update_state_2()
if (
trackType == 255 ||
((mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK) == 0 && trackType == mapElement->properties.track.type))
(map_element_get_track_sequence(mapElement) == 0 && trackType == mapElement->properties.track.type))
{
if (trackType == TRACK_ELEM_END_STATION) {
sint32 entranceIndex = map_element_get_station(mapElement);
@@ -541,7 +541,7 @@ static void ride_ratings_score_close_proximity(rct_map_element *inputMapElement)
{
sint32 trackType = mapElement->properties.track.type;
if (trackType == TRACK_ELEM_LEFT_VERTICAL_LOOP || trackType == TRACK_ELEM_RIGHT_VERTICAL_LOOP) {
sint32 sequence = mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
sint32 sequence = map_element_get_track_sequence(mapElement);
if (sequence == 3 || sequence == 6) {
if (mapElement->base_height - inputMapElement->clearance_height <= 10) {
proximity_score_increment(PROXIMITY_THROUGH_VERTICAL_LOOP);
+3 -7
View File
@@ -65,13 +65,13 @@ static void ride_update_station_blocksection(rct_ride *ride, sint32 stationIndex
if ((ride->status == RIDE_STATUS_CLOSED && ride->num_riders == 0) || (mapElement != NULL && mapElement->flags & 0x20)) {
ride->station_depart[stationIndex] &= ~STATION_DEPART_FLAG;
if ((ride->station_depart[stationIndex] & STATION_DEPART_FLAG) || (mapElement != NULL && (mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT)))
if ((ride->station_depart[stationIndex] & STATION_DEPART_FLAG) || (mapElement != NULL && map_element_get_green_light(mapElement)))
ride_invalidate_station_start(ride, stationIndex, false);
} else {
if (!(ride->station_depart[stationIndex] & STATION_DEPART_FLAG)) {
ride->station_depart[stationIndex] |= STATION_DEPART_FLAG;
ride_invalidate_station_start(ride, stationIndex, true);
} else if (mapElement != NULL && mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT) {
} else if (mapElement != NULL && map_element_get_green_light(mapElement)) {
ride_invalidate_station_start(ride, stationIndex, true);
}
}
@@ -281,11 +281,7 @@ static void ride_invalidate_station_start(rct_ride *ride, sint32 stationIndex, b
if (mapElement == NULL)
return;
mapElement->properties.track.sequence &= ~MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT;
if (greenLight)
{
mapElement->properties.track.sequence |= MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT;
}
map_element_set_green_light(mapElement, greenLight);
// Invalidate map tile
map_invalidate_tile_zoom1(x, y, mapElement->base_height * 8, mapElement->clearance_height * 8);
+1 -1
View File
@@ -361,7 +361,7 @@ static void paint_go_karts_station(uint8 rideIndex, uint8 trackSequence, uint8 d
}
if (mapElement->properties.track.type == TRACK_ELEM_END_STATION) {
const bool hasGreenLight = (bool)(mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT);
const bool hasGreenLight = map_element_get_green_light(mapElement);
switch (direction) {
case 0:
+8 -10
View File
@@ -1327,7 +1327,7 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32
}
mapElement->type = map_type;
mapElement->properties.track.sequence = trackBlock->index;
map_element_set_track_sequence(mapElement, trackBlock->index);
mapElement->properties.track.ride_index = rideIndex;
mapElement->properties.track.type = type;
mapElement->properties.track.colour = 0;
@@ -1350,7 +1350,7 @@ static money32 track_place(sint32 rideIndex, sint32 type, sint32 originX, sint32
break;
}
if (track_element_has_speed_setting(type)) {
mapElement->properties.track.sequence = (properties_1 >> 1) << 4;
map_element_set_brake_booster_speed(mapElement, properties_1);
}
else {
mapElement->properties.track.colour = properties_3 << 4;
@@ -1470,7 +1470,7 @@ static money32 track_remove(uint8 type, uint8 sequence, sint16 originX, sint16 o
if ((mapElement->type & MAP_ELEMENT_DIRECTION_MASK) != rotation)
continue;
if ((mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK) != sequence)
if (map_element_get_track_sequence(mapElement) != sequence)
continue;
// Probably should add a check for ghost here as well!
@@ -1505,7 +1505,7 @@ static money32 track_remove(uint8 type, uint8 sequence, sint16 originX, sint16 o
rct_ride* ride = get_ride(rideIndex);
const rct_preview_track* trackBlock = get_track_def_from_ride(ride, type);
trackBlock += mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
trackBlock += map_element_get_track_sequence(mapElement);
uint8 originDirection = mapElement->type & MAP_ELEMENT_DIRECTION_MASK;
switch (originDirection){
@@ -1572,7 +1572,7 @@ static money32 track_remove(uint8 type, uint8 sequence, sint16 originX, sint16 o
if ((mapElement->type & MAP_ELEMENT_DIRECTION_MASK) != rotation)
continue;
if ((mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK) != trackBlock->index)
if (map_element_get_track_sequence(mapElement) != trackBlock->index)
continue;
if (mapElement->properties.track.type != type)
@@ -1595,7 +1595,7 @@ static money32 track_remove(uint8 type, uint8 sequence, sint16 originX, sint16 o
entranceDirections = TrackSequenceProperties[type][0];
}
if (entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN && ((mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK) == 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;
}
@@ -1616,7 +1616,7 @@ static money32 track_remove(uint8 type, uint8 sequence, sint16 originX, sint16 o
if (!(flags & GAME_COMMAND_FLAG_APPLY))
continue;
if (entranceDirections & (1 << 4) && ((mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK) == 0)){
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;
}
@@ -2022,9 +2022,7 @@ void game_command_set_brakes_speed(sint32 *eax, sint32 *ebx, sint32 *ecx, sint32
if (mapElement->properties.track.type != trackType)
continue;
mapElement->properties.track.sequence =
(mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK) |
((brakesSpeed >> 1) << 4);
map_element_set_brake_booster_speed(mapElement, brakesSpeed);
break;
} while (!map_element_is_last_for_tile(mapElement++));
+1 -1
View File
@@ -1005,7 +1005,7 @@ static bool track_design_save_to_td6_for_tracked_ride(uint8 rideIndex, rct_track
uint8 bh;
if (track_element_has_speed_setting(track->type)) {
bh = trackElement.element->properties.track.sequence >> 4;
bh = map_element_get_brake_booster_speed(trackElement.element) >> 1;
} else {
bh = trackElement.element->properties.track.colour >> 4;
}
+5 -5
View File
@@ -307,7 +307,7 @@ void track_paint_util_draw_station_impl(uint8 rideIndex, uint8 trackSequence, ui
rct_xy16 position = {gPaintMapPosition.x, gPaintMapPosition.y};
rct_ride * ride = get_ride(rideIndex);
const rct_ride_entrance_definition * entranceStyle = &RideEntranceDefinitions[ride->entrance_style];
const bool hasGreenLight = (bool) (mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT);
const bool hasGreenLight = map_element_get_green_light(mapElement);
bool hasFence;
uint32 imageId;
@@ -441,7 +441,7 @@ void track_paint_util_draw_station_inverted(uint8 rideIndex, uint8 trackSequence
rct_xy16 position = {gPaintMapPosition.x, gPaintMapPosition.y};
rct_ride * ride = get_ride(rideIndex);
const rct_ride_entrance_definition * entranceStyle = &RideEntranceDefinitions[ride->entrance_style];
const bool hasGreenLight = (bool) (mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT);
const bool hasGreenLight = map_element_get_green_light(mapElement);
bool hasFence;
uint32 imageId;
@@ -1634,7 +1634,7 @@ void track_paint_util_onride_photo_small_paint(uint8 direction, sint32 height, r
{ SPR_ON_RIDE_PHOTO_SIGN_SMALL_SE_NW, SPR_ON_RIDE_PHOTO_CAMERA_SMALL_E, SPR_ON_RIDE_PHOTO_CAMERA_FLASH_SMALL_E },
};
bool takingPhoto = (mapElement->properties.track.sequence & 0xF0) != 0;
bool takingPhoto = map_element_is_taking_photo(mapElement);
uint32 imageId = imageIds[direction][0] | gTrackColours[SCHEME_MISC];
uint32 flashImageId = imageIds[direction][takingPhoto ? 2 : 1] | gTrackColours[SCHEME_MISC];
switch (direction) {
@@ -1671,7 +1671,7 @@ void track_paint_util_onride_photo_paint(uint8 direction, sint32 height, rct_map
{ SPR_ON_RIDE_PHOTO_SIGN_SE_NW, SPR_ON_RIDE_PHOTO_CAMERA_E, SPR_ON_RIDE_PHOTO_CAMERA_FLASH_E },
};
bool takingPhoto = (mapElement->properties.track.sequence & 0xF0) != 0;
bool takingPhoto = map_element_is_taking_photo(mapElement);
uint32 imageId = imageIds[direction][0] | gTrackColours[SCHEME_MISC];
uint32 flashImageId = imageIds[direction][takingPhoto ? 2 : 1] | gTrackColours[SCHEME_MISC];
switch (direction) {
@@ -1757,7 +1757,7 @@ void track_paint(uint8 direction, sint32 height, rct_map_element *mapElement)
if (!gTrackDesignSaveMode || rideIndex == gTrackDesignSaveRideIndex) {
sint32 trackType = mapElement->properties.track.type;
sint32 trackSequence = mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
sint32 trackSequence = map_element_get_track_sequence(mapElement);
sint32 trackColourScheme = mapElement->properties.track.colour & 3;
if ((gCurrentViewportFlags & VIEWPORT_FLAG_TRACK_HEIGHTS) && dpi->zoom_level == 0) {
+5 -5
View File
@@ -6926,8 +6926,8 @@ static void loc_6DB481(rct_vehicle *vehicle)
*/
static void vehicle_trigger_on_ride_photo(rct_vehicle *vehicle, rct_map_element *mapElement)
{
mapElement->properties.track.sequence &= MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
mapElement->properties.track.sequence |= 0x30;
map_element_set_onride_photo_timeout(mapElement);
map_animation_create(
MAP_ANIMATION_TYPE_TRACK_ONRIDEPHOTO,
vehicle->track_x,
@@ -7473,7 +7473,7 @@ loc_6DB41D:
}
vehicle->track_direction = regs.bl & 3;
vehicle->track_type |= trackType << 2;
vehicle->brake_speed = (mapElement->properties.track.sequence >> 4) << 1;
vehicle->brake_speed = map_element_get_brake_booster_speed(mapElement);
if (trackType == TRACK_ELEM_ON_RIDE_PHOTO) {
vehicle_trigger_on_ride_photo(vehicle, mapElement);
}
@@ -7848,7 +7848,7 @@ static bool vehicle_update_track_motion_backwards_get_new_track(rct_vehicle *veh
direction &= 3;
vehicle->track_type = trackType << 2;
vehicle->track_direction |= direction;
vehicle->brake_speed = (mapElement->properties.track.sequence >> 4) << 1;
vehicle->brake_speed = map_element_get_brake_booster_speed(mapElement);
// There are two bytes before the move info list
uint16 trackTotalProgress = vehicle_get_move_info_size(vehicle->var_CD, vehicle->track_type);
@@ -8157,7 +8157,7 @@ loc_6DC476:
vehicle->update_flags &= ~VEHICLE_UPDATE_FLAG_0;
vehicle->track_type = (mapElement->properties.track.type << 2) | (direction & 3);
vehicle->var_CF = (mapElement->properties.track.sequence >> 4) << 1;
vehicle->var_CF = map_element_get_brake_booster_speed(mapElement);
regs.ax = 0;
loc_6DC743:
+2 -2
View File
@@ -2425,7 +2425,7 @@ static void sub_6CBCE2(
_tempTrackMapElement.base_height = baseZ;
_tempTrackMapElement.clearance_height = clearanceZ;
_tempTrackMapElement.properties.track.type = trackType;
_tempTrackMapElement.properties.track.sequence = trackBlock->index;
map_element_set_track_sequence(&_tempTrackMapElement, trackBlock->index);
_tempTrackMapElement.properties.track.colour = (edx & 0x20000) ? 4 : 0;
_tempTrackMapElement.properties.track.ride_index = rideIndex;
@@ -2477,7 +2477,7 @@ void window_ride_construction_update_active_elements()
if (!sub_6C683D(&x, &y, &z, _currentTrackPieceDirection & 3, _currentTrackPieceType, 0, &mapElement, 0)) {
_selectedTrackType = mapElement->properties.track.type;
if (track_element_has_speed_setting(mapElement->properties.track.type))
_currentBrakeSpeed2 = (mapElement->properties.track.sequence >> 4) << 1;
_currentBrakeSpeed2 = map_element_get_brake_booster_speed(mapElement);
_currentSeatRotationAngle = mapElement->properties.track.colour >> 4;
}
}
+1 -1
View File
@@ -1729,7 +1729,7 @@ static void window_tile_inspector_paint(rct_window *w, rct_drawpixelinfo *dpi)
gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_TRACK_RIDE_NAME, gCommonFormatArgs, COLOUR_DARK_GREEN, x, y + 22);
// Track
sint16 trackType = mapElement->properties.track.type;
sint16 sequenceNumber = mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
sint16 sequenceNumber = map_element_get_track_sequence(mapElement);
gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_TRACK_PIECE_ID, &trackType, COLOUR_DARK_GREEN, x, y + 33);
gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_TRACK_SEQUENCE, &sequenceNumber, COLOUR_DARK_GREEN, x, y + 44);
+2 -2
View File
@@ -1194,7 +1194,7 @@ static void loc_6A6D7E(
}
const uint8 trackType = mapElement->properties.track.type;
const uint8 trackSequence = mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
const uint8 trackSequence = map_element_get_track_sequence(mapElement);
if (!(FlatRideTrackSequenceProperties[trackType][trackSequence] & TRACK_SEQUENCE_FLAG_CONNECTS_TO_PATH)) {
return;
}
@@ -1286,7 +1286,7 @@ static void loc_6A6C85(
return;
}
const uint8 trackType = mapElement->properties.track.type;
const uint8 trackSequence = mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
const uint8 trackSequence = map_element_get_track_sequence(mapElement);
if (!(FlatRideTrackSequenceProperties[trackType][trackSequence] & TRACK_SEQUENCE_FLAG_CONNECTS_TO_PATH)) {
return;
}
+56 -1
View File
@@ -2730,6 +2730,61 @@ void map_element_set_station(rct_map_element * mapElement, uint32 stationIndex)
mapElement->properties.track.sequence |= (stationIndex << 4);
}
sint32 map_element_get_track_sequence(const rct_map_element * mapElement)
{
return mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
}
void map_element_set_track_sequence(rct_map_element * mapElement, sint32 trackSequence)
{
mapElement->properties.track.sequence &= ~MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
mapElement->properties.track.sequence |= (trackSequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK);
}
bool map_element_get_green_light(const rct_map_element * mapElement)
{
return (bool)mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT;
}
void map_element_set_green_light(rct_map_element * mapElement, bool greenLight)
{
mapElement->properties.track.sequence &= ~MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT;
if (greenLight)
{
mapElement->properties.track.sequence |= MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT;
}
}
sint32 map_element_get_brake_booster_speed(const rct_map_element *mapElement)
{
return (mapElement->properties.track.sequence >> 4) << 1;
}
void map_element_set_brake_booster_speed(rct_map_element *mapElement, sint32 speed)
{
mapElement->properties.track.sequence = map_element_get_track_sequence(mapElement) | ((speed >> 1) << 4);
}
bool map_element_is_taking_photo(const rct_map_element * mapElement)
{
return (bool)mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_TAKING_PHOTO_MASK;
}
void map_element_set_onride_photo_timeout(rct_map_element * mapElement)
{
mapElement->properties.track.sequence &= MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
mapElement->properties.track.sequence |= (3 << 4);
}
void map_element_decrement_onride_photo_timout(rct_map_element * mapElement)
{
// We should only touch the upper 4 bits, avoid underflow into the lower 4.
if (mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_TAKING_PHOTO_MASK)
{
mapElement->properties.track.sequence -= (1 << 4);
}
}
/**
*
* rct2: 0x0068B280
@@ -4269,7 +4324,7 @@ rct_map_element *map_get_track_element_at_of_type_seq(sint32 x, sint32 y, sint32
if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK) continue;
if (mapElement->base_height != z) continue;
if (mapElement->properties.track.type != trackType) continue;
if ((mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK) != sequence) continue;
if (map_element_get_track_sequence(mapElement) != sequence) continue;
return mapElement;
} while (!map_element_is_last_for_tile(mapElement++));
+22 -1
View File
@@ -43,7 +43,18 @@ typedef struct rct_map_element_track_properties {
uint8 type; //4
union{
struct{
uint8 sequence; //5
// The lower 4 bits are the track sequence.
// The upper 4 bits are either station bits or on-ride photo bits.
//
// Station bits:
// - Bit 8 marks green light
// - Bit 5-7 are station index.
//
// On-ride photo bits:
// - Bits 7 and 8 are never set
// - Bits 5 and 6 are set when a vehicle triggers the on-ride photo and act like a countdown from 3.
// - If any of the bits 5-8 are set, the game counts it as a photo being taken.
uint8 sequence; //5.
uint8 colour; //6
};
uint16 maze_entry; // 5
@@ -255,6 +266,7 @@ enum
#define MAP_ELEM_TRACK_SEQUENCE_STATION_INDEX_MASK 0x70
#define MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK 0x0F
#define MAP_ELEM_TRACK_SEQUENCE_TAKING_PHOTO_MASK 0xF0
#define MINIMUM_MAP_SIZE_TECHNICAL 15
#define MAXIMUM_MAP_SIZE_TECHNICAL 256
@@ -449,6 +461,15 @@ bool map_is_location_owned_or_has_rights(sint32 x, sint32 y);
bool map_surface_is_blocked(sint16 x, sint16 y);
sint32 map_element_get_station(const rct_map_element * mapElement);
void map_element_set_station(rct_map_element * mapElement, uint32 stationIndex);
sint32 map_element_get_track_sequence(const rct_map_element * mapElement);
void map_element_set_track_sequence(rct_map_element * mapElement, sint32 trackSequence);
bool map_element_get_green_light(const rct_map_element * mapElement);
void map_element_set_green_light(rct_map_element * mapElement, bool greenLight);
sint32 map_element_get_brake_booster_speed(const rct_map_element *mapElement);
void map_element_set_brake_booster_speed(rct_map_element *mapElement, sint32 speed);
bool map_element_is_taking_photo(const rct_map_element * mapElement);
void map_element_set_onride_photo_timeout(rct_map_element * mapElement);
void map_element_decrement_onride_photo_timout(rct_map_element * mapElement);
void map_element_remove(rct_map_element *mapElement);
void map_remove_all_rides();
void map_invalidate_map_selection_tiles();
+2 -2
View File
@@ -324,8 +324,8 @@ static bool map_animation_invalidate_track_onridephoto(sint32 x, sint32 y, sint3
if (game_is_paused()) {
return false;
}
if (mapElement->properties.track.sequence & 0xF0) {
mapElement->properties.track.sequence -= 0x10;
if (map_element_is_taking_photo(mapElement)) {
map_element_decrement_onride_photo_timout(mapElement);
return false;
} else {
return true;
+4 -4
View File
@@ -602,7 +602,7 @@ sint32 tile_inspector_track_base_height_offset(sint32 x, sint32 y, sint32 elemen
uint8 rideIndex = trackElement->properties.track.ride_index;
rct_ride* ride = get_ride(rideIndex);
const rct_preview_track* trackBlock = get_track_def_from_ride(ride, type);
trackBlock += trackElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
trackBlock += map_element_get_track_sequence(trackElement);
uint8 originDirection = map_element_get_direction(trackElement);
switch (originDirection)
@@ -669,7 +669,7 @@ sint32 tile_inspector_track_base_height_offset(sint32 x, sint32 y, sint32 elemen
if ((mapElement->type & MAP_ELEMENT_DIRECTION_MASK) != rotation)
continue;
if ((mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK) != trackBlock->index)
if (map_element_get_track_sequence(mapElement) != trackBlock->index)
continue;
if (mapElement->properties.track.type != type)
@@ -734,7 +734,7 @@ sint32 tile_inspector_track_set_chain(sint32 x, sint32 y, sint32 elementIndex, b
uint8 rideIndex = trackElement->properties.track.ride_index;
rct_ride* ride = get_ride(rideIndex);
const rct_preview_track* trackBlock = get_track_def_from_ride(ride, type);
trackBlock += trackElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
trackBlock += map_element_get_track_sequence(trackElement);
uint8 originDirection = map_element_get_direction(trackElement);
switch (originDirection)
@@ -801,7 +801,7 @@ sint32 tile_inspector_track_set_chain(sint32 x, sint32 y, sint32 elementIndex, b
if ((mapElement->type & MAP_ELEMENT_DIRECTION_MASK) != rotation)
continue;
if ((mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK) != trackBlock->index)
if (map_element_get_track_sequence(mapElement) != trackBlock->index)
continue;
if (mapElement->properties.track.type != type)
+1 -1
View File
@@ -69,7 +69,7 @@ static bool WallCheckObstructionWithTrack(rct_scenery_entry * wall,
bool * wallAcrossTrack)
{
sint32 trackType = trackElement->properties.track.type;
sint32 sequence = trackElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
sint32 sequence = map_element_get_track_sequence(trackElement);
sint32 direction = (edge - trackElement->type) & 3;
rct_ride * ride = get_ride(trackElement->properties.track.ride_index);
+56 -1
View File
@@ -141,12 +141,67 @@ int map_element_get_station(const rct_map_element * mapElement) {
return (mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_STATION_INDEX_MASK) >> 4;
}
void map_element_set_station(rct_map_element * mapElement, int stationIndex)
void map_element_set_station(rct_map_element * mapElement, uint32 stationIndex)
{
mapElement->properties.track.sequence &= ~MAP_ELEM_TRACK_SEQUENCE_STATION_INDEX_MASK;
mapElement->properties.track.sequence |= (stationIndex << 4);
}
sint32 map_element_get_track_sequence(const rct_map_element * mapElement)
{
return mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
}
void map_element_set_track_sequence(rct_map_element * mapElement, int trackSequence)
{
mapElement->properties.track.sequence &= ~MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
mapElement->properties.track.sequence |= (trackSequence & MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK);
}
bool map_element_get_green_light(const rct_map_element * mapElement)
{
return (bool)mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT;
}
void map_element_set_green_light(rct_map_element * mapElement, bool greenLight)
{
mapElement->properties.track.sequence &= ~MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT;
if (greenLight)
{
mapElement->properties.track.sequence |= MAP_ELEM_TRACK_SEQUENCE_GREEN_LIGHT;
}
}
int map_element_get_brake_booster_speed(const rct_map_element *mapElement)
{
return (mapElement->properties.track.sequence >> 4) << 1;
}
void map_element_set_brake_booster_speed(rct_map_element *mapElement, int speed)
{
mapElement->properties.track.sequence = map_element_get_track_sequence(mapElement) | ((speed >> 1) << 4);
}
bool map_element_is_taking_photo(const rct_map_element * mapElement)
{
return (bool)mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_TAKING_PHOTO_MASK;
}
void map_element_set_onride_photo_timeout(rct_map_element * mapElement)
{
mapElement->properties.track.sequence &= MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK;
mapElement->properties.track.sequence |= (3 << 4);
}
void map_element_decrement_onride_photo_timout(rct_map_element * mapElement)
{
// We should only touch the upper 4 bits, avoid underflow into the lower 4.
if (mapElement->properties.track.sequence & MAP_ELEM_TRACK_SEQUENCE_TAKING_PHOTO_MASK)
{
mapElement->properties.track.sequence -= (1 << 4);
}
}
bool ride_type_has_flag(int rideType, int flag)
{
return (RideProperties[rideType].flags & flag) != 0;