Remove tunnel/bridge spacing setting, use usual signal drag spacing

pull/400/head
Jonathan G Rennison 2 years ago
parent 191f710c40
commit 92723d4f5c

@ -1464,6 +1464,7 @@ static void ReReserveTrainPath(Train *v)
* - p1 = (bit 17) - 1 = don't modify an existing signal but don't fail either, 0 = always set new signal type
* - p1 = (bit 18) - permit creation of/conversion to bidirectionally signalled bridges/tunnels
* - p1 = (bit 19-22)-signal style
* - p1 = (bit 23-27)-signal spacing
* @param p2 used for CmdBuildManySignals() to copy direction of first signal
* @param text unused
* @return the cost of this operation or an error
@ -1511,6 +1512,10 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1,
CommandCost cost;
/* handle signals simulation on tunnel/bridge. */
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
int signal_spacing = GB(p1, 23, 5);
if (signal_spacing == 0) return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
signal_spacing = Clamp<int>(signal_spacing, 1, 16);
TileIndex tile_exit = GetOtherTunnelBridgeEnd(tile);
if (TracksOverlap(GetTunnelBridgeTrackBits(tile)) || TracksOverlap(GetTunnelBridgeTrackBits(tile_exit))) return_cmd_error(STR_ERROR_NO_SUITABLE_RAILROAD_TRACK);
bool bidirectional = HasBit(p1, 18) && (sigtype == SIGTYPE_PBS);
@ -1597,7 +1602,7 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (IsTunnelBridgeWithSignalSimulation(tile)) {
c->infrastructure.signal -= GetTunnelBridgeSignalSimulationSignalCount(tile, tile_exit);
} else {
uint spacing = GetBestTunnelBridgeSignalSimulationSpacing(GetTileOwner(tile), tile, tile_exit);
uint spacing = GetBestTunnelBridgeSignalSimulationSpacing(tile, tile_exit, signal_spacing);
SetTunnelBridgeSignalSimulationSpacing(tile, spacing);
SetTunnelBridgeSignalSimulationSpacing(tile_exit, spacing);
for (TileIndex t : { tile, tile_exit }) {
@ -2035,6 +2040,7 @@ static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uin
SB(param1, 5, 3, sigtype);
SB(param1, 19, 4, signal_style);
if (!remove && signal_ctr == 0) SetBit(param1, 17);
if (!remove) SB(param1, 23, 5, Clamp<int>(GB(p2, 24, 8), 1, 16));
/* Pick the correct orientation for the track direction */
signals = 0;

@ -306,6 +306,7 @@ static void GenericPlaceSignals(TileIndex tile)
SB(p1, 9, 6, cycle_types);
}
SB(p1, 18, 1, _settings_client.gui.adv_sig_bridge_tun_modes);
SB(p1, 23, 5, Clamp<int>(_settings_client.gui.drag_signals_density, 1, 16));
DoCommandP(tile, p1, 0, CMD_BUILD_SIGNALS |
CMD_MSG((w != nullptr && _convert_signal_button) ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE),

@ -3652,7 +3652,7 @@ bool AfterLoadGame()
if (SlXvIsFeaturePresent(XSLFI_SIG_TUNNEL_BRIDGE, 1, 7)) {
/* spacing setting moved to company settings */
for (Company *c : Company::Iterate()) {
c->settings.simulated_wormhole_signals = _settings_game.construction.old_simulated_wormhole_signals;
c->settings.old_simulated_wormhole_signals = _settings_game.construction.old_simulated_wormhole_signals;
}
}
if (SlXvIsFeaturePresent(XSLFI_SIG_TUNNEL_BRIDGE, 1, 8)) {
@ -3662,7 +3662,14 @@ bool AfterLoadGame()
DiagDirection dir = GetTunnelBridgeDirection(t);
if (dir == DIAGDIR_NE || dir == DIAGDIR_SE) {
TileIndex other = GetOtherTunnelBridgeEnd(t);
uint spacing = GetBestTunnelBridgeSignalSimulationSpacing(GetTileOwner(t), t, other);
Owner owner = GetTileOwner(t);
int target;
if (Company::IsValidID(owner)) {
target = Company::Get(owner)->settings.old_simulated_wormhole_signals;
} else {
target = 4;
}
uint spacing = GetBestTunnelBridgeSignalSimulationSpacing(t, other, target);
SetTunnelBridgeSignalSimulationSpacing(t, spacing);
SetTunnelBridgeSignalSimulationSpacing(other, spacing);
}

@ -89,7 +89,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
{ XSLFI_DEPARTURE_BOARDS, XSCF_IGNORABLE_UNKNOWN, 1, 1, "departure_boards", nullptr, nullptr, nullptr },
{ XSLFI_TIMETABLES_START_TICKS, XSCF_NULL, 2, 2, "timetable_start_ticks", nullptr, nullptr, nullptr },
{ XSLFI_TOWN_CARGO_ADJ, XSCF_IGNORABLE_UNKNOWN, 2, 2, "town_cargo_adj", nullptr, nullptr, nullptr },
{ XSLFI_SIG_TUNNEL_BRIDGE, XSCF_NULL, 9, 9, "signal_tunnel_bridge", nullptr, nullptr, "XBSS" },
{ XSLFI_SIG_TUNNEL_BRIDGE, XSCF_NULL, 10, 10, "signal_tunnel_bridge", nullptr, nullptr, "XBSS" },
{ XSLFI_IMPROVED_BREAKDOWNS, XSCF_NULL, 8, 8, "improved_breakdowns", nullptr, nullptr, nullptr },
{ XSLFI_CONSIST_BREAKDOWN_FLAG, XSCF_NULL, 1, 1, "consist_breakdown_flag", nullptr, nullptr, nullptr },
{ XSLFI_TT_WAIT_IN_DEPOT, XSCF_NULL, 1, 1, "tt_wait_in_depot", nullptr, nullptr, nullptr },

@ -1993,7 +1993,6 @@ static SettingsContainer &GetSettingsTree()
company->Add(new SettingEntry("company.infra_others_buy_in_depot[3]"));
company->Add(new SettingEntry("company.advance_order_on_clone"));
company->Add(new SettingEntry("company.copy_clone_add_to_group"));
company->Add(new SettingEntry("company.simulated_wormhole_signals"));
}
SettingsPage *accounting = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING));

@ -753,7 +753,8 @@ struct CompanySettings {
uint16 timetable_autofill_rounding; ///< round up timetable times to be a multiple of this number of ticks
bool advance_order_on_clone; ///< when cloning a vehicle or copying/sharing an order list, advance the current order to a suitable point
bool copy_clone_add_to_group; ///< whether to add cloned vehicles to the source vehicle's group, when cloning a vehicle without sharing orders
byte simulated_wormhole_signals; ///< tunnel/bridge signal simulation spacing
byte old_simulated_wormhole_signals; ///< no longer needs a setting: tunnel/bridge signal simulation spacing
};
/** Debug settings. */

@ -255,7 +255,7 @@ patxname = ""copy_clone_add_to_group""
[SDT_VAR]
base = CompanySettings
var = simulated_wormhole_signals
var = old_simulated_wormhole_signals
type = SLE_UINT8
flags = SF_PER_COMPANY
def = 4
@ -265,4 +265,5 @@ str = STR_CONFIG_SETTING_SIMULATE_SIGNALS
strhelp = STR_CONFIG_SETTING_SIMULATE_SIGNALS_HELPTEXT
strval = STR_CONFIG_SETTING_SIMULATE_SIGNALS_VALUE
cat = SC_ADVANCED
extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_SIG_TUNNEL_BRIDGE, 1, 9)
patxname = ""simulated_wormhole_signals""

@ -13,8 +13,7 @@
#include "map_func.h"
#include "tile_map.h"
uint GetTunnelBridgeSignalSimulationSpacingTarget(Owner owner);
uint GetBestTunnelBridgeSignalSimulationSpacing(Owner owner, TileIndex begin, TileIndex end);
uint GetBestTunnelBridgeSignalSimulationSpacing(TileIndex begin, TileIndex end, int target);
uint GetTunnelBridgeSignalSimulationSignalCount(TileIndex begin, TileIndex end);
void MarkTunnelBridgeSignalDirty(TileIndex tile, bool exit);

@ -134,18 +134,8 @@ void MarkBridgeOrTunnelDirtyOnReservationChange(TileIndex tile, ViewportMarkDirt
}
}
uint GetTunnelBridgeSignalSimulationSpacingTarget(Owner owner)
uint GetBestTunnelBridgeSignalSimulationSpacing(TileIndex begin, TileIndex end, int target)
{
if (Company::IsValidID(owner)) {
return Company::Get(owner)->settings.simulated_wormhole_signals;
} else {
return 4;
}
}
uint GetBestTunnelBridgeSignalSimulationSpacing(Owner owner, TileIndex begin, TileIndex end)
{
int target = GetTunnelBridgeSignalSimulationSpacingTarget(owner);
if (target <= 2) return target;
int length = GetTunnelBridgeLength(begin, end);
if (target > length || ((length + 1) % target) == 0) return target;

Loading…
Cancel
Save