Road stops: Add inferred one way road state to var 50/roadstop_misc_info

This commit is contained in:
Jonathan G Rennison
2023-03-15 19:10:34 +00:00
parent eebb427b42
commit 48d602962f
5 changed files with 29 additions and 4 deletions

View File

@@ -58,7 +58,7 @@ extern const GRFFeatureInfo _grf_feature_list[] = {
GRFFeatureInfo("action0_object_edge_foundation_mode", 2),
GRFFeatureInfo("action0_object_flood_resistant", 1),
GRFFeatureInfo("action0_object_viewport_map_tile_type", 1),
GRFFeatureInfo("road_stops", 7),
GRFFeatureInfo("road_stops", 8),
GRFFeatureInfo("new_landscape", 2),
GRFFeatureInfo("more_objects_per_grf", 1, GFTOF_MORE_OBJECTS_PER_GRF),
GRFFeatureInfo("more_action2_ids", 1, GFTOF_MORE_ACTION2_IDS),

View File

@@ -159,7 +159,11 @@ uint32 RoadStopScopeResolver::GetVariable(uint16 variable, uint32 parameter, Get
case 0x50: {
uint32 result = 0;
if (this->tile != INVALID_TILE) {
if (IsDriveThroughStopTile(this->tile)) result |= GetDriveThroughStopDisallowedRoadDirections(this->tile);
if (IsDriveThroughStopTile(this->tile)) {
result |= GetDriveThroughStopDisallowedRoadDirections(this->tile);
RoadCachedOneWayState rcows = GetRoadCachedOneWayState(this->tile);
if (rcows <= RCOWS_NO_ACCESS) result |= (rcows << 2);
}
}
return result;
}

View File

@@ -259,9 +259,21 @@ static btree::btree_set<TileIndex> _road_cache_one_way_state_pending_interpolate
static bool _defer_update_road_cache_one_way_state = false;
bool _mark_tile_dirty_on_road_cache_one_way_state_update = false;
static void RefreshTileOnCachedOneWayStateChange(TileIndex tile)
{
if (IsAnyRoadStopTile(tile) && IsCustomRoadStopSpecIndex(tile)) {
MarkTileGroundDirtyByTile(tile, VMDF_NOT_MAP_MODE);
return;
}
if (unlikely(_mark_tile_dirty_on_road_cache_one_way_state_update)) {
MarkTileGroundDirtyByTile(tile, VMDF_NOT_MAP_MODE);
return;
}
}
static void UpdateTileRoadCachedOneWayState(TileIndex tile)
{
if (unlikely(_mark_tile_dirty_on_road_cache_one_way_state_update)) MarkTileGroundDirtyByTile(tile, VMDF_NOT_MAP_MODE);
RefreshTileOnCachedOneWayStateChange(tile);
DisallowedRoadDirections drd = GetOneWayRoadTileDisallowedRoadDirections(tile);
if (drd != DRD_NONE) {
@@ -364,7 +376,7 @@ static void InterpolateRoadFollowRoadBitSetState(TileIndex tile, uint8 bit, Inte
SetRoadCachedOneWayState(tile, (RoadCachedOneWayState)(irr ^ (HasBit(bits_to_rcows, (inbit << 2) | bit) ? 0 : 3)));
}
_road_cache_one_way_state_pending_interpolate_tiles.erase(tile);
if (unlikely(_mark_tile_dirty_on_road_cache_one_way_state_update)) MarkTileGroundDirtyByTile(tile, VMDF_NOT_MAP_MODE);
RefreshTileOnCachedOneWayStateChange(tile);
TileIndex next = InterpolateRoadFollowTileStep(tile, bit);
if (next == INVALID_TILE) return;
DisallowedRoadDirections drd = GetOneWayRoadTileDisallowedRoadDirections(next);