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

pull/507/head
Jonathan G Rennison 1 year ago
parent eebb427b42
commit 48d602962f

@ -142,6 +142,7 @@
<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>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>
<br />
Variables that require one or more parameters:

@ -309,6 +309,14 @@
2 - East-bound only<br />
3 - No entry
</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>
<br />
The remaining bits are reserved for future use and should be masked.

@ -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),

@ -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;
}

@ -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);

Loading…
Cancel
Save