mirror of https://github.com/OpenTTD/OpenTTD
(svn r13935) -Codechange [YAPP]: PBS signals can now be built with the normal signal tools. (michi_cc)
parent
5c55922a06
commit
60006ad24c
|
@ -1172,6 +1172,14 @@ STR_CONFIG_PATCHES_ALLOW_SHARES :{LTBLUE}Allow b
|
||||||
STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY :{LTBLUE}When dragging, place signals every: {ORANGE}{STRING1} tile(s)
|
STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY :{LTBLUE}When dragging, place signals every: {ORANGE}{STRING1} tile(s)
|
||||||
STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE :{LTBLUE}Automatically build semaphores before: {ORANGE}{STRING1}
|
STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE :{LTBLUE}Automatically build semaphores before: {ORANGE}{STRING1}
|
||||||
STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI :{LTBLUE}Enable the signal GUI: {ORANGE}{STRING1}
|
STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI :{LTBLUE}Enable the signal GUI: {ORANGE}{STRING1}
|
||||||
|
STR_CONFIG_PATCHES_DEFAULT_SIGNAL_TYPE :{LTBLUE}Signal type to build by default: {ORANGE}{STRING1}
|
||||||
|
STR_CONFIG_PATCHES_DEFAULT_SIGNAL_NORMAL :Normal
|
||||||
|
STR_CONFIG_PATCHES_DEFAULT_SIGNAL_PBS :Advanced
|
||||||
|
STR_CONFIG_PATCHES_DEFAULT_SIGNAL_PBSOWAY :One-way advanced
|
||||||
|
STR_CONFIG_PATCHES_CYCLE_SIGNAL_TYPES :{LTBLUE}Cycle through signal types: {ORANGE}{STRING1}
|
||||||
|
STR_CONFIG_PATCHES_CYCLE_SIGNAL_NORMAL :Normal only
|
||||||
|
STR_CONFIG_PATCHES_CYCLE_SIGNAL_PBS :Advanced only
|
||||||
|
STR_CONFIG_PATCHES_CYCLE_SIGNAL_ALL :All
|
||||||
|
|
||||||
STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID :{WHITE}The town layout "no more roads" isn't valid in the scenario editor
|
STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID :{WHITE}The town layout "no more roads" isn't valid in the scenario editor
|
||||||
STR_CONFIG_PATCHES_TOWN_LAYOUT :{LTBLUE}Select town-road layout: {ORANGE}{STRING1}
|
STR_CONFIG_PATCHES_TOWN_LAYOUT :{LTBLUE}Select town-road layout: {ORANGE}{STRING1}
|
||||||
|
|
|
@ -794,8 +794,10 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p
|
||||||
* - p1 = (bit 0-2) - track-orientation, valid values: 0-5 (Track enum)
|
* - p1 = (bit 0-2) - track-orientation, valid values: 0-5 (Track enum)
|
||||||
* - p1 = (bit 3) - 1 = override signal/semaphore, or pre/exit/combo signal or (for bit 7) toggle variant (CTRL-toggle)
|
* - p1 = (bit 3) - 1 = override signal/semaphore, or pre/exit/combo signal or (for bit 7) toggle variant (CTRL-toggle)
|
||||||
* - p1 = (bit 4) - 0 = signals, 1 = semaphores
|
* - p1 = (bit 4) - 0 = signals, 1 = semaphores
|
||||||
* - p1 = (bit 5-6) - type of the signal, for valid values see enum SignalType in rail_map.h
|
* - p1 = (bit 5-7) - type of the signal, for valid values see enum SignalType in rail_map.h
|
||||||
* - p1 = (bit 7) - convert the present signal type and variant
|
* - p1 = (bit 8) - convert the present signal type and variant
|
||||||
|
* - p1 = (bit 9-11)- start cycle from this signal type
|
||||||
|
* - p1 = (bit 12-14)-wrap around after this signal type
|
||||||
* @param p2 used for CmdBuildManySignals() to copy direction of first signal
|
* @param p2 used for CmdBuildManySignals() to copy direction of first signal
|
||||||
* TODO: p2 should be replaced by two bits for "along" and "against" the track.
|
* TODO: p2 should be replaced by two bits for "along" and "against" the track.
|
||||||
*/
|
*/
|
||||||
|
@ -804,10 +806,14 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32
|
||||||
Track track = (Track)GB(p1, 0, 3);
|
Track track = (Track)GB(p1, 0, 3);
|
||||||
bool ctrl_pressed = HasBit(p1, 3); // was the CTRL button pressed
|
bool ctrl_pressed = HasBit(p1, 3); // was the CTRL button pressed
|
||||||
SignalVariant sigvar = (ctrl_pressed ^ HasBit(p1, 4)) ? SIG_SEMAPHORE : SIG_ELECTRIC; // the signal variant of the new signal
|
SignalVariant sigvar = (ctrl_pressed ^ HasBit(p1, 4)) ? SIG_SEMAPHORE : SIG_ELECTRIC; // the signal variant of the new signal
|
||||||
SignalType sigtype = (SignalType)GB(p1, 5, 2); // the signal type of the new signal
|
SignalType sigtype = (SignalType)GB(p1, 5, 3); // the signal type of the new signal
|
||||||
bool convert_signal = HasBit(p1, 7); // convert button pressed
|
bool convert_signal = HasBit(p1, 8); // convert button pressed
|
||||||
|
SignalType cycle_start = (SignalType)GB(p1, 9, 3);
|
||||||
|
SignalType cycle_stop = (SignalType)GB(p1, 12, 3);
|
||||||
CommandCost cost;
|
CommandCost cost;
|
||||||
|
|
||||||
|
if (sigtype > SIGTYPE_LAST) return CMD_ERROR;
|
||||||
|
|
||||||
if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoTrainOnTrack(tile, track))
|
if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoTrainOnTrack(tile, track))
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
|
|
||||||
|
@ -869,7 +875,7 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32
|
||||||
if (p2 == 0) {
|
if (p2 == 0) {
|
||||||
if (!HasSignalOnTrack(tile, track)) {
|
if (!HasSignalOnTrack(tile, track)) {
|
||||||
/* build new signals */
|
/* build new signals */
|
||||||
SetPresentSignals(tile, GetPresentSignals(tile) | SignalOnTrack(track));
|
SetPresentSignals(tile, GetPresentSignals(tile) | (IsPbsSignal(sigtype) ? KillFirstBit(SignalOnTrack(track)) : SignalOnTrack(track)));
|
||||||
SetSignalType(tile, track, sigtype);
|
SetSignalType(tile, track, sigtype);
|
||||||
SetSignalVariant(tile, track, sigvar);
|
SetSignalVariant(tile, track, sigvar);
|
||||||
} else {
|
} else {
|
||||||
|
@ -886,10 +892,12 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (ctrl_pressed) {
|
} else if (ctrl_pressed) {
|
||||||
/* cycle between normal -> pre -> exit -> combo -> ... */
|
/* cycle between cycle_start and cycle_end */
|
||||||
sigtype = GetSignalType(tile, track);
|
sigtype = (SignalType)(GetSignalType(tile, track) + 1);
|
||||||
|
|
||||||
SetSignalType(tile, track, sigtype == SIGTYPE_COMBO ? SIGTYPE_NORMAL : (SignalType)(sigtype + 1));
|
if (sigtype < cycle_start || sigtype > cycle_stop) sigtype = cycle_start;
|
||||||
|
|
||||||
|
SetSignalType(tile, track, sigtype);
|
||||||
} else {
|
} else {
|
||||||
/* cycle the signal side: both -> left -> right -> both -> ... */
|
/* cycle the signal side: both -> left -> right -> both -> ... */
|
||||||
CycleSignalSide(tile, track);
|
CycleSignalSide(tile, track);
|
||||||
|
@ -902,6 +910,10 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32
|
||||||
SetSignalVariant(tile, track, sigvar);
|
SetSignalVariant(tile, track, sigvar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsPbsSignal(sigtype)) {
|
||||||
|
uint mask = GetPresentSignals(tile) & SignalOnTrack(track);
|
||||||
|
SetSignalStates(tile, (GetSignalStates(tile) & ~mask) | ((HasBit(GetTrackReservation(tile), track) ? (uint)-1 : 0) & mask));
|
||||||
|
}
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
AddTrackToSignalBuffer(tile, track, _current_player);
|
AddTrackToSignalBuffer(tile, track, _current_player);
|
||||||
YapfNotifyTrackLayoutChange(tile, track);
|
YapfNotifyTrackLayoutChange(tile, track);
|
||||||
|
|
|
@ -52,6 +52,9 @@ static bool _convert_signal_button; ///< convert signal button in the s
|
||||||
static SignalVariant _cur_signal_variant; ///< set the signal variant (for signal GUI)
|
static SignalVariant _cur_signal_variant; ///< set the signal variant (for signal GUI)
|
||||||
static SignalType _cur_signal_type; ///< set the signal type (for signal GUI)
|
static SignalType _cur_signal_type; ///< set the signal type (for signal GUI)
|
||||||
|
|
||||||
|
/* Map _patches.default_signal_type to the corresponding signal type */
|
||||||
|
static const SignalType _default_signal_type[] = {SIGTYPE_NORMAL, SIGTYPE_PBS, SIGTYPE_PBS_ONEWAY};
|
||||||
|
|
||||||
struct RailStationGUISettings {
|
struct RailStationGUISettings {
|
||||||
Axis orientation; ///< Currently selected rail station orientation
|
Axis orientation; ///< Currently selected rail station orientation
|
||||||
byte numtracks; ///< Currently selected number of tracks in station (if not \c dragdrop )
|
byte numtracks; ///< Currently selected number of tracks in station (if not \c dragdrop )
|
||||||
|
@ -218,6 +221,9 @@ static void GenericPlaceSignals(TileIndex tile)
|
||||||
} else {
|
} else {
|
||||||
const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
|
const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
|
||||||
|
|
||||||
|
/* Map _patches.cycle_signal_types to the lower and upper allowed signal type. */
|
||||||
|
static const uint cycle_bounds[] = {SIGTYPE_NORMAL | (SIGTYPE_LAST_NOPBS << 3), SIGTYPE_PBS | (SIGTYPE_LAST << 3), SIGTYPE_NORMAL | (SIGTYPE_LAST << 3)};
|
||||||
|
|
||||||
/* various bitstuffed elements for CmdBuildSingleSignal() */
|
/* various bitstuffed elements for CmdBuildSingleSignal() */
|
||||||
uint32 p1 = track;
|
uint32 p1 = track;
|
||||||
|
|
||||||
|
@ -225,13 +231,15 @@ static void GenericPlaceSignals(TileIndex tile)
|
||||||
/* signal GUI is used */
|
/* signal GUI is used */
|
||||||
SB(p1, 3, 1, _ctrl_pressed);
|
SB(p1, 3, 1, _ctrl_pressed);
|
||||||
SB(p1, 4, 1, _cur_signal_variant);
|
SB(p1, 4, 1, _cur_signal_variant);
|
||||||
SB(p1, 5, 2, _cur_signal_type);
|
SB(p1, 5, 3, _cur_signal_type);
|
||||||
SB(p1, 7, 1, _convert_signal_button);
|
SB(p1, 8, 1, _convert_signal_button);
|
||||||
|
SB(p1, 9, 6, cycle_bounds[_settings_client.gui.cycle_signal_types]);
|
||||||
} else {
|
} else {
|
||||||
SB(p1, 3, 1, _ctrl_pressed);
|
SB(p1, 3, 1, _ctrl_pressed);
|
||||||
SB(p1, 4, 1, (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
|
SB(p1, 4, 1, (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
|
||||||
SB(p1, 5, 2, SIGTYPE_NORMAL);
|
SB(p1, 5, 3, _default_signal_type[_settings_client.gui.default_signal_type]);
|
||||||
SB(p1, 7, 1, 0);
|
SB(p1, 8, 1, 0);
|
||||||
|
SB(p1, 9, 6, cycle_bounds[_settings_client.gui.cycle_signal_types]);
|
||||||
}
|
}
|
||||||
|
|
||||||
DoCommandP(tile, p1, 0, CcPlaySound1E, CMD_BUILD_SIGNALS |
|
DoCommandP(tile, p1, 0, CcPlaySound1E, CMD_BUILD_SIGNALS |
|
||||||
|
|
|
@ -1790,6 +1790,8 @@ const SettingDesc _patch_settings[] = {
|
||||||
SDTC_BOOL(gui.auto_euro, S, 0, true, STR_NULL, NULL),
|
SDTC_BOOL(gui.auto_euro, S, 0, true, STR_NULL, NULL),
|
||||||
SDTC_VAR(gui.news_message_timeout, SLE_UINT8, S, 0, 2, 1, 255, 0, STR_NULL, NULL),
|
SDTC_VAR(gui.news_message_timeout, SLE_UINT8, S, 0, 2, 1, 255, 0, STR_NULL, NULL),
|
||||||
SDTC_BOOL(gui.show_track_reservation, S, 0, false, STR_CONFIG_PATCHES_SHOW_TRACK_RESERVATION, RedrawScreen),
|
SDTC_BOOL(gui.show_track_reservation, S, 0, false, STR_CONFIG_PATCHES_SHOW_TRACK_RESERVATION, RedrawScreen),
|
||||||
|
SDTC_VAR(gui.default_signal_type, SLE_UINT8, S, MS, 0, 0, 2, 1, STR_CONFIG_PATCHES_DEFAULT_SIGNAL_TYPE, NULL),
|
||||||
|
SDTC_VAR(gui.cycle_signal_types, SLE_UINT8, S, MS, 0, 0, 2, 1, STR_CONFIG_PATCHES_CYCLE_SIGNAL_TYPES, NULL),
|
||||||
|
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
SDTC_VAR(network.sync_freq, SLE_UINT16,C|S,NO, 100, 0, 100, 0, STR_NULL, NULL),
|
SDTC_VAR(network.sync_freq, SLE_UINT16,C|S,NO, 100, 0, 100, 0, STR_NULL, NULL),
|
||||||
|
|
|
@ -627,6 +627,8 @@ static const char *_patches_construction[] = {
|
||||||
"gui.drag_signals_density",
|
"gui.drag_signals_density",
|
||||||
"game_creation.oil_refinery_limit",
|
"game_creation.oil_refinery_limit",
|
||||||
"gui.semaphore_build_before",
|
"gui.semaphore_build_before",
|
||||||
|
"gui.default_signal_type",
|
||||||
|
"gui.cycle_signal_types",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *_patches_stations[] = {
|
static const char *_patches_stations[] = {
|
||||||
|
|
|
@ -80,6 +80,8 @@ struct GUISettings {
|
||||||
int32 autorenew_money; ///< how much money before autorenewing for new companies?
|
int32 autorenew_money; ///< how much money before autorenewing for new companies?
|
||||||
byte news_message_timeout; ///< how much longer than the news message "age" should we keep the message in the history
|
byte news_message_timeout; ///< how much longer than the news message "age" should we keep the message in the history
|
||||||
bool show_track_reservation; ///< highlight reserved tracks.
|
bool show_track_reservation; ///< highlight reserved tracks.
|
||||||
|
uint8 default_signal_type; ///< the signal type to build by default.
|
||||||
|
uint8 cycle_signal_types; ///< what signal types to cycle with the build signal tool.
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Settings related to currency/unit systems. */
|
/** Settings related to currency/unit systems. */
|
||||||
|
|
Loading…
Reference in New Issue