From 07a43863c4d5a578bcdc68697140678edb84c524 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 2 Aug 2008 22:49:39 +0000 Subject: (svn r13936) -Codechange [YAPP]: Enable the auto-signal tool to build PBS signals and honor the default signal type. (michi_cc) --- src/rail_cmd.cpp | 12 +++++++++++- src/rail_gui.cpp | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index a7d9bd4f2..a983857f5 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -908,6 +908,7 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 * direction of the first signal given as parameter by CmdBuildManySignals */ SetPresentSignals(tile, (GetPresentSignals(tile) & ~SignalOnTrack(track)) | (p2 & SignalOnTrack(track))); SetSignalVariant(tile, track, sigvar); + SetSignalType(tile, track, sigtype); } if (IsPbsSignal(sigtype)) { @@ -987,6 +988,7 @@ static bool CheckSignalAutoFill(TileIndex &tile, Trackdir &trackdir, int &signal * - p2 = (bit 4) - 0 = signals, 1 = semaphores * - p2 = (bit 5) - 0 = build, 1 = remove signals * - p2 = (bit 6) - 0 = selected stretch, 1 = auto fill + * - p2 = (bit 7- 9) - default signal type * - p2 = (bit 24-31) - user defined signals_density */ static CommandCost CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) @@ -1024,6 +1026,9 @@ static CommandCost CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, /* Autofill must start on a valid track to be able to avoid loops */ if (autofill && !HasTrack(tile, track)) return CMD_ERROR; + SignalType sigtype = (SignalType)GB(p2, 7, 3); + if (sigtype > SIGTYPE_LAST) return CMD_ERROR; + /* copy the signal-style of the first rail-piece if existing */ if (HasSignals(tile)) { signals = GetPresentSignals(tile) & SignalOnTrack(track); @@ -1031,8 +1036,10 @@ static CommandCost CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, /* copy signal/semaphores style (independent of CTRL) */ semaphores = GetSignalVariant(tile, track) != SIG_ELECTRIC; + + sigtype = GetSignalType(tile, track); } else { // no signals exist, drag a two-way signal stretch - signals = SignalOnTrack(track); + signals = IsPbsSignal(sigtype) ? SignalAlongTrackdir(trackdir) : SignalOnTrack(track); } byte signal_dir = 0; @@ -1054,6 +1061,7 @@ static CommandCost CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p1 = GB(TrackdirToTrack(trackdir), 0, 3); SB(p1, 3, 1, mode); SB(p1, 4, 1, semaphores); + SB(p1, 5, 3, sigtype); /* Pick the correct orientation for the track direction */ signals = 0; @@ -1103,6 +1111,7 @@ static CommandCost CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, * - p2 = (bit 4) - 0 = signals, 1 = semaphores * - p2 = (bit 5) - 0 = build, 1 = remove signals * - p2 = (bit 6) - 0 = selected stretch, 1 = auto fill + * - p2 = (bit 7- 9) - default signal type * - p2 = (bit 24-31) - user defined signals_density * @see CmdSignalTrackHelper */ @@ -1166,6 +1175,7 @@ CommandCost CmdRemoveSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint3 * - p2 = (bit 4) - 0 = signals, 1 = semaphores * - p2 = (bit 5) - 0 = build, 1 = remove signals * - p2 = (bit 6) - 0 = selected stretch, 1 = auto fill + * - p2 = (bit 7- 9) - default signal type * - p2 = (bit 24-31) - user defined signals_density * @see CmdSignalTrackHelper */ diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index ee4decb59..3b5d9dfde 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -557,11 +557,13 @@ static void HandleAutoSignalPlacement() SB(p2, 3, 1, 0); SB(p2, 4, 1, _cur_signal_variant); SB(p2, 6, 1, _ctrl_pressed); + SB(p2, 7, 3, _cur_signal_type); SB(p2, 24, 8, _settings_client.gui.drag_signals_density); } else { SB(p2, 3, 1, 0); SB(p2, 4, 1, (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC)); SB(p2, 6, 1, _ctrl_pressed); + SB(p2, 7, 3, _default_signal_type[_settings_client.gui.default_signal_type]); SB(p2, 24, 8, _settings_client.gui.drag_signals_density); } -- cgit v1.2.3-70-g09d2