mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-10-31 15:20:10 +00:00
Add railtype variable for adjacent crossing information
This commit is contained in:
parent
a3371fccc6
commit
ca23e31986
@ -216,6 +216,17 @@
|
|||||||
If there is no bridge above, the value is 0xFF.
|
If there is no bridge above, the value is 0xFF.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr><td>adjacent_crossing</td><td>bitmask(RAILTYPE_ADJACENT_CROSSING_XXX, ...)</td>
|
||||||
|
<td>
|
||||||
|
Adjacent level crossing information:
|
||||||
|
<dl>
|
||||||
|
<dt>SOUTH</dt>
|
||||||
|
<dd>This level crossing tile is part of a continuous adjacent crossing with the tile to the south (SW or SE)</dd>
|
||||||
|
<dt>NORTH</dt>
|
||||||
|
<dd>This level crossing tile is part of a continuous adjacent crossing with the tile to the north (NW or NE)</dd>
|
||||||
|
</dl>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<h3 id="roadtype-properties"><a href="https://newgrf-specs.tt-wiki.net/wiki/NML:Roadtypes#Roadtype_properties">Roadtype properties</a></h3>
|
<h3 id="roadtype-properties"><a href="https://newgrf-specs.tt-wiki.net/wiki/NML:Roadtypes#Roadtype_properties">Roadtype properties</a></h3>
|
||||||
<table>
|
<table>
|
||||||
|
@ -872,6 +872,16 @@
|
|||||||
</table>
|
</table>
|
||||||
</p>
|
</p>
|
||||||
<p>This is indicated by the feature name: <font face="monospace">varaction2_railtype_signal_vertical_clearance</font>, version 1</p>
|
<p>This is indicated by the feature name: <font face="monospace">varaction2_railtype_signal_vertical_clearance</font>, version 1</p>
|
||||||
|
<h4 id="railtype_adjacent_crossing">Adjacent level crossing information (mappable variable: railtype_adjacent_crossing)</h4>
|
||||||
|
<p>
|
||||||
|
<table>
|
||||||
|
<tr><th>Bit</th><th>Meaning</th></tr>
|
||||||
|
<tr><td>0</td><td>This level crossing tile is part of a continuous adjacent crossing with the tile to the south (SW or SE)</td></tr>
|
||||||
|
<tr><td>1</td><td>This level crossing tile is part of a continuous adjacent crossing with the tile to the north (NW or NE)</td></tr>
|
||||||
|
</table>
|
||||||
|
The value is 0 for non level crossing tiles.
|
||||||
|
</p>
|
||||||
|
<p>This is indicated by the feature name: <font face="monospace">varaction2_railtype_adjacent_crossing</font>, version 1</p>
|
||||||
<br />
|
<br />
|
||||||
<h3 id="varaction2_object"><a href="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Objects">Variational Action 2 - Objects</a></h3>
|
<h3 id="varaction2_object"><a href="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Objects">Variational Action 2 - Objects</a></h3>
|
||||||
<h4 id="object_foundation_tile_slope">Tile slope after foundation applied (mappable variable: object_foundation_tile_slope)</h4>
|
<h4 id="object_foundation_tile_slope">Tile slope after foundation applied (mappable variable: object_foundation_tile_slope)</h4>
|
||||||
|
@ -44,6 +44,7 @@ extern const GRFFeatureInfo _grf_feature_list[] = {
|
|||||||
GRFFeatureInfo("varaction2_railtype_signal_context", 1),
|
GRFFeatureInfo("varaction2_railtype_signal_context", 1),
|
||||||
GRFFeatureInfo("varaction2_railtype_signal_side", 1),
|
GRFFeatureInfo("varaction2_railtype_signal_side", 1),
|
||||||
GRFFeatureInfo("varaction2_railtype_signal_vertical_clearance", 1),
|
GRFFeatureInfo("varaction2_railtype_signal_vertical_clearance", 1),
|
||||||
|
GRFFeatureInfo("varaction2_railtype_adjacent_crossing", 1),
|
||||||
GRFFeatureInfo("action0_global_extra_station_names", 2),
|
GRFFeatureInfo("action0_global_extra_station_names", 2),
|
||||||
GRFFeatureInfo("action0_global_default_object_generate_amount", 1),
|
GRFFeatureInfo("action0_global_default_object_generate_amount", 1),
|
||||||
GRFFeatureInfo("action0_global_allow_rocks_in_desert", 1),
|
GRFFeatureInfo("action0_global_allow_rocks_in_desert", 1),
|
||||||
@ -175,6 +176,7 @@ extern const GRFVariableMapDefinition _grf_action2_remappable_variables[] = {
|
|||||||
GRFVariableMapDefinition(GSF_RAILTYPES, A2VRI_RAILTYPE_SIGNAL_CONTEXT, "railtype_signal_context"),
|
GRFVariableMapDefinition(GSF_RAILTYPES, A2VRI_RAILTYPE_SIGNAL_CONTEXT, "railtype_signal_context"),
|
||||||
GRFVariableMapDefinition(GSF_RAILTYPES, A2VRI_RAILTYPE_SIGNAL_SIDE, "railtype_signal_side"),
|
GRFVariableMapDefinition(GSF_RAILTYPES, A2VRI_RAILTYPE_SIGNAL_SIDE, "railtype_signal_side"),
|
||||||
GRFVariableMapDefinition(GSF_RAILTYPES, A2VRI_RAILTYPE_SIGNAL_VERTICAL_CLEARANCE, "railtype_signal_vertical_clearance"),
|
GRFVariableMapDefinition(GSF_RAILTYPES, A2VRI_RAILTYPE_SIGNAL_VERTICAL_CLEARANCE, "railtype_signal_vertical_clearance"),
|
||||||
|
GRFVariableMapDefinition(GSF_RAILTYPES, A2VRI_RAILTYPE_ADJACENT_CROSSING, "railtype_adjacent_crossing"),
|
||||||
GRFVariableMapDefinition(GSF_SIGNALS, A2VRI_SIGNALS_SIGNAL_RESTRICTION_INFO, "signals_signal_restriction_info"),
|
GRFVariableMapDefinition(GSF_SIGNALS, A2VRI_SIGNALS_SIGNAL_RESTRICTION_INFO, "signals_signal_restriction_info"),
|
||||||
GRFVariableMapDefinition(GSF_SIGNALS, A2VRI_SIGNALS_SIGNAL_CONTEXT, "signals_signal_context"),
|
GRFVariableMapDefinition(GSF_SIGNALS, A2VRI_SIGNALS_SIGNAL_CONTEXT, "signals_signal_context"),
|
||||||
GRFVariableMapDefinition(GSF_SIGNALS, A2VRI_SIGNALS_SIGNAL_STYLE, "signals_signal_style"),
|
GRFVariableMapDefinition(GSF_SIGNALS, A2VRI_SIGNALS_SIGNAL_STYLE, "signals_signal_style"),
|
||||||
|
@ -86,6 +86,7 @@ enum Action2VariableRemapIds {
|
|||||||
A2VRI_RAILTYPE_SIGNAL_CONTEXT,
|
A2VRI_RAILTYPE_SIGNAL_CONTEXT,
|
||||||
A2VRI_RAILTYPE_SIGNAL_SIDE,
|
A2VRI_RAILTYPE_SIGNAL_SIDE,
|
||||||
A2VRI_RAILTYPE_SIGNAL_VERTICAL_CLEARANCE,
|
A2VRI_RAILTYPE_SIGNAL_VERTICAL_CLEARANCE,
|
||||||
|
A2VRI_RAILTYPE_ADJACENT_CROSSING,
|
||||||
A2VRI_SIGNALS_SIGNAL_RESTRICTION_INFO,
|
A2VRI_SIGNALS_SIGNAL_RESTRICTION_INFO,
|
||||||
A2VRI_SIGNALS_SIGNAL_CONTEXT,
|
A2VRI_SIGNALS_SIGNAL_CONTEXT,
|
||||||
A2VRI_SIGNALS_SIGNAL_STYLE,
|
A2VRI_SIGNALS_SIGNAL_STYLE,
|
||||||
|
@ -108,6 +108,7 @@ static bool IsExpensiveRailtypeVariable(uint16 variable)
|
|||||||
{
|
{
|
||||||
switch (variable) {
|
switch (variable) {
|
||||||
case A2VRI_RAILTYPE_SIGNAL_VERTICAL_CLEARANCE:
|
case A2VRI_RAILTYPE_SIGNAL_VERTICAL_CLEARANCE:
|
||||||
|
case A2VRI_RAILTYPE_ADJACENT_CROSSING:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "depot_base.h"
|
#include "depot_base.h"
|
||||||
#include "town.h"
|
#include "town.h"
|
||||||
#include "signal_func.h"
|
#include "signal_func.h"
|
||||||
|
#include "road.h"
|
||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
@ -39,6 +40,7 @@
|
|||||||
case A2VRI_RAILTYPE_SIGNAL_CONTEXT: return this->signal_context;
|
case A2VRI_RAILTYPE_SIGNAL_CONTEXT: return this->signal_context;
|
||||||
case A2VRI_RAILTYPE_SIGNAL_SIDE: return GetNewSignalsSideVariable();
|
case A2VRI_RAILTYPE_SIGNAL_SIDE: return GetNewSignalsSideVariable();
|
||||||
case A2VRI_RAILTYPE_SIGNAL_VERTICAL_CLEARANCE: return 0xFF;
|
case A2VRI_RAILTYPE_SIGNAL_VERTICAL_CLEARANCE: return 0xFF;
|
||||||
|
case A2VRI_RAILTYPE_ADJACENT_CROSSING: return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,6 +68,31 @@
|
|||||||
return GetNewSignalsSideVariable();
|
return GetNewSignalsSideVariable();
|
||||||
case A2VRI_RAILTYPE_SIGNAL_VERTICAL_CLEARANCE:
|
case A2VRI_RAILTYPE_SIGNAL_VERTICAL_CLEARANCE:
|
||||||
return GetNewSignalsVerticalClearanceInfo(this->tile, this->z);
|
return GetNewSignalsVerticalClearanceInfo(this->tile, this->z);
|
||||||
|
case A2VRI_RAILTYPE_ADJACENT_CROSSING: {
|
||||||
|
if (!IsLevelCrossingTile(this->tile) || !_settings_game.vehicle.adjacent_crossings) return 0;
|
||||||
|
|
||||||
|
auto is_usable_crossing = [&](TileIndex t) -> bool {
|
||||||
|
if (HasRoadTypeRoad(t) && !HasBit(_roadtypes_non_train_colliding, GetRoadTypeRoad(t))) return true;
|
||||||
|
if (HasRoadTypeTram(t) && !HasBit(_roadtypes_non_train_colliding, GetRoadTypeTram(t))) return true;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
if (!is_usable_crossing(this->tile)) return 0;
|
||||||
|
|
||||||
|
const Axis axis = GetCrossingRoadAxis(this->tile);
|
||||||
|
const DiagDirection dir_s = AxisToDiagDir(axis);
|
||||||
|
const DiagDirection dir_n = ReverseDiagDir(dir_s);
|
||||||
|
|
||||||
|
uint32 result = 0;
|
||||||
|
auto test_dir = [&](DiagDirection dir, uint bit) {
|
||||||
|
const TileIndex t = TileAddByDiagDir(this->tile, dir);
|
||||||
|
if (t < MapSize() && IsLevelCrossingTile(t) && GetCrossingRoadAxis(t) == axis && is_usable_crossing(t)) {
|
||||||
|
SetBit(result, bit);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
test_dir(dir_s, 0);
|
||||||
|
test_dir(dir_n, 1);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(grf, 1, "Unhandled rail type tile variable 0x%X", variable);
|
DEBUG(grf, 1, "Unhandled rail type tile variable 0x%X", variable);
|
||||||
|
@ -1599,6 +1599,7 @@ static const NIVariable _niv_railtypes[] = {
|
|||||||
NIV(0x42, "level crossing status"),
|
NIV(0x42, "level crossing status"),
|
||||||
NIV(0x43, "construction date"),
|
NIV(0x43, "construction date"),
|
||||||
NIV(0x44, "town zone"),
|
NIV(0x44, "town zone"),
|
||||||
|
NIV(A2VRI_RAILTYPE_ADJACENT_CROSSING, "adjacent crossing"),
|
||||||
NIV_END()
|
NIV_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user