summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2006-05-22 14:41:20 +0000
committercelestar <celestar@openttd.org>2006-05-22 14:41:20 +0000
commitb725af6ad78334908edbdf8e0394ca42b26a0eca (patch)
tree6729ec5a4a2fefdf868805d2aed89308a1bfa90e
parent59174d8dbcf748cf64b7a7f26ab80da1b82a23ee (diff)
downloadopenttd-b725af6ad78334908edbdf8e0394ca42b26a0eca.tar.xz
(svn r4946) "Feature": Add a cheat that allows running electric engines on normal rail
-rw-r--r--lang/english.txt1
-rw-r--r--misc_gui.c21
-rw-r--r--rail.h2
-rw-r--r--railtypes.h2
-rw-r--r--variables.h1
5 files changed, 22 insertions, 5 deletions
diff --git a/lang/english.txt b/lang/english.txt
index df7b98611..46118ae16 100644
--- a/lang/english.txt
+++ b/lang/english.txt
@@ -1111,6 +1111,7 @@ 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/misc_gui.c b/misc_gui.c
index ac0222a55..60064770c 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -23,6 +23,8 @@
#include "network.h"
#include "string.h"
#include "variables.h"
+#include "vehicle.h"
+#include "train.h"
#include "hal.h" // for file list
@@ -1682,6 +1684,18 @@ 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};
@@ -1708,14 +1722,15 @@ 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_UINT8, 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},
};
static const Widget _cheat_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 399, 0, 13, STR_CHEATS, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{ WWT_PANEL, RESIZE_NONE, 14, 0, 399, 14, 159, 0x0, STR_NULL},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 399, 14, 159, 0x0, STR_CHEATS_TIP},
+{ WWT_PANEL, RESIZE_NONE, 14, 0, 399, 14, 169, 0x0, STR_NULL},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 399, 14, 169, 0x0, STR_CHEATS_TIP},
{ WIDGETS_END},
};
@@ -1845,7 +1860,7 @@ static void CheatsWndProc(Window *w, WindowEvent *e)
}
static const WindowDesc _cheats_desc = {
- 240, 22, 400, 160,
+ 240, 22, 400, 170,
WC_CHEATS,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
_cheat_widgets,
diff --git a/rail.h b/rail.h
index d756a3b87..975b0e76c 100644
--- a/rail.h
+++ b/rail.h
@@ -127,7 +127,7 @@ typedef struct RailtypeInfo {
byte custom_ground_offset;
} RailtypeInfo;
-extern const RailtypeInfo _railtypes[RAILTYPE_END];
+extern RailtypeInfo _railtypes[RAILTYPE_END];
// these are the maximums used for updating signal blocks, and checking if a depot is in a pbs block
enum {
diff --git a/railtypes.h b/railtypes.h
index 48f13286a..be2ff2907 100644
--- a/railtypes.h
+++ b/railtypes.h
@@ -6,7 +6,7 @@
/** Global Railtype definition
*/
-const RailtypeInfo _railtypes[] = {
+RailtypeInfo _railtypes[] = {
/** Railway */
{ /* Main Sprites */
{ SPR_RAIL_TRACK_Y, SPR_RAIL_TRACK_N_S, SPR_RAIL_TRACK_BASE, SPR_RAIL_SINGLE_Y, SPR_RAIL_SINGLE_X,
diff --git a/variables.h b/variables.h
index 7f4d97e42..b5eaf492e 100644
--- a/variables.h
+++ b/variables.h
@@ -228,6 +228,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
} Cheats;
VARDEF Cheats _cheats;