diff --git a/docs/newgrf-roadstops-nml.html b/docs/newgrf-roadstops-nml.html index 269005cace..2738eb0e9b 100644 --- a/docs/newgrf-roadstops-nml.html +++ b/docs/newgrf-roadstops-nml.html @@ -142,6 +142,7 @@ random_bits0..16777215All random bits random_bits_tile0..255Random bits (per tile), see also random_bits_station one_way_infoRST_OWI_XXXOne-way road information of drive-through stop tile
XXX = TWO_WAY | WEST_BOUND | EAST_BOUND | NO_ENTRY + one_way_info_inferredRST_OWI_XXXInferred one-way road information of drive-through stop tile
XXX = TWO_WAY | WEST_BOUND | EAST_BOUND | NO_ENTRY
Variables that require one or more parameters: diff --git a/docs/newgrf-roadstops.html b/docs/newgrf-roadstops.html index e5647c94bc..25d1eeb5d9 100644 --- a/docs/newgrf-roadstops.html +++ b/docs/newgrf-roadstops.html @@ -309,6 +309,14 @@ 2 - East-bound only
3 - No entry + 2 - 3 + Inferred one-way road information, from examining the road layout:
+ 0 - Two-way traffic
+ 1 - West-bound only
+ 2 - East-bound only
+ 3 - No entry
+ This requires road_stops, version 8. +
The remaining bits are reserved for future use and should be masked. diff --git a/src/newgrf_extension.cpp b/src/newgrf_extension.cpp index a8d9d7f7d2..6be3e8570d 100644 --- a/src/newgrf_extension.cpp +++ b/src/newgrf_extension.cpp @@ -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), diff --git a/src/newgrf_roadstop.cpp b/src/newgrf_roadstop.cpp index 8ad2870ff0..35e0b7d243 100644 --- a/src/newgrf_roadstop.cpp +++ b/src/newgrf_roadstop.cpp @@ -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; } diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 924b15c90e..8a7e45acf0 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -259,9 +259,21 @@ static btree::btree_set _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);