Merge pull request #8781 from duncanspumpkin/flag_refactor

Flag refactor
This commit is contained in:
Duncan 2019-02-27 19:18:02 +00:00 committed by GitHub
commit f0092b7aae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 171 additions and 73 deletions

View File

@ -366,7 +366,7 @@ int32_t viewport_interaction_get_item_right(int32_t x, int32_t y, viewport_inter
case VIEWPORT_INTERACTION_ITEM_FOOTPATH_ITEM:
sceneryEntry = tileElement->AsPath()->GetAdditionEntry();
set_map_tooltip_format_arg(0, rct_string_id, STR_MAP_TOOLTIP_STRINGID_CLICK_TO_REMOVE);
if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN)
if (tileElement->AsPath()->IsBroken())
{
set_map_tooltip_format_arg(2, rct_string_id, STR_BROKEN);
set_map_tooltip_format_arg(4, rct_string_id, sceneryEntry->name);

View File

@ -2186,8 +2186,8 @@ static void window_tile_inspector_scrollpaint(rct_window* w, rct_drawpixelinfo*
const int32_t baseHeight = tileElement->base_height;
const int32_t clearanceHeight = tileElement->clearance_height;
const bool ghost = tileElement->IsGhost();
const bool broken = (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN) != 0;
const bool last = (tileElement->flags & TILE_ELEMENT_FLAG_LAST_TILE) != 0;
const bool broken = tileElement->AsPath() == nullptr ? false : tileElement->AsPath()->IsBroken();
const bool last = tileElement->IsLastForTile();
const rct_string_id stringFormat = (selectedRow || hoveredRow) ? STR_WHITE_STRING : STR_WINDOW_COLOUR_2_STRINGID;

View File

@ -105,7 +105,7 @@ static void cheat_fix_vandalism()
if (!(it.element)->AsPath()->HasAddition())
continue;
it.element->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
it.element->AsPath()->SetIsBroken(false);
} while (tile_element_iterator_next(&it));
gfx_invalidate_screen();

View File

@ -241,7 +241,7 @@ private:
{
if (tileElement->GetType() == TILE_ELEMENT_TYPE_LARGE_SCENERY)
{
tileElement->flags &= ~TILE_ELEMENT_FLAG_LARGE_SCENERY_ACCOUNTED;
tileElement->AsLargeScenery()->SetIsAccounted(false);
}
} while (!(tileElement++)->IsLastForTile());
}

View File

@ -113,11 +113,11 @@ public:
// scenery tile elements.
if (flags & GAME_COMMAND_FLAG_PATH_SCENERY)
{
if (tileElement->flags & TILE_ELEMENT_FLAG_LARGE_SCENERY_ACCOUNTED)
if (tileElement->AsLargeScenery()->IsAccounted())
calculate_cost = false;
// Sets the flag to prevent this being counted in additional calls
tileElement->flags |= TILE_ELEMENT_FLAG_LARGE_SCENERY_ACCOUNTED;
tileElement->AsLargeScenery()->SetIsAccounted(true);
}
}

View File

@ -117,7 +117,7 @@ public:
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS);
}
if (tileElement->flags & TILE_ELEMENT_FLAG_INDESTRUCTIBLE_TRACK_PIECE)
if (tileElement->AsTrack()->IsIndestructible())
{
return MakeResult(
GA_ERROR::DISALLOWED, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, STR_YOU_ARE_NOT_ALLOWED_TO_REMOVE_THIS_SECTION);

View File

@ -102,7 +102,7 @@ static void path_bit_lights_paint(
{
imageId = pathBitEntry->image + 1;
if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN)
if (tileElement->AsPath()->IsBroken())
imageId += 4;
imageId |= pathBitImageFlags;
@ -113,7 +113,7 @@ static void path_bit_lights_paint(
{
imageId = pathBitEntry->image + 2;
if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN)
if (tileElement->AsPath()->IsBroken())
imageId += 4;
imageId |= pathBitImageFlags;
@ -125,7 +125,7 @@ static void path_bit_lights_paint(
{
imageId = pathBitEntry->image + 3;
if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN)
if (tileElement->AsPath()->IsBroken())
imageId += 4;
imageId |= pathBitImageFlags;
@ -137,7 +137,7 @@ static void path_bit_lights_paint(
{
imageId = pathBitEntry->image + 4;
if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN)
if (tileElement->AsPath()->IsBroken())
imageId += 4;
imageId |= pathBitImageFlags;
@ -155,7 +155,7 @@ static void path_bit_bins_paint(
height += 8;
uint32_t imageId;
bool binsAreVandalised = tileElement->flags & TILE_ELEMENT_FLAG_BROKEN;
bool binsAreVandalised = tileElement->AsPath()->IsBroken();
if (!(edges & EDGE_NE))
{
@ -256,7 +256,7 @@ static void path_bit_benches_paint(
{
imageId = pathBitEntry->image + 1;
if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN)
if (tileElement->AsPath()->IsBroken())
imageId += 4;
imageId |= pathBitImageFlags;
@ -267,7 +267,7 @@ static void path_bit_benches_paint(
{
imageId = pathBitEntry->image + 2;
if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN)
if (tileElement->AsPath()->IsBroken())
imageId += 4;
imageId |= pathBitImageFlags;
@ -279,7 +279,7 @@ static void path_bit_benches_paint(
{
imageId = pathBitEntry->image + 3;
if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN)
if (tileElement->AsPath()->IsBroken())
imageId += 4;
imageId |= pathBitImageFlags;
@ -291,7 +291,7 @@ static void path_bit_benches_paint(
{
imageId = pathBitEntry->image + 4;
if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN)
if (tileElement->AsPath()->IsBroken())
imageId += 4;
imageId |= pathBitImageFlags;
@ -703,8 +703,7 @@ static void sub_6A3F61(
if (sceneryEntry == nullptr)
return;
if ((session->ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES)
&& !(tile_element->flags & TILE_ELEMENT_FLAG_BROKEN)
if ((session->ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES) && !(tile_element->AsPath()->IsBroken())
&& !(sceneryEntry->path_bit.draw_type == PATH_BIT_DRAW_TYPE_BINS))
{
return;
@ -836,7 +835,7 @@ void path_paint(paint_session* session, uint16_t height, const TileElement* tile
}
// For debugging purpose, show blocked tiles with a colour
if (gPaintBlockedTiles && (tile_element->flags & TILE_ELEMENT_FLAG_BLOCKED_BY_VEHICLE))
if (gPaintBlockedTiles && tile_element->AsPath()->IsBlockedByVehicle())
{
imageFlags = COLOUR_BRIGHT_GREEN << 19 | COLOUR_GREY << 24 | IMAGE_TYPE_REMAP;
}
@ -948,7 +947,7 @@ void path_paint(paint_session* session, uint16_t height, const TileElement* tile
#ifdef __ENABLE_LIGHTFX__
if (lightfx_is_available())
{
if (tile_element->AsPath()->HasAddition() && !(tile_element->flags & TILE_ELEMENT_FLAG_BROKEN))
if (tile_element->AsPath()->HasAddition() && !(tile_element->AsPath()->IsBroken()))
{
rct_scenery_entry* sceneryEntry = tile_element->AsPath()->GetAdditionEntry();
if (sceneryEntry != nullptr && sceneryEntry->path_bit.flags & PATH_BIT_FLAG_LAMP)

View File

@ -2728,7 +2728,7 @@ static PeepThoughtType peep_assess_surroundings(int16_t centre_x, int16_t centre
num_fountains++;
break;
}
if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN)
if (tileElement->AsPath()->IsBroken())
{
num_rubbish++;
}
@ -5782,7 +5782,7 @@ void rct_peep::UpdateUsingBin()
return;
}
if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN)
if (tileElement->AsPath()->IsBroken())
{
StateReset();
return;
@ -5945,7 +5945,7 @@ bool rct_peep::UpdateWalkingFindBench()
if (sceneryEntry == nullptr || !(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BENCH))
return false;
if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN)
if (tileElement->AsPath()->IsBroken())
return false;
if (tileElement->AsPath()->AdditionIsGhost())
@ -6044,7 +6044,7 @@ bool rct_peep::UpdateWalkingFindBin()
if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN))
return false;
if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN)
if (tileElement->AsPath()->IsBroken())
return false;
if (tileElement->AsPath()->AdditionIsGhost())
@ -6141,7 +6141,7 @@ static void peep_update_walking_break_scenery(rct_peep* peep)
if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_BREAKABLE))
return;
if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN)
if (tileElement->AsPath()->IsBroken())
return;
if (tileElement->AsPath()->AdditionIsGhost())
@ -6185,7 +6185,7 @@ static void peep_update_walking_break_scenery(rct_peep* peep)
return;
}
tileElement->flags |= TILE_ELEMENT_FLAG_BROKEN;
tileElement->AsPath()->SetIsBroken(true);
map_invalidate_tile_zoom1(peep->next_x, peep->next_y, (tileElement->base_height << 3) + 32, tileElement->base_height << 3);

View File

@ -2874,7 +2874,7 @@ static void peep_interact_with_path(rct_peep* peep, int16_t x, int16_t y, TileEl
{
// 0x00F1AEE2
bool vandalism_present = false;
if (tile_element->AsPath()->HasAddition() && (tile_element->flags & TILE_ELEMENT_FLAG_BROKEN)
if (tile_element->AsPath()->HasAddition() && (tile_element->AsPath()->IsBroken())
&& (tile_element->AsPath()->GetEdges()) != 0xF)
{
vandalism_present = true;

View File

@ -1729,7 +1729,7 @@ void rct_peep::UpdateEmptyingBin()
}
rct_scenery_entry* scenery_entry = tile_element->AsPath()->GetAdditionEntry();
if (!(scenery_entry->path_bit.flags & PATH_BIT_FLAG_IS_BIN) || tile_element->flags & TILE_ELEMENT_FLAG_BROKEN
if (!(scenery_entry->path_bit.flags & PATH_BIT_FLAG_IS_BIN) || tile_element->AsPath()->IsBroken()
|| tile_element->AsPath()->AdditionIsGhost())
{
StateReset();
@ -2130,7 +2130,7 @@ static int32_t peep_update_patrolling_find_bin(rct_peep* peep)
if (!(sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_BIN))
return 0;
if (tileElement->flags & TILE_ELEMENT_FLAG_BROKEN)
if (tileElement->AsPath()->IsBroken())
return 0;
if (tileElement->AsPath()->AdditionIsGhost())

View File

@ -2080,7 +2080,8 @@ private:
uint8_t entryIndex = _pathTypeToEntryMap[pathType];
dst2->SetDirection(0);
dst2->flags &= ~(TILE_ELEMENT_FLAG_BROKEN | TILE_ELEMENT_FLAG_INDESTRUCTIBLE_TRACK_PIECE);
dst2->SetIsBroken(false);
dst2->SetIsBlockedByVehicle(false);
dst2->SetPathEntryIndex(entryIndex);
dst2->SetShouldDrawPathOverSupports(true);
@ -2121,7 +2122,7 @@ private:
entryIndex = _pathAdditionTypeToEntryMap[normalisedType];
if (additionType != normalisedType)
{
dst2->flags |= TILE_ELEMENT_FLAG_BROKEN;
dst2->SetIsBroken(true);
}
dst2->SetAddition(entryIndex + 1);
}

View File

@ -1246,7 +1246,7 @@ void ride_clear_blocked_tiles(Ride* ride)
auto footpathElement = map_get_footpath_element(x, y, element->base_height);
if (footpathElement != nullptr)
{
footpathElement->flags &= ~TILE_ELEMENT_FLAG_BLOCKED_BY_VEHICLE;
footpathElement->AsPath()->SetIsBlockedByVehicle(false);
}
}
} while (!(element++)->IsLastForTile());
@ -4530,7 +4530,7 @@ static void ride_set_block_points(CoordsXYE* startElement)
case TRACK_ELEM_DIAG_25_DEG_UP_TO_FLAT:
case TRACK_ELEM_DIAG_60_DEG_UP_TO_FLAT:
case TRACK_ELEM_BLOCK_BRAKES:
currentElement.element->flags &= ~TILE_ELEMENT_FLAG_BLOCK_BRAKE_CLOSED;
currentElement.element->AsTrack()->SetBlockBrakeClosed(false);
break;
}
} while (track_block_get_next(&currentElement, &currentElement, nullptr, nullptr)
@ -5076,7 +5076,7 @@ void loc_6DDF9C(Ride* ride, TileElement* tileElement)
do
{
tileElement->flags |= TILE_ELEMENT_FLAG_BLOCK_BRAKE_CLOSED;
tileElement->AsTrack()->SetBlockBrakeClosed(true);
car = train;
while (true)
{
@ -5094,7 +5094,7 @@ void loc_6DDF9C(Ride* ride, TileElement* tileElement)
}
} while (!(vehicle_update_track_motion(train, nullptr) & VEHICLE_UPDATE_MOTION_TRACK_FLAG_10));
tileElement->flags |= TILE_ELEMENT_FLAG_BLOCK_BRAKE_CLOSED;
tileElement->AsTrack()->SetBlockBrakeClosed(true);
car = train;
while (true)
{

View File

@ -57,7 +57,7 @@ static void ride_update_station_blocksection(Ride* ride, int32_t stationIndex)
TileElement* tileElement = ride_get_station_start_track_element(ride, stationIndex);
if ((ride->status == RIDE_STATUS_CLOSED && ride->num_riders == 0)
|| (tileElement != nullptr && tileElement->flags & TILE_ELEMENT_FLAG_BLOCK_BRAKE_CLOSED))
|| (tileElement != nullptr && tileElement->AsTrack()->BlockBrakeClosed()))
{
ride->stations[stationIndex].Depart &= ~STATION_DEPART_FLAG;

View File

@ -1015,7 +1015,7 @@ static money32 track_remove(
return MONEY32_UNDEFINED;
}
if (tileElement->flags & TILE_ELEMENT_FLAG_INDESTRUCTIBLE_TRACK_PIECE)
if (tileElement->AsTrack()->IsIndestructible())
{
gGameCommandErrorText = STR_YOU_ARE_NOT_ALLOWED_TO_REMOVE_THIS_SECTION;
return MONEY32_UNDEFINED;
@ -1718,6 +1718,40 @@ void TrackElement::SetInverted(bool inverted)
}
}
bool TrackElement::BlockBrakeClosed() const
{
return (flags & TILE_ELEMENT_FLAG_BLOCK_BRAKE_CLOSED) != 0;
}
void TrackElement::SetBlockBrakeClosed(bool isClosed)
{
if (isClosed)
{
flags |= TILE_ELEMENT_FLAG_BLOCK_BRAKE_CLOSED;
}
else
{
flags &= ~TILE_ELEMENT_FLAG_BLOCK_BRAKE_CLOSED;
}
}
bool TrackElement::IsIndestructible() const
{
return (flags & TILE_ELEMENT_FLAG_INDESTRUCTIBLE_TRACK_PIECE) != 0;
}
void TrackElement::SetIsIndestructible(bool isIndestructible)
{
if (isIndestructible)
{
flags |= TILE_ELEMENT_FLAG_INDESTRUCTIBLE_TRACK_PIECE;
}
else
{
flags &= ~TILE_ELEMENT_FLAG_INDESTRUCTIBLE_TRACK_PIECE;
}
}
uint8_t TrackElement::GetBrakeBoosterSpeed() const
{
return (sequence >> 4) << 1;

View File

@ -6656,13 +6656,13 @@ static void check_and_apply_block_section_stop_site(rct_vehicle* vehicle)
{
case TRACK_ELEM_BLOCK_BRAKES:
if (ride_is_block_sectioned(ride))
apply_block_brakes(vehicle, trackElement->flags & TILE_ELEMENT_FLAG_BLOCK_BRAKE_CLOSED);
apply_block_brakes(vehicle, trackElement->AsTrack()->BlockBrakeClosed());
else
apply_non_stop_block_brake(vehicle, true);
break;
case TRACK_ELEM_END_STATION:
if (trackElement->flags & TILE_ELEMENT_FLAG_BLOCK_BRAKE_CLOSED)
if (trackElement->AsTrack()->BlockBrakeClosed())
_vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_10;
break;
@ -6675,7 +6675,7 @@ static void check_and_apply_block_section_stop_site(rct_vehicle* vehicle)
{
if (trackType == TRACK_ELEM_CABLE_LIFT_HILL || trackElement->AsTrack()->HasChain())
{
if (trackElement->flags & TILE_ELEMENT_FLAG_BLOCK_BRAKE_CLOSED)
if (trackElement->AsTrack()->BlockBrakeClosed())
{
apply_block_brakes(vehicle, true);
}
@ -6767,7 +6767,7 @@ static void vehicle_update_block_brakes_open_previous_section(rct_vehicle* vehic
{
return;
}
tileElement->flags &= ~TILE_ELEMENT_FLAG_BLOCK_BRAKE_CLOSED;
tileElement->AsTrack()->SetBlockBrakeClosed(false);
map_invalidate_element(x, y, tileElement);
int32_t trackType = tileElement->AsTrack()->GetTrackType();
@ -7953,7 +7953,7 @@ static bool vehicle_update_track_motion_forwards_get_new_track(
{
if (vehicle->next_vehicle_on_train == SPRITE_INDEX_NULL)
{
tileElement->flags |= TILE_ELEMENT_FLAG_BLOCK_BRAKE_CLOSED;
tileElement->AsTrack()->SetBlockBrakeClosed(true);
if (trackType == TRACK_ELEM_BLOCK_BRAKES || trackType == TRACK_ELEM_END_STATION)
{
if (!(rideEntry->vehicles[0].flags & VEHICLE_ENTRY_FLAG_POWERED))
@ -9911,12 +9911,12 @@ void vehicle_update_crossings(const rct_vehicle* vehicle)
if (tileElement)
{
if (!playedClaxon && 0 == (tileElement->flags & TILE_ELEMENT_FLAG_BLOCKED_BY_VEHICLE))
if (!playedClaxon && !tileElement->AsPath()->IsBlockedByVehicle())
{
vehicle_claxon(vehicle);
}
crossingBonus = 4;
tileElement->flags |= TILE_ELEMENT_FLAG_BLOCKED_BY_VEHICLE;
tileElement->AsPath()->SetIsBlockedByVehicle(true);
}
else
{
@ -9983,7 +9983,7 @@ void vehicle_update_crossings(const rct_vehicle* vehicle)
xyElement.x / 32, xyElement.y / 32, xyElement.element->base_height);
if (tileElement)
{
tileElement->flags &= ~TILE_ELEMENT_FLAG_BLOCKED_BY_VEHICLE;
tileElement->AsPath()->SetIsBlockedByVehicle(false);
}
}
}

View File

@ -1646,7 +1646,7 @@ void junior_rc_paint_station(
{
uint32_t imageId;
bool isBraked = (bool)(tileElement->flags & TILE_ELEMENT_FLAG_BLOCK_BRAKE_CLOSED);
bool isBraked = tileElement->AsTrack()->BlockBrakeClosed();
if (direction == 0 || direction == 2)
{
@ -3693,7 +3693,7 @@ static void junior_rc_block_brake_paint_setup(
{
uint32_t image_id;
bool isBraked = (bool)(tileElement->flags & TILE_ELEMENT_FLAG_BLOCK_BRAKE_CLOSED);
bool isBraked = tileElement->AsTrack()->BlockBrakeClosed();
image_id = junior_rc_track_pieces_block_brake[isBraked][direction] | session->TrackColours[SCHEME_TRACK];
if (direction & 1)

View File

@ -633,14 +633,7 @@ static bool scenario_prepare_rides_for_save()
}
}
if (markTrackAsIndestructible)
{
it.element->flags |= TILE_ELEMENT_FLAG_INDESTRUCTIBLE_TRACK_PIECE;
}
else
{
it.element->flags &= ~TILE_ELEMENT_FLAG_INDESTRUCTIBLE_TRACK_PIECE;
}
it.element->AsTrack()->SetIsIndestructible(markTrackAsIndestructible);
}
} while (tile_element_iterator_next(&it));

View File

@ -287,9 +287,9 @@ static money32 footpath_element_insert(
if (type & FOOTPATH_ELEMENT_INSERT_QUEUE)
pathElement->SetIsQueue(true);
pathElement->SetAddition(pathItemType);
tileElement->AsPath()->SetRideIndex(RIDE_ID_NULL);
tileElement->AsPath()->SetAdditionStatus(255);
pathElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
pathElement->SetRideIndex(RIDE_ID_NULL);
pathElement->SetAdditionStatus(255);
pathElement->SetIsBroken(false);
if (flags & GAME_COMMAND_FLAG_GHOST)
pathElement->SetGhost(true);
@ -325,7 +325,7 @@ static money32 footpath_element_update(
else if (pathItemType != 0)
{
if (!(flags & GAME_COMMAND_FLAG_GHOST) && tileElement->AsPath()->GetAddition() == pathItemType
&& !(tileElement->flags & TILE_ELEMENT_FLAG_BROKEN))
&& !(tileElement->AsPath()->IsBroken()))
{
if (flags & GAME_COMMAND_FLAG_4)
return MONEY32_UNDEFINED;
@ -394,7 +394,7 @@ static money32 footpath_element_update(
}
tileElement->AsPath()->SetAddition(pathItemType);
tileElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
tileElement->AsPath()->SetIsBroken(false);
if (pathItemType != 0)
{
rct_scenery_entry* scenery_entry = get_footpath_item_entry(pathItemType - 1);
@ -423,7 +423,7 @@ static money32 footpath_element_update(
else
tileElement->AsPath()->SetIsQueue(false);
tileElement->AsPath()->SetAddition(pathItemType);
tileElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
tileElement->AsPath()->SetIsBroken(false);
loc_6A6620(flags, x, y, tileElement);
}
@ -678,13 +678,13 @@ static money32 footpath_place_from_track(
if (slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED)
pathElement->SetSloped(true);
if (type & (1 << 7))
tileElement->AsPath()->SetIsQueue(true);
pathElement->SetIsQueue(true);
pathElement->SetAddition(0);
tileElement->AsPath()->SetRideIndex(RIDE_ID_NULL);
tileElement->AsPath()->SetAdditionStatus(255);
tileElement->AsPath()->SetEdges(edges);
tileElement->AsPath()->SetCorners(0);
pathElement->flags &= ~TILE_ELEMENT_FLAG_BROKEN;
pathElement->SetRideIndex(RIDE_ID_NULL);
pathElement->SetAdditionStatus(255);
pathElement->SetEdges(edges);
pathElement->SetCorners(0);
pathElement->SetIsBroken(false);
if (flags & (1 << 6))
pathElement->SetGhost(true);
@ -2035,6 +2035,40 @@ void PathElement::SetHasQueueBanner(bool hasQueueBanner)
entryIndex |= FOOTPATH_PROPERTIES_FLAG_HAS_QUEUE_BANNER;
}
bool PathElement::IsBroken() const
{
return (flags & TILE_ELEMENT_FLAG_BROKEN) != 0;
}
void PathElement::SetIsBroken(bool isBroken)
{
if (isBroken == true)
{
flags |= TILE_ELEMENT_FLAG_BROKEN;
}
else
{
flags &= ~TILE_ELEMENT_FLAG_BROKEN;
}
}
bool PathElement::IsBlockedByVehicle() const
{
return (flags & TILE_ELEMENT_FLAG_BLOCKED_BY_VEHICLE) != 0;
}
void PathElement::SetIsBlockedByVehicle(bool isBlocked)
{
if (isBlocked == true)
{
flags |= TILE_ELEMENT_FLAG_BLOCKED_BY_VEHICLE;
}
else
{
flags &= ~TILE_ELEMENT_FLAG_BLOCKED_BY_VEHICLE;
}
}
uint8_t PathElement::GetStationIndex() const
{
return (additions & FOOTPATH_PROPERTIES_ADDITIONS_STATION_INDEX_MASK) >> 4;
@ -2399,7 +2433,7 @@ void footpath_update_path_wide_flags(int32_t x, int32_t y)
bool footpath_is_blocked_by_vehicle(const TileCoordsXYZ& position)
{
auto pathElement = map_get_path_element_at(position.x, position.y, position.z);
return pathElement != nullptr && (pathElement->flags & TILE_ELEMENT_FLAG_BLOCKED_BY_VEHICLE);
return pathElement != nullptr && pathElement->AsPath()->IsBlockedByVehicle();
}
/**

View File

@ -50,6 +50,23 @@ void LargeSceneryElement::SetBannerIndex(BannerIndex newIndex)
colour[1] |= (newIndex & 7) << 5;
}
bool LargeSceneryElement::IsAccounted() const
{
return (flags & TILE_ELEMENT_FLAG_LARGE_SCENERY_ACCOUNTED) != 0;
}
void LargeSceneryElement::SetIsAccounted(bool isAccounted)
{
if (isAccounted)
{
flags |= TILE_ELEMENT_FLAG_LARGE_SCENERY_ACCOUNTED;
}
else
{
flags &= ~TILE_ELEMENT_FLAG_LARGE_SCENERY_ACCOUNTED;
}
}
uint32_t LargeSceneryElement::GetEntryIndex() const
{
return entryIndex & TILE_ELEMENT_LARGE_TYPE_MASK;

View File

@ -2781,7 +2781,7 @@ TileElement* tile_element_insert(int32_t x, int32_t y, int32_t z, int32_t flags)
originalTileElement->base_height = 255;
originalTileElement++;
newTileElement++;
} while (!((newTileElement - 1)->flags & TILE_ELEMENT_FLAG_LAST_TILE));
} while (!((newTileElement - 1)->IsLastForTile()));
}
gNextFreeTileElement = newTileElement;

View File

@ -182,7 +182,7 @@ static bool map_animation_invalidate_small_scenery(int32_t x, int32_t y, int32_t
continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY)
continue;
if (tileElement->flags & (1 << 4))
if (tileElement->IsGhost())
continue;
sceneryEntry = tileElement->AsSmallScenery()->GetEntry();

View File

@ -462,7 +462,7 @@ void SmallSceneryElement::SetAge(uint8_t newAge)
void SmallSceneryElement::IncreaseAge(int32_t x, int32_t y)
{
if (flags & SMALL_SCENERY_FLAG_ANIMATED)
if (IsGhost())
return;
if (age < 255)

View File

@ -154,7 +154,7 @@ void SurfaceElement::UpdateGrassLength(CoordsXY coords)
TileElement* tileElementAbove = (TileElement*)this;
for (;;)
{
if (tileElementAbove->flags & TILE_ELEMENT_FLAG_LAST_TILE)
if (tileElementAbove->IsLastForTile())
{
// Grow grass

View File

@ -210,6 +210,12 @@ public:
bool HasQueueBanner() const;
void SetHasQueueBanner(bool hasQueueBanner);
bool IsBroken() const;
void SetIsBroken(bool isBroken);
bool IsBlockedByVehicle() const;
void SetIsBlockedByVehicle(bool isBlocked);
uint8_t GetEdges() const;
void SetEdges(uint8_t newEdges);
uint8_t GetCorners() const;
@ -286,6 +292,12 @@ public:
bool IsInverted() const;
void SetInverted(bool inverted);
bool BlockBrakeClosed() const;
void SetBlockBrakeClosed(bool isClosed);
bool IsIndestructible() const;
void SetIsIndestructible(bool isIndestructible);
uint8_t GetBrakeBoosterSpeed() const;
void SetBrakeBoosterSpeed(uint8_t speed);
@ -360,6 +372,9 @@ public:
BannerIndex GetBannerIndex() const;
void SetBannerIndex(BannerIndex newIndex);
bool IsAccounted() const;
void SetIsAccounted(bool isAccounted);
};
assert_struct_size(LargeSceneryElement, 8);

View File

@ -170,6 +170,11 @@ bool TileElementBase::IsGhost() const
return (this->flags & TILE_ELEMENT_FLAG_GHOST) != 0;
}
bool TrackElement::BlockBrakeClosed() const
{
return (flags & TILE_ELEMENT_FLAG_BLOCK_BRAKE_CLOSED) != 0;
}
TileElement* map_get_first_element_at(int x, int y)
{
if (x < 0 || y < 0 || x > 255 || y > 255)