From 68814bd912e8688d4fadbb27993ce77beea2c5cb Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Mon, 15 Jan 2024 15:27:48 -0500 Subject: [PATCH] Codechange: Rename SIGTYPE_NORMAL to SIGTYPE_BLOCK (#11788) --- src/pathfinder/yapf/yapf_costrail.hpp | 2 +- src/pathfinder/yapf/yapf_node_rail.hpp | 2 +- src/rail_cmd.cpp | 16 ++++++++-------- src/rail_gui.cpp | 4 ++-- src/script/api/script_rail.cpp | 2 +- src/script/api/script_rail.hpp | 2 +- src/signal_type.h | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/pathfinder/yapf/yapf_costrail.hpp b/src/pathfinder/yapf/yapf_costrail.hpp index 0ce9e478de..5781efce97 100644 --- a/src/pathfinder/yapf/yapf_costrail.hpp +++ b/src/pathfinder/yapf/yapf_costrail.hpp @@ -217,7 +217,7 @@ public: switch (sig_type) { case SIGTYPE_COMBO: case SIGTYPE_EXIT: cost += Yapf().PfGetSettings().rail_firstred_exit_penalty; break; // first signal is red pre-signal-exit - case SIGTYPE_NORMAL: + case SIGTYPE_BLOCK: case SIGTYPE_ENTRY: cost += Yapf().PfGetSettings().rail_firstred_penalty; break; default: break; } diff --git a/src/pathfinder/yapf/yapf_node_rail.hpp b/src/pathfinder/yapf/yapf_node_rail.hpp index 9185009df6..7309fa02d2 100644 --- a/src/pathfinder/yapf/yapf_node_rail.hpp +++ b/src/pathfinder/yapf/yapf_node_rail.hpp @@ -142,7 +142,7 @@ struct CYapfRailNodeT if (parent == nullptr) { m_num_signals_passed = 0; flags_u.m_inherited_flags = 0; - m_last_red_signal_type = SIGTYPE_NORMAL; + m_last_red_signal_type = SIGTYPE_BLOCK; /* We use PBS as initial signal type because if we are in * a PBS section and need to route, i.e. we're at a safe * waiting point of a station, we need to account for the diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 2689f7f170..c59b195551 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -103,7 +103,7 @@ void ResolveRailTypeGUISprites(RailTypeInfo *rti) SPR_IMG_SIGNAL_SEMAPHORE_COMBO, SPR_IMG_SIGNAL_SEMAPHORE_PBS, SPR_IMG_SIGNAL_SEMAPHORE_PBS_OWAY}, }; - for (SignalType type = SIGTYPE_NORMAL; type < SIGTYPE_END; type = (SignalType)(type + 1)) { + for (SignalType type = SIGTYPE_BLOCK; type < SIGTYPE_END; type = (SignalType)(type + 1)) { for (SignalVariant var = SIG_ELECTRIC; var <= SIG_SEMAPHORE; var = (SignalVariant)(var + 1)) { SpriteID red = GetCustomSignalSprite(rti, INVALID_TILE, type, var, SIGNAL_STATE_RED, true); SpriteID green = GetCustomSignalSprite(rti, INVALID_TILE, type, var, SIGNAL_STATE_GREEN, true); @@ -1088,15 +1088,15 @@ CommandCost CmdBuildSingleSignal(DoCommandFlag flags, TileIndex tile, Track trac } else if (convert_signal) { /* convert button pressed */ if (ctrl_pressed || GetSignalVariant(tile, track) != sigvar) { - /* convert electric <-> semaphore */ + /* it costs money to change signal variant (light or semaphore) */ cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_SIGNALS] + _price[PR_CLEAR_SIGNALS]); } else { - /* it is free to change signal type: normal-pre-exit-combo */ + /* it is free to change signal type (block, exit, entry, combo, path, etc) */ cost = CommandCost(); } } else { - /* it is free to change orientation/pre-exit-combo signals */ + /* it is free to change orientation or number of signals on the tile (for block/presignals which allow signals in both directions) */ cost = CommandCost(); } } @@ -1290,7 +1290,7 @@ static CommandCost CmdSignalTrackHelper(DoCommandFlag flags, TileIndex tile, Til sigtype = GetSignalType(tile, track); /* Don't but copy entry or exit-signal type */ - if (sigtype == SIGTYPE_ENTRY || sigtype == SIGTYPE_EXIT) sigtype = SIGTYPE_NORMAL; + if (sigtype == SIGTYPE_ENTRY || sigtype == SIGTYPE_EXIT) sigtype = SIGTYPE_BLOCK; } else { // no signals exist, drag a two-way signal stretch signals = IsPbsSignal(sigtype) ? SignalAlongTrackdir(trackdir) : SignalOnTrack(track); } @@ -1325,7 +1325,7 @@ static CommandCost CmdSignalTrackHelper(DoCommandFlag flags, TileIndex tile, Til if (HasBit(signal_dir, 1)) signals |= SignalAgainstTrackdir(trackdir); DoCommandFlag do_flags = test_only ? flags & ~DC_EXEC : flags; - CommandCost ret = remove ? Command::Do(do_flags, tile, TrackdirToTrack(trackdir)) : Command::Do(do_flags, tile, TrackdirToTrack(trackdir), sigtype, sigvar, false, signal_ctr == 0, mode, SIGTYPE_NORMAL, SIGTYPE_NORMAL, 0, signals); + CommandCost ret = remove ? Command::Do(do_flags, tile, TrackdirToTrack(trackdir)) : Command::Do(do_flags, tile, TrackdirToTrack(trackdir), sigtype, sigvar, false, signal_ctr == 0, mode, SIGTYPE_BLOCK, SIGTYPE_BLOCK, 0, signals); if (test_only) return ret.Succeeded(); @@ -1526,7 +1526,7 @@ CommandCost CmdRemoveSingleSignal(DoCommandFlag flags, TileIndex tile, Track tra */ CommandCost CmdRemoveSignalTrack(DoCommandFlag flags, TileIndex tile, TileIndex end_tile, Track track, bool autofill) { - return CmdSignalTrackHelper(flags, tile, end_tile, track, SIGTYPE_NORMAL, SIG_ELECTRIC, false, true, autofill, false, 1); // bit 5 is remove bit + return CmdSignalTrackHelper(flags, tile, end_tile, track, SIGTYPE_BLOCK, SIG_ELECTRIC, false, true, autofill, false, 1); // bit 5 is remove bit } /** Update power of train under which is the railtype being converted */ @@ -1901,7 +1901,7 @@ static void DrawSingleSignal(TileIndex tile, const RailTypeInfo *rti, Track trac sprite += image; } else { /* Normal electric signals are stored in a different sprite block than all other signals. */ - sprite = (type == SIGTYPE_NORMAL && variant == SIG_ELECTRIC) ? SPR_ORIGINAL_SIGNALS_BASE : SPR_SIGNALS_BASE - 16; + sprite = (type == SIGTYPE_BLOCK && variant == SIG_ELECTRIC) ? SPR_ORIGINAL_SIGNALS_BASE : SPR_SIGNALS_BASE - 16; sprite += type * 16 + variant * 64 + image * 2 + condition + (type > SIGTYPE_LAST_NOPBS ? 64 : 0); } diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 2f19b82205..7ed5e2159c 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -241,7 +241,7 @@ static void GenericPlaceSignals(TileIndex tile) Command::Post(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM, CcPlaySound_CONSTRUCTION_RAIL, tile, track); } else { /* Which signals should we cycle through? */ - SignalType cycle_start = _settings_client.gui.cycle_signal_types == SIGNAL_CYCLE_ALL && _settings_client.gui.signal_gui_mode == SIGNAL_GUI_ALL ? SIGTYPE_NORMAL : SIGTYPE_PBS; + SignalType cycle_start = _settings_client.gui.cycle_signal_types == SIGNAL_CYCLE_ALL && _settings_client.gui.signal_gui_mode == SIGNAL_GUI_ALL ? SIGTYPE_BLOCK : SIGTYPE_PBS; if (FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr) { /* signal GUI is used */ @@ -1695,7 +1695,7 @@ public: this->sig_sprite_size.height = 0; this->sig_sprite_bottom_offset = 0; const RailTypeInfo *rti = GetRailTypeInfo(_cur_railtype); - for (uint type = SIGTYPE_NORMAL; type < SIGTYPE_END; type++) { + for (uint type = SIGTYPE_BLOCK; type < SIGTYPE_END; type++) { for (uint variant = SIG_ELECTRIC; variant <= SIG_SEMAPHORE; variant++) { for (uint lowered = 0; lowered < 2; lowered++) { Point offset; diff --git a/src/script/api/script_rail.cpp b/src/script/api/script_rail.cpp index 3caf070509..88f88e6048 100644 --- a/src/script/api/script_rail.cpp +++ b/src/script/api/script_rail.cpp @@ -469,7 +469,7 @@ static bool IsValidSignalType(int signal_type) } ::SignalType sig_type = (::SignalType)(signal >= SIGNALTYPE_TWOWAY ? signal ^ SIGNALTYPE_TWOWAY : signal); - return ScriptObject::Command::Do(tile, track, sig_type, ::SIG_ELECTRIC, false, false, false, ::SIGTYPE_NORMAL, ::SIGTYPE_NORMAL, signal_cycles, 0); + return ScriptObject::Command::Do(tile, track, sig_type, ::SIG_ELECTRIC, false, false, false, ::SIGTYPE_BLOCK, ::SIGTYPE_BLOCK, signal_cycles, 0); } /* static */ bool ScriptRail::RemoveSignal(TileIndex tile, TileIndex front) diff --git a/src/script/api/script_rail.hpp b/src/script/api/script_rail.hpp index 31425721e6..da0edb04c0 100644 --- a/src/script/api/script_rail.hpp +++ b/src/script/api/script_rail.hpp @@ -64,7 +64,7 @@ public: */ enum SignalType { /* Note: these values represent part of the in-game SignalType enum */ - SIGNALTYPE_NORMAL = ::SIGTYPE_NORMAL, ///< Normal signal. + SIGNALTYPE_NORMAL = ::SIGTYPE_BLOCK, ///< Block signal. SIGNALTYPE_ENTRY = ::SIGTYPE_ENTRY, ///< Entry presignal. SIGNALTYPE_EXIT = ::SIGTYPE_EXIT, ///< Exit signal. SIGNALTYPE_COMBO = ::SIGTYPE_COMBO, ///< Combo signal. diff --git a/src/signal_type.h b/src/signal_type.h index b28c9ef108..e29d2d65b6 100644 --- a/src/signal_type.h +++ b/src/signal_type.h @@ -21,7 +21,7 @@ enum SignalVariant : byte { /** Type of signal, i.e. how does the signal behave? */ enum SignalType : byte { - SIGTYPE_NORMAL = 0, ///< normal signal + SIGTYPE_BLOCK = 0, ///< block signal SIGTYPE_ENTRY = 1, ///< presignal block entry SIGTYPE_EXIT = 2, ///< presignal block exit SIGTYPE_COMBO = 3, ///< presignal inter-block