summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormaedhros <maedhros@openttd.org>2007-01-15 22:18:35 +0000
committermaedhros <maedhros@openttd.org>2007-01-15 22:18:35 +0000
commite91bbdd491547e0e3dd90bdbb1c7a8fae8a63856 (patch)
tree0a7c7a59463925d388434ef7010b35b7d6b0f50f /src
parent8e8c72b8e14874c94fd2803df9606a1978e88aa3 (diff)
downloadopenttd-e91bbdd491547e0e3dd90bdbb1c7a8fae8a63856.tar.xz
(svn r8151) -Feature: Automatically build semaphores before a configurable date, which can be set by each network player seperately.
Diffstat (limited to 'src')
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/rail_gui.cpp18
-rw-r--r--src/settings.cpp1
-rw-r--r--src/settings_gui.cpp1
-rw-r--r--src/variables.h1
5 files changed, 20 insertions, 2 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index ca1baa8aa..044e03b72 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1117,6 +1117,7 @@ STR_CONFIG_PATCHES_ENDING_YEAR :{LTBLUE}End gam
STR_CONFIG_PATCHES_SMOOTH_ECONOMY :{LTBLUE}Enable smooth economy (more, smaller changes)
STR_CONFIG_PATCHES_ALLOW_SHARES :{LTBLUE}Allow buying shares from other companies
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_TOOLBAR_POS :{LTBLUE}Position of main toolbar: {ORANGE}{STRING1}
STR_CONFIG_PATCHES_TOOLBAR_POS_LEFT :Left
STR_CONFIG_PATCHES_TOOLBAR_POS_CENTER :Centre
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 2d08dfeab..25318676d 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -7,6 +7,7 @@
#include "table/sprites.h"
#include "table/strings.h"
#include "functions.h"
+#include "date.h"
#include "map.h"
#include "tile.h"
#include "window.h"
@@ -181,7 +182,13 @@ static void GenericPlaceSignals(TileIndex tile)
}
if (!_remove_button_clicked) {
- DoCommandP(tile, i + (_ctrl_pressed ? 8 : 0), 0, CcPlaySound1E,
+ uint32 p1 = _ctrl_pressed ? 8 : 0;
+ if (!HasSignals(tile) && _cur_year < _patches.semaphore_build_before) {
+ /* Reverse the logic, so semaphores are normally built, and light
+ * signals can be built with ctrl held down. */
+ p1 = _ctrl_pressed ? 0 : 8;
+ }
+ DoCommandP(tile, i + p1, 0, CcPlaySound1E,
CMD_BUILD_SIGNALS | CMD_AUTO | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE));
} else {
DoCommandP(tile, i, 0, CcPlaySound1E,
@@ -360,18 +367,25 @@ static void HandleAutoSignalPlacement(void)
{
TileHighlightData *thd = &_thd;
byte trackstat = thd->drawstyle & 0xF; // 0..5
+ byte semaphore = _ctrl_pressed ? 1 : 0;
if (thd->drawstyle == HT_RECT) { // one tile case
GenericPlaceSignals(TileVirtXY(thd->selend.x, thd->selend.y));
return;
}
+ if (!HasSignals(TileVirtXY(thd->selstart.x, thd->selstart.y)) && _cur_year < _patches.semaphore_build_before) {
+ /* Reverse the logic, so semaphores are normally built, and light
+ * signals can be built with ctrl held down. */
+ semaphore = _ctrl_pressed ? 0 : 1;
+ }
+
// _patches.drag_signals_density is given as a parameter such that each user in a network
// game can specify his/her own signal density
DoCommandP(
TileVirtXY(thd->selstart.x, thd->selstart.y),
TileVirtXY(thd->selend.x, thd->selend.y),
- (_ctrl_pressed ? 1 << 3 : 0) | (trackstat << 4) | (_patches.drag_signals_density << 24),
+ (semaphore << 3) | (trackstat << 4) | (_patches.drag_signals_density << 24),
CcPlaySound1E,
_remove_button_clicked ?
CMD_REMOVE_SIGNAL_TRACK | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM) :
diff --git a/src/settings.cpp b/src/settings.cpp
index 37b1b83f9..6aaddc1df 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1292,6 +1292,7 @@ const SettingDesc _patch_settings[] = {
SDT_BOOL(Patches, signal_side, N, 0, true, STR_CONFIG_PATCHES_SIGNALSIDE, RedrawScreen),
SDT_BOOL(Patches, always_small_airport, 0, 0, false, STR_CONFIG_PATCHES_SMALL_AIRPORTS, NULL),
SDT_VAR(Patches, drag_signals_density,SLE_UINT8,S, 0, 4, 1, 20, 0, STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY,NULL),
+ SDT_VAR(Patches, semaphore_build_before,SLE_INT32, S, NC, 1975, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE, NULL),
/***************************************************************************/
/* Vehicle section of the GUI-configure patches window */
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index f651334b3..10389b23d 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -585,6 +585,7 @@ static const char *_patches_construction[] = {
"always_small_airport",
"drag_signals_density",
"oil_refinery_limit",
+ "semaphore_build_before",
};
static const char *_patches_stations[] = {
diff --git a/src/variables.h b/src/variables.h
index 4a9c8cecd..049730f43 100644
--- a/src/variables.h
+++ b/src/variables.h
@@ -186,6 +186,7 @@ typedef struct Patches {
uint8 map_y;
byte drag_signals_density; // many signals density
+ Year semaphore_build_before; // Build semaphore signals automatically before this year
bool ainew_active; // Is the new AI active?
bool ai_in_multiplayer; // Do we allow AIs in multiplayer