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

@@ -142,6 +142,7 @@
<tr><td>random_bits</td><td>0..16777215</td><td>All random bits</td></tr> <tr><td>random_bits</td><td>0..16777215</td><td>All random bits</td></tr>
<tr><td>random_bits_tile</td><td>0..255</td><td>Random bits (per tile), see also <a href="https://newgrf-specs.tt-wiki.net/wiki/NML:Stations#Base_station_variables">random_bits_station</a></td></tr> <tr><td>random_bits_tile</td><td>0..255</td><td>Random bits (per tile), see also <a href="https://newgrf-specs.tt-wiki.net/wiki/NML:Stations#Base_station_variables">random_bits_station</a></td></tr>
<tr><td>one_way_info</td><td>RST_OWI_XXX</td><td>One-way road information of drive-through stop tile<br />XXX = TWO_WAY | WEST_BOUND | EAST_BOUND | NO_ENTRY</td></tr> <tr><td>one_way_info</td><td>RST_OWI_XXX</td><td>One-way road information of drive-through stop tile<br />XXX = TWO_WAY | WEST_BOUND | EAST_BOUND | NO_ENTRY</td></tr>
<tr><td>one_way_info_inferred</td><td>RST_OWI_XXX</td><td>Inferred one-way road information of drive-through stop tile<br />XXX = TWO_WAY | WEST_BOUND | EAST_BOUND | NO_ENTRY</td></tr>
</table> </table>
<br /> <br />
Variables that require one or more parameters: Variables that require one or more parameters:

View File

@@ -309,6 +309,14 @@
2 - East-bound only<br /> 2 - East-bound only<br />
3 - No entry 3 - No entry
</td></tr> </td></tr>
<tr><td>2 - 3</td><td>
Inferred one-way road information, from examining the road layout:<br />
0 - Two-way traffic<br />
1 - West-bound only<br />
2 - East-bound only<br />
3 - No entry<br />
This requires <font face="monospace">road_stops</font>, version 8.
</td></tr>
</table> </table>
<br /> <br />
The remaining bits are reserved for future use and should be masked. The remaining bits are reserved for future use and should be masked.

View File

@@ -58,7 +58,7 @@ extern const GRFFeatureInfo _grf_feature_list[] = {
GRFFeatureInfo("action0_object_edge_foundation_mode", 2), GRFFeatureInfo("action0_object_edge_foundation_mode", 2),
GRFFeatureInfo("action0_object_flood_resistant", 1), GRFFeatureInfo("action0_object_flood_resistant", 1),
GRFFeatureInfo("action0_object_viewport_map_tile_type", 1), GRFFeatureInfo("action0_object_viewport_map_tile_type", 1),
GRFFeatureInfo("road_stops", 7), GRFFeatureInfo("road_stops", 8),
GRFFeatureInfo("new_landscape", 2), GRFFeatureInfo("new_landscape", 2),
GRFFeatureInfo("more_objects_per_grf", 1, GFTOF_MORE_OBJECTS_PER_GRF), GRFFeatureInfo("more_objects_per_grf", 1, GFTOF_MORE_OBJECTS_PER_GRF),
GRFFeatureInfo("more_action2_ids", 1, GFTOF_MORE_ACTION2_IDS), 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: { case 0x50: {
uint32 result = 0; uint32 result = 0;
if (this->tile != INVALID_TILE) { 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; 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; static bool _defer_update_road_cache_one_way_state = false;
bool _mark_tile_dirty_on_road_cache_one_way_state_update = 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) 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); DisallowedRoadDirections drd = GetOneWayRoadTileDisallowedRoadDirections(tile);
if (drd != DRD_NONE) { 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))); SetRoadCachedOneWayState(tile, (RoadCachedOneWayState)(irr ^ (HasBit(bits_to_rcows, (inbit << 2) | bit) ? 0 : 3)));
} }
_road_cache_one_way_state_pending_interpolate_tiles.erase(tile); _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); TileIndex next = InterpolateRoadFollowTileStep(tile, bit);
if (next == INVALID_TILE) return; if (next == INVALID_TILE) return;
DisallowedRoadDirections drd = GetOneWayRoadTileDisallowedRoadDirections(next); DisallowedRoadDirections drd = GetOneWayRoadTileDisallowedRoadDirections(next);