1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 15:52:55 +01:00

Remove direct usage of map element track sequence field

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

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;