(svn r8151) -Feature: Automatically build semaphores before a configurable date, which can be set by each network player seperately.
authormaedhros
Mon, 15 Jan 2007 22:18:35 +0000
changeset 5688 c4ba40106d5d
parent 5687 5f63969a6707
child 5689 2a00c1acabc5
(svn r8151) -Feature: Automatically build semaphores before a configurable date, which can be set by each network player seperately.
src/lang/english.txt
src/rail_gui.cpp
src/settings.cpp
src/settings_gui.cpp
src/variables.h
--- a/src/lang/english.txt	Mon Jan 15 18:28:27 2007 +0000
+++ b/src/lang/english.txt	Mon Jan 15 22:18:35 2007 +0000
@@ -1117,6 +1117,7 @@
 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
--- a/src/rail_gui.cpp	Mon Jan 15 18:28:27 2007 +0000
+++ b/src/rail_gui.cpp	Mon Jan 15 22:18:35 2007 +0000
@@ -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 @@
 	}
 
 	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 @@
 {
 	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) :
--- a/src/settings.cpp	Mon Jan 15 18:28:27 2007 +0000
+++ b/src/settings.cpp	Mon Jan 15 22:18:35 2007 +0000
@@ -1292,6 +1292,7 @@
 	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 */
--- a/src/settings_gui.cpp	Mon Jan 15 18:28:27 2007 +0000
+++ b/src/settings_gui.cpp	Mon Jan 15 22:18:35 2007 +0000
@@ -585,6 +585,7 @@
 	"always_small_airport",
 	"drag_signals_density",
 	"oil_refinery_limit",
+	"semaphore_build_before",
 };
 
 static const char *_patches_stations[] = {
--- a/src/variables.h	Mon Jan 15 18:28:27 2007 +0000
+++ b/src/variables.h	Mon Jan 15 22:18:35 2007 +0000
@@ -186,6 +186,7 @@
 	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