summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--elrail.c57
-rw-r--r--gui.h3
-rw-r--r--lang/american.txt1
-rw-r--r--lang/brazilian_portuguese.txt1
-rw-r--r--lang/catalan.txt1
-rw-r--r--lang/czech.txt1
-rw-r--r--lang/danish.txt1
-rw-r--r--lang/dutch.txt1
-rw-r--r--lang/english.txt2
-rw-r--r--lang/estonian.txt1
-rw-r--r--lang/finnish.txt1
-rw-r--r--lang/french.txt1
-rw-r--r--lang/german.txt1
-rw-r--r--lang/hungarian.txt1
-rw-r--r--lang/icelandic.txt1
-rw-r--r--lang/italian.txt1
-rw-r--r--lang/norwegian.txt1
-rw-r--r--lang/polish.txt1
-rw-r--r--lang/portuguese.txt1
-rw-r--r--lang/romanian.txt1
-rw-r--r--lang/slovak.txt1
-rw-r--r--lang/spanish.txt1
-rw-r--r--lang/swedish.txt1
-rw-r--r--lang/turkish.txt1
-rw-r--r--main_gui.c3
-rw-r--r--misc_gui.c13
-rw-r--r--openttd.c16
-rw-r--r--rail.h3
-rw-r--r--rail_cmd.c3
-rw-r--r--rail_gui.c18
-rw-r--r--road_cmd.c3
-rw-r--r--saveload.c2
-rw-r--r--settings.c2
-rw-r--r--settings_gui.c1
-rw-r--r--station_cmd.c3
-rw-r--r--train_cmd.c7
-rw-r--r--tunnelbridge_cmd.c3
-rw-r--r--variables.h3
-rw-r--r--vehicle.h3
39 files changed, 127 insertions, 39 deletions
diff --git a/elrail.c b/elrail.c
index 9d2f92d32..a1a48bceb 100644
--- a/elrail.c
+++ b/elrail.c
@@ -61,6 +61,9 @@
#include "rail_map.h"
#include "table/sprites.h"
#include "table/elrail_data.h"
+#include "vehicle.h"
+#include "train.h"
+#include "gui.h"
static inline TLG GetTLG(TileIndex t)
{
@@ -360,6 +363,8 @@ static void DrawCatenaryOnBridge(const TileInfo *ti)
void DrawCatenary(const TileInfo *ti)
{
+ if (_patches.disable_elrails) return;
+
switch (GetTileType(ti->tile)) {
case MP_RAILWAY:
if (IsRailDepot(ti->tile)) {
@@ -385,3 +390,55 @@ void DrawCatenary(const TileInfo *ti)
}
DrawCatenaryRailway(ti);
}
+
+int32 SettingsDisableElrail(int32 p1)
+{
+ EngineID e_id;
+ Vehicle* v;
+ Player *p;
+ bool disable = (p1 != 0);
+
+ /* we will now walk through all electric train engines and change their railtypes if it is the wrong one*/
+ const RailType old_railtype = disable ? RAILTYPE_ELECTRIC : RAILTYPE_RAIL;
+ const RailType new_railtype = disable ? RAILTYPE_RAIL : RAILTYPE_ELECTRIC;
+
+ /* walk through all train engines */
+ for (e_id = 0; e_id < NUM_TRAIN_ENGINES; e_id++)
+ {
+ const RailVehicleInfo *rv_info = RailVehInfo(e_id);
+ Engine *e = GetEngine(e_id);
+ /* if it is an electric rail engine and its railtype is the wrong one */
+ if (rv_info->engclass == 2 && e->railtype == old_railtype) {
+ /* change it to the proper one */
+ e->railtype = new_railtype;
+ }
+ }
+
+ /* when disabling elrails, make sure that all existing trains can run on
+ * normal rail too */
+ if (disable) {
+ FOR_ALL_VEHICLES(v) {
+ if (v->type == VEH_Train && v->u.rail.railtype == RAILTYPE_ELECTRIC) {
+ /* this railroad vehicle is now compatible only with elrail,
+ * so add there also normal rail compatibility */
+ v->u.rail.compatible_railtypes |= (1 << RAILTYPE_RAIL);
+ v->u.rail.railtype = RAILTYPE_RAIL;
+ SETBIT(v->u.rail.flags, VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL);
+ }
+ }
+ }
+
+ /* setup total power for trains */
+ FOR_ALL_VEHICLES(v) {
+ /* power is cached only for front engines */
+ if (v->type == VEH_Train && IsFrontEngine(v)) TrainPowerChanged(v);
+ }
+
+ FOR_ALL_PLAYERS(p) p->avail_railtypes = GetPlayerRailtypes(p->index);
+
+ /* This resets the _last_built_railtype, which will be invalid for electric
+ * rails. It may have unintended consequences if that function is ever
+ * extended, though. */
+ ReinitGuiAfterToggleElrail(disable);
+ return 0;
+}
diff --git a/gui.h b/gui.h
index 376a969aa..dfa4313fa 100644
--- a/gui.h
+++ b/gui.h
@@ -35,9 +35,10 @@ void ShowLastNewsMessage(void);
void ShowMessageOptions(void);
void ShowMessageHistory(void);
-/* traintoolb_gui.c */
+/* rail_gui.c */
void ShowBuildRailToolbar(RailType railtype, int button);
void PlaceProc_BuyLand(TileIndex tile);
+void ReinitGuiAfterToggleElrail(bool disable);
/* train_gui.c */
void ShowTrainViewWindow(const Vehicle *v);
diff --git a/lang/american.txt b/lang/american.txt
index 1f7ca6748..3d4b94e43 100644
--- a/lang/american.txt
+++ b/lang/american.txt
@@ -1140,7 +1140,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Jetplan
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Switch climate: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Change date: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Enable modifying production values: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Allow electric engines to run on normal rail
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Heading for {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Heading for {WAYPOINT}, {VELOCITY}
diff --git a/lang/brazilian_portuguese.txt b/lang/brazilian_portuguese.txt
index fdd17536e..63951a65d 100644
--- a/lang/brazilian_portuguese.txt
+++ b/lang/brazilian_portuguese.txt
@@ -1140,7 +1140,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Aviões
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Mudar de clima: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Alterar data: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Ativar modificação de valores de produção: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Permite Trens elétricos em trilho normal
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Dirigindo-se para {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Dirigindo-se para {WAYPOINT}, {VELOCITY}
diff --git a/lang/catalan.txt b/lang/catalan.txt
index 694d817d6..8f11a8dca 100644
--- a/lang/catalan.txt
+++ b/lang/catalan.txt
@@ -1140,7 +1140,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Els avi
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Canviar clima: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Canviar data: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Activar modificació de valors de producció: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Deixar que els trens elèctrics circulin per rails normals
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Cap a {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Cap a {WAYPOINT}, a {VELOCITY}
diff --git a/lang/czech.txt b/lang/czech.txt
index c61277ee8..1cf0b9961 100644
--- a/lang/czech.txt
+++ b/lang/czech.txt
@@ -1197,7 +1197,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Letadla
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Zmenit podnebí: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Zmenit datum: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Povolit zmenu produkce prumyslu: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Povolit elektrickým lokomotivám vyjet na normální koleje
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Mirim do {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Mirim do {WAYPOINT}, {VELOCITY}
diff --git a/lang/danish.txt b/lang/danish.txt
index a11bb3bf0..c9694c979 100644
--- a/lang/danish.txt
+++ b/lang/danish.txt
@@ -1140,7 +1140,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Jetfly
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Skift klima: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Ændre dato: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Aktiver modifikation af produktion: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Tillad elektriske tog at køre på almindelige skinner
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Retning mod {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Retning mod {WAYPOINT}, {VELOCITY}
diff --git a/lang/dutch.txt b/lang/dutch.txt
index 9cdd73b03..26e5620f2 100644
--- a/lang/dutch.txt
+++ b/lang/dutch.txt
@@ -1142,7 +1142,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Jetvlie
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Verander klimaat: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Verander datum: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Sta aanpassen productiewaarden toe: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Sta elektrische locomotieven toe op normale rails
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Op weg naar {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Op weg naar {WAYPOINT}, {VELOCITY}
diff --git a/lang/english.txt b/lang/english.txt
index 38feece2b..e8aee74b0 100644
--- a/lang/english.txt
+++ b/lang/english.txt
@@ -1095,6 +1095,7 @@ STR_CONFIG_PATCHES_SERVINT_SHIPS :{LTBLUE}Default
STR_CONFIG_PATCHES_SERVINT_SHIPS_DISABLED :{LTBLUE}Default service interval for ships: {ORANGE}disabled
STR_CONFIG_PATCHES_NOSERVICE :{LTBLUE}Disable servicing when breakdowns set to none: {ORANGE}{STRING1}
STR_CONFIG_PATCHES_WAGONSPEEDLIMITS :{LTBLUE}Enable wagon speed limits: {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_DISABLE_ELRAILS :{LTBLUE}Disable electric rails: {ORANGE}{STRING1}
STR_CONFIG_PATCHES_COLORED_NEWS_YEAR :{LTBLUE}Coloured news appears in: {ORANGE}{STRING1}
STR_CONFIG_PATCHES_STARTING_YEAR :{LTBLUE}Starting year: {ORANGE}{STRING1}
@@ -1143,7 +1144,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Jetplan
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Switch climate: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Change date: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Enable modifying production values: {ORANGE}{STRING1}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Allow electric engines to run on normal rail
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Heading for {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Heading for {WAYPOINT}, {VELOCITY}
diff --git a/lang/estonian.txt b/lang/estonian.txt
index a0ad2f9ec..f58a8fdc3 100644
--- a/lang/estonian.txt
+++ b/lang/estonian.txt
@@ -1197,7 +1197,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Reaktii
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Vaheta kliimat: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Muuda kuupäeva: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Luba muutuvad tootmisväärtused: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Luba elektrirongidel sõita tavalisel raudteel
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Suudub kontrollpunti: {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Suundub {WAYPOINT}, {VELOCITY}
diff --git a/lang/finnish.txt b/lang/finnish.txt
index 32299f69a..633db1a6c 100644
--- a/lang/finnish.txt
+++ b/lang/finnish.txt
@@ -1140,7 +1140,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Suihkuk
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Vaihda ilmastoa: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Muuta päiväystä: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Muuntuvat tuotantoarvot: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Salli sähköveturien kulkeminen tavallisella rautatiellä.
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Kohde: {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Kohde: {WAYPOINT}, {VELOCITY}
diff --git a/lang/french.txt b/lang/french.txt
index fd48671ac..e0a58e7e3 100644
--- a/lang/french.txt
+++ b/lang/french.txt
@@ -1141,7 +1141,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Les jet
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Changer de climat : {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Changer la date: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Permettre la modification des valeurs de production : {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Autoriser les locomotives électriques à circuler sur des voies non-électrifiées
STR_HEADING_FOR_WAYPOINT :{LTBLUE}En route pour {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}En route pour {WAYPOINT}, {VELOCITY}
diff --git a/lang/german.txt b/lang/german.txt
index 81ea73c4c..6d6442059 100644
--- a/lang/german.txt
+++ b/lang/german.txt
@@ -1141,7 +1141,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Flugzeu
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Wechsle Klima: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Ändere Datum: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Aktiviere Veränderung der Produktionswerte: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Erlaube E-Loks auf normalen Gleisen zu fahren
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Fahre zu {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Fahre zu {WAYPOINT}, {VELOCITY}
diff --git a/lang/hungarian.txt b/lang/hungarian.txt
index 7dceeff7f..e00ee1b7a 100644
--- a/lang/hungarian.txt
+++ b/lang/hungarian.txt
@@ -1206,7 +1206,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Jet-rep
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Klíma változtatás: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Dátum módosítás: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}A nyersanyagüzemek termelése változtatható: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Közlekedhessenek elektromos mozdonyok hagyományos síneken
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Úton {WAYPOINT} felé
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Úton {WAYPOINT} felé, {VELOCITY}
diff --git a/lang/icelandic.txt b/lang/icelandic.txt
index 35e82a727..8dfda982a 100644
--- a/lang/icelandic.txt
+++ b/lang/icelandic.txt
@@ -1110,7 +1110,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Þotur
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Skipta um loftslag: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Breyta dagsetningu: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Leyfa breytingar á verðmæti framleiðslu: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Leyfa rafdrifnum lestum að nota venjuleg spor
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Á leiðinni til {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Á leiðinni til {WAYPOINT}, {VELOCITY}
diff --git a/lang/italian.txt b/lang/italian.txt
index 4cf85e3e1..2d47d0e83 100644
--- a/lang/italian.txt
+++ b/lang/italian.txt
@@ -1142,7 +1142,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}I jet n
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Cambia paesaggio: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Cambia data: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Permetti la modifica dei valori di produzione: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Permetti l'uso di locomotori elettrici sui binari normali
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Direzione {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Direzione {WAYPOINT}, {VELOCITY}
diff --git a/lang/norwegian.txt b/lang/norwegian.txt
index 8e181335f..5ae178bf5 100644
--- a/lang/norwegian.txt
+++ b/lang/norwegian.txt
@@ -1137,7 +1137,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Jetfly
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Bytt klima: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Bytt dato: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Tillat endring av produksjonsmengder: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Tillat elektriske lokomotiv å kjøre på vanlige skinner
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Har kurs mot {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Har kurs mot {WAYPOINT}, {VELOCITY}
diff --git a/lang/polish.txt b/lang/polish.txt
index 33840f8ba..4b71087a4 100644
--- a/lang/polish.txt
+++ b/lang/polish.txt
@@ -1227,7 +1227,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Odrzuto
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Zmien klimat: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Zmien date: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Pozwol modyfikowac wielkosc produkcji przedsiebiorstw: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Pozwol lokomotywom elektrycznym pracowac na zwyklych torach
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Zmierza do {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Zmierza do {WAYPOINT}, {VELOCITY}
diff --git a/lang/portuguese.txt b/lang/portuguese.txt
index 5caab132e..ac0ca7e33 100644
--- a/lang/portuguese.txt
+++ b/lang/portuguese.txt
@@ -1140,7 +1140,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Aviões
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Mudar de clima: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Alterar data: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Activar modificação de valores de produção: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Permitir comboios eléctricos em carris normais
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Dirige-se a {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Dirige-se a {WAYPOINT}, {VELOCITY}
diff --git a/lang/romanian.txt b/lang/romanian.txt
index f042f2185..321bc900b 100644
--- a/lang/romanian.txt
+++ b/lang/romanian.txt
@@ -1106,7 +1106,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Avioane
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Schimbã peisajul: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Schimbã data: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Activeaza accesul la valorile de productie: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Permite motoarealor electrice sã ruleze pe sine normale
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Merge spre {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Merge spre {WAYPOINT}, {VELOCITY}
diff --git a/lang/slovak.txt b/lang/slovak.txt
index 99178db86..32b72de96 100644
--- a/lang/slovak.txt
+++ b/lang/slovak.txt
@@ -1206,7 +1206,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Prudove
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Zmenit klimu: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Zmenit datum: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Povolit zmenu objemu vyroby: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Umoznit pouzitie el. rusnov na normalnych tratiach
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Smeruje do {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Smeruje do {WAYPOINT}, {VELOCITY}
diff --git a/lang/spanish.txt b/lang/spanish.txt
index a0f707e39..f5976c3ff 100644
--- a/lang/spanish.txt
+++ b/lang/spanish.txt
@@ -1141,7 +1141,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Los Jet
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Cambiar clima: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Cambiar fecha: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Activar modificación de los valores de producción: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Permitir locomotoras eléctricas sobre railes normales
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Hacia {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Hacia {WAYPOINT}, {VELOCITY}
diff --git a/lang/swedish.txt b/lang/swedish.txt
index 1b058206a..fbad49c2c 100644
--- a/lang/swedish.txt
+++ b/lang/swedish.txt
@@ -1140,7 +1140,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Jetplan
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}Byt klimat: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Byt datum: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Aktivera modifierande produceringsvärden: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Tillåt elektriska lok att använda vanlig räls
STR_HEADING_FOR_WAYPOINT :{LTBLUE}På väg mot {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}På väg mot {WAYPOINT}, {VELOCITY}
diff --git a/lang/turkish.txt b/lang/turkish.txt
index 65b7ca184..a8f989865 100644
--- a/lang/turkish.txt
+++ b/lang/turkish.txt
@@ -1139,7 +1139,6 @@ STR_CHEAT_NO_JETCRASH :{LTBLUE}Jetler
STR_CHEAT_SWITCH_CLIMATE :{LTBLUE}iklimi degistir: {ORANGE} {STRING}
STR_CHEAT_CHANGE_DATE :{LTBLUE}Tarihi degistir: {ORANGE} {DATE_SHORT}
STR_CHEAT_SETUP_PROD :{LTBLUE}Üretim degerlerini degistir: {ORANGE}{STRING}
-STR_CHEAT_ALLOW_CONVRAIL :{LTBLUE}Elektrikli trenler normal raylarda da gidebilsin
STR_HEADING_FOR_WAYPOINT :{LTBLUE}Gidiyor -> {WAYPOINT}
STR_HEADING_FOR_WAYPOINT_VEL :{LTBLUE}Gidiyor -> {WAYPOINT}, {VELOCITY}
diff --git a/main_gui.c b/main_gui.c
index 40ddcad60..11b33067e 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -46,7 +46,7 @@ static int _rename_id;
static int _rename_what;
static byte _terraform_size = 1;
-static RailType _last_built_railtype;
+RailType _last_built_railtype;
static int _scengen_town_size = 2; // depress medium-sized towns per default
extern void GenerateIndustries(void);
@@ -2448,3 +2448,4 @@ void InitializeMainGui(void)
/* Clean old GUI values */
_last_built_railtype = 0;
}
+
diff --git a/misc_gui.c b/misc_gui.c
index 6969312c3..2d2429fcf 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -1682,18 +1682,6 @@ static int32 ClickChangeDateCheat(int32 p1, int32 p2)
return _cur_year;
}
-static int32 ClickAllowConvrail(int32 p1, int32 p2)
-{
- Vehicle *v;
- SB(_railtypes[RAILTYPE_ELECTRIC].powered_railtypes, RAILTYPE_RAIL, 1, p1);
-
- FOR_ALL_VEHICLES(v) {
- if (v->type == VEH_Train && IsFrontEngine(v)) TrainConsistChanged(v);
- }
- return p1;
-}
-
-
typedef int32 CheckButtonClick(int32, int32);
enum ce_flags {CE_CLICK = 1 << 0};
@@ -1720,7 +1708,6 @@ static const CheatEntry _cheats_ui[] = {
{SLE_BOOL, 0, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, NULL, 0, 0},
{SLE_UINT8, 0, STR_CHEAT_SWITCH_CLIMATE, &_opt.landscape, &_cheats.switch_climate.been_used, &ClickChangeClimateCheat,-1, 4},
{SLE_INT32, 0, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat, -1, 1},
- {SLE_BOOL, 0, STR_CHEAT_ALLOW_CONVRAIL, &_cheats.elrail.value, &_cheats.elrail.been_used, &ClickAllowConvrail, 0, 0},
};
diff --git a/openttd.c b/openttd.c
index 0103c279d..43fb5bc4f 100644
--- a/openttd.c
+++ b/openttd.c
@@ -606,6 +606,8 @@ static void MakeNewGameDone(void)
_current_player = _local_player;
DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
+ SettingsDisableElrail(_patches.disable_elrails);
+
MarkWholeScreenDirty();
}
@@ -1536,5 +1538,19 @@ bool AfterLoadGame(void)
ConvertNameArray();
}
+ /* from version 38 we have optional elrails */
+ if (CheckSavegameVersion(38)) {
+ /* old game - before elrails made optional */
+ if (CheckSavegameVersion(24)) {
+ /* very old game - before elrail was introduced */
+ _patches.disable_elrails = true; // disable elrails
+ } else {
+ /* game with mandatory elrails (r4150+) */
+ _patches.disable_elrails = false; // enable elrails
+ }
+ }
+ /* do the same as when elrails were enabled/disabled manually just now */
+ SettingsDisableElrail(_patches.disable_elrails);
+
return true;
}
diff --git a/rail.h b/rail.h
index 5cfc7340c..37270a1bf 100644
--- a/rail.h
+++ b/rail.h
@@ -465,4 +465,7 @@ void DrawDefaultWaypointSprite(int x, int y, RailType railtype);
void DrawCatenary(const TileInfo *ti);
uint GetRailFoundation(Slope tileh, TrackBits bits);
+
+int32 SettingsDisableElrail(int32 p1); ///< _patches.disable_elrail callback
+
#endif /* RAIL_H */
diff --git a/rail_cmd.c b/rail_cmd.c
index 65713beb6..cb5ff4213 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -883,6 +883,9 @@ static int32 DoConvertRail(TileIndex tile, RailType totype, bool exec)
// tile is already of requested type?
if (GetRailType(tile) == totype) return CMD_ERROR;
+ // 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
+ if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
+
// change type.
if (exec) {
TrackBits tracks;
diff --git a/rail_gui.c b/rail_gui.c
index 4d9e8ae17..30bf0a034 100644
--- a/rail_gui.c
+++ b/rail_gui.c
@@ -22,6 +22,7 @@
#include "variables.h"
#include "newgrf_callbacks.h"
#include "newgrf_station.h"
+#include "train.h"
static RailType _cur_railtype;
static bool _remove_button_clicked;
@@ -1150,3 +1151,20 @@ void InitializeRailGui(void)
_railstation.platlength = 1;
_railstation.dragdrop = true;
}
+
+void ReinitGuiAfterToggleElrail(bool disable)
+{
+ extern RailType _last_built_railtype;
+ if (disable && _last_built_railtype == RAILTYPE_ELECTRIC) {
+ Window *w;
+ _last_built_railtype = _cur_railtype = RAILTYPE_RAIL;
+ w = FindWindowById(WC_BUILD_TOOLBAR, 0);
+ if (w != NULL && w->wndproc == BuildRailToolbWndProc) {
+ SetupRailToolbar(_cur_railtype, w);
+ SetWindowDirty(w);
+ }
+ }
+ MarkWholeScreenDirty();
+}
+
+
diff --git a/road_cmd.c b/road_cmd.c
index 7828d0abc..5f0276c16 100644
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -430,6 +430,9 @@ int32 DoConvertStreetRail(TileIndex tile, RailType totype, bool exec)
if (GetRailTypeCrossing(tile) == totype) return CMD_ERROR;
+ // 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
+ if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailTypeCrossing(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
+
if (exec) {
SetRailTypeCrossing(tile, totype);
MarkTileDirtyByTile(tile);
diff --git a/saveload.c b/saveload.c
index 811c85da5..21e537084 100644
--- a/saveload.c
+++ b/saveload.c
@@ -30,7 +30,7 @@
#include "variables.h"
#include <setjmp.h>
-const uint16 SAVEGAME_VERSION = 37;
+const uint16 SAVEGAME_VERSION = 38;
uint16 _sl_version; /// the major savegame version identifier
byte _sl_minor_version; /// the minor savegame version, DO NOT USE!
diff --git a/settings.c b/settings.c
index 6dea5e74a..3de21068d 100644
--- a/settings.c
+++ b/settings.c
@@ -38,6 +38,7 @@
#include "newgrf.h"
#include "genworld.h"
#include "date.h"
+#include "rail.h"
#ifdef WITH_FREETYPE
#include "gfx.h"
#include "fontcache.h"
@@ -1320,6 +1321,7 @@ const SettingDesc _patch_settings[] = {
SDT_VAR(Patches, servint_aircraft, SLE_UINT16, 0,D0, 100, 5, 800, 0, STR_CONFIG_PATCHES_SERVINT_AIRCRAFT, InValidateDetailsWindow),
SDT_BOOL(Patches, no_servicing_if_no_breakdowns, 0, 0, false, STR_CONFIG_PATCHES_NOSERVICE, NULL),
SDT_BOOL(Patches, wagon_speed_limits, 0, 0, true, STR_CONFIG_PATCHES_WAGONSPEEDLIMITS, NULL),
+ SDT_CONDBOOL(Patches, disable_elrails, 38, SL_MAX_VERSION, 0, 0, false, STR_CONFIG_PATCHES_DISABLE_ELRAILS, SettingsDisableElrail),
/***************************************************************************/
/* Station section of the GUI-configure patches window */
diff --git a/settings_gui.c b/settings_gui.c
index c336e86fa..eff7dedc1 100644
--- a/settings_gui.c
+++ b/settings_gui.c
@@ -646,6 +646,7 @@ static const char *_patches_vehicles[] = {
"servint_aircraft",
"no_servicing_if_no_breakdowns",
"wagon_speed_limits",
+ "disable_elrails",
};
typedef struct PatchEntry {
diff --git a/station_cmd.c b/station_cmd.c
index 87099bf03..7de77721e 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -1358,6 +1358,9 @@ int32 DoConvertStationRail(TileIndex tile, RailType totype, bool exec)
if (GetRailType(tile) == totype) return CMD_ERROR;
+ // 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
+ if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
+
if (exec) {
SetRailType(tile, totype);
MarkTileDirtyByTile(tile);
diff --git a/train_cmd.c b/train_cmd.c
index 6edecc4e6..1179c2958 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -192,6 +192,13 @@ void TrainConsistChanged(Vehicle* v)
v->u.rail.compatible_railtypes |= GetRailTypeInfo(u->u.rail.railtype)->powered_railtypes;
}
+ /* Some electric engines can be allowed to run on normal rail. It happens to all
+ * existing electric engines when elrails are disabled and then re-enabled */
+ if (HASBIT(u->u.rail.flags, VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL)) {
+ u->u.rail.railtype = RAILTYPE_RAIL;
+ u->u.rail.compatible_railtypes |= (1 << RAILTYPE_RAIL);
+ }
+
// max speed is the minimum of the speed limits of all vehicles in the consist
if (!(rvi_u->flags & RVI_WAGON) || _patches.wagon_speed_limits)
if (rvi_u->max_speed != 0 && !UsesWagonOverride(u))
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index 17b803628..a1db8f866 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -772,6 +772,9 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
if (GetRailType(tile) == totype) return CMD_ERROR;
+ // 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
+ if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
+
endtile = CheckTunnelBusy(tile, &length);
if (endtile == INVALID_TILE) return CMD_ERROR;
diff --git a/variables.h b/variables.h
index 2ea03c740..9d44979fe 100644
--- a/variables.h
+++ b/variables.h
@@ -125,6 +125,7 @@ typedef struct Patches {
bool no_servicing_if_no_breakdowns; // dont send vehicles to depot when breakdowns are disabled
bool link_terraform_toolbar; // display terraform toolbar when displaying rail, road, water and airport toolbars
bool reverse_scroll; // Right-Click-Scrolling scrolls in the opposite direction
+ bool disable_elrails; // when true, the elrails are disabled
bool measure_tooltip; // Show a permanent tooltip when dragging tools
byte liveries; // Options for displaying company liveries, 0=none, 1=self, 2=all
bool prefer_teamchat; // Choose the chat message target with <ENTER>, true=all players, false=your team
@@ -240,7 +241,7 @@ typedef struct Cheats {
Cheat switch_climate;
Cheat change_date; // changes date ingame
Cheat setup_prod; // setup raw-material production in game
- Cheat elrail; // allow electric engines to be powered on conventional rail
+ Cheat dummy; // empty cheat (enable running el-engines on normal rail)
} Cheats;
VARDEF Cheats _cheats;
diff --git a/vehicle.h b/vehicle.h
index ef57eaee2..7681b9de9 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -95,6 +95,9 @@ enum {
// used to mark train as lost because PF can't find the route
VRF_NO_PATH_TO_DESTINATION = 5,
+
+ // used to mark that electric train engine is allowed to run on normal rail
+ VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL = 6,
};
typedef struct VehicleAir {