summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2009-02-25 00:45:52 +0000
committeryexo <yexo@openttd.org>2009-02-25 00:45:52 +0000
commit3bb872e7dd8ec9318cd60bb9ca417b4d80f8fc34 (patch)
tree0821775e819b64e32e518cdd87b874fb720c4d92 /src
parent901230bde1b0752d97d63aabaa0fd38c9ea183e7 (diff)
downloadopenttd-3bb872e7dd8ec9318cd60bb9ca417b4d80f8fc34.tar.xz
(svn r15576) -Codechange: rename SwitchModes to SwitchMode and don't hardcode the values for that enum.
Diffstat (limited to 'src')
-rw-r--r--src/console_cmds.cpp6
-rw-r--r--src/genworld_gui.cpp2
-rw-r--r--src/gfx.cpp1
-rw-r--r--src/network/network_gui.cpp6
-rw-r--r--src/openttd.cpp6
-rw-r--r--src/openttd.h25
-rw-r--r--src/variables.h3
-rw-r--r--src/video/dedicated_v.cpp6
8 files changed, 28 insertions, 27 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 0993bf47d..7f4463c2b 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -923,7 +923,7 @@ DEF_CONSOLE_CMD(ConNewGame)
return true;
}
-extern void SwitchMode(int new_mode);
+extern void SwitchToMode(SwitchMode new_mode);
DEF_CONSOLE_CMD(ConRestart)
{
@@ -933,10 +933,10 @@ DEF_CONSOLE_CMD(ConRestart)
return true;
}
- /* Don't copy the _newgame pointers to the real pointers, so call SwitchMode directly */
+ /* Don't copy the _newgame pointers to the real pointers, so call SwitchToMode directly */
_settings_game.game_creation.map_x = MapLogX();
_settings_game.game_creation.map_y = FindFirstBit(MapSizeY());
- SwitchMode(SM_NEWGAME);
+ SwitchToMode(SM_NEWGAME);
return true;
}
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index c98e05ad9..49b8bc633 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -39,7 +39,7 @@ enum glwp_modes {
GLWP_END
};
-extern void SwitchMode(int new_mode);
+extern void SwitchToMode(SwitchMode new_mode);
extern void MakeNewgameSettingsLive();
static inline void SetNewLandscapeType(byte landscape)
diff --git a/src/gfx.cpp b/src/gfx.cpp
index 2cf213262..033841e3d 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -38,6 +38,7 @@ bool _screen_disable_anim = false; ///< Disable palette animation (important f
bool _exit_game;
bool _networking; ///< are we in networking mode?
GameMode _game_mode;
+SwitchMode _switch_mode; ///< The next mainloop command.
int8 _pause_game;
int _pal_first_dirty;
int _pal_count_dirty;
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 364c6f0e3..814ace117 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -30,7 +30,7 @@
static void ShowNetworkStartServerWindow();
static void ShowNetworkLobbyWindow(NetworkGameList *ngl);
-extern void SwitchMode(int new_mode);
+extern void SwitchToMode(SwitchMode new_mode);
static const StringID _connection_types_dropdown[] = {
STR_NETWORK_LAN_INTERNET,
@@ -1020,7 +1020,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
strecpy(_file_to_saveload.title, this->map->title, lastof(_file_to_saveload.title));
delete this;
- SwitchMode(SM_START_SCENARIO);
+ SwitchToMode(SM_START_SCENARIO);
}
}
break;
@@ -1829,7 +1829,7 @@ struct NetworkJoinStatusWindow : Window {
{
if (widget == 2) { //Disconnect button
NetworkDisconnect();
- SwitchMode(SM_MENU);
+ SwitchToMode(SM_MENU);
ShowNetworkGameWindow();
}
}
diff --git a/src/openttd.cpp b/src/openttd.cpp
index b03f990f0..692f09698 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -867,7 +867,7 @@ bool SafeSaveOrLoad(const char *filename, int mode, GameMode newgm, Subdirectory
}
}
-void SwitchMode(int new_mode)
+void SwitchToMode(SwitchMode new_mode)
{
#ifdef ENABLE_NETWORK
/* If we are saving something, the network stays in his current state */
@@ -1002,6 +1002,8 @@ void SwitchMode(int new_mode)
/* XXX: set date */
MarkWholeScreenDirty();
break;
+
+ default: NOT_REACHED();
}
if (_switch_mode_errorstr != INVALID_STRING_ID) {
@@ -1146,7 +1148,7 @@ void GameLoop()
/* switch game mode? */
if (_switch_mode != SM_NONE) {
- SwitchMode(_switch_mode);
+ SwitchToMode(_switch_mode);
_switch_mode = SM_NONE;
}
diff --git a/src/openttd.h b/src/openttd.h
index b769de963..d3cc1bb1e 100644
--- a/src/openttd.h
+++ b/src/openttd.h
@@ -11,18 +11,18 @@ enum GameMode {
GM_EDITOR,
};
-enum SwitchModes {
- SM_NONE = 0,
- SM_NEWGAME = 1,
- SM_EDITOR = 2,
- SM_LOAD = 3,
- SM_MENU = 4,
- SM_SAVE = 5,
- SM_GENRANDLAND = 6,
- SM_LOAD_SCENARIO = 9,
- SM_START_SCENARIO = 10,
- SM_START_HEIGHTMAP = 11,
- SM_LOAD_HEIGHTMAP = 12,
+enum SwitchMode {
+ SM_NONE,
+ SM_NEWGAME,
+ SM_EDITOR,
+ SM_LOAD,
+ SM_MENU,
+ SM_SAVE,
+ SM_GENRANDLAND,
+ SM_LOAD_SCENARIO,
+ SM_START_SCENARIO,
+ SM_START_HEIGHTMAP,
+ SM_LOAD_HEIGHTMAP,
};
/* Display Options */
@@ -36,6 +36,7 @@ enum {
};
extern GameMode _game_mode;
+extern SwitchMode _switch_mode;
extern bool _exit_game;
extern int8 _pause_game;
diff --git a/src/variables.h b/src/variables.h
index ded717de8..4ad8f9fb2 100644
--- a/src/variables.h
+++ b/src/variables.h
@@ -49,9 +49,6 @@ VARDEF bool _rightclick_emulate;
/* IN/OUT parameters to commands */
VARDEF bool _generating_world;
-/* Used when switching from the intro menu. */
-VARDEF byte _switch_mode;
-
VARDEF char _savegame_format[8];
VARDEF char *_config_file;
diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp
index 7a4e1a406..2a997d9f9 100644
--- a/src/video/dedicated_v.cpp
+++ b/src/video/dedicated_v.cpp
@@ -126,7 +126,7 @@ static void CloseWindowsConsoleThread()
static void *_dedicated_video_mem;
extern bool SafeSaveOrLoad(const char *filename, int mode, GameMode newgm, Subdirectory subdir);
-extern void SwitchMode(int new_mode);
+extern void SwitchToMode(SwitchMode new_mode);
static FVideoDriver_Dedicated iFVideoDriver_Dedicated;
@@ -261,7 +261,7 @@ void VideoDriver_Dedicated::MainLoop()
/* If SwitchMode is SM_LOAD, it means that the user used the '-g' options */
if (_switch_mode != SM_LOAD) {
StartNewGameWithoutGUI(GENERATE_NEW_SEED);
- SwitchMode(_switch_mode);
+ SwitchToMode(_switch_mode);
_switch_mode = SM_NONE;
} else {
_switch_mode = SM_NONE;
@@ -273,7 +273,7 @@ void VideoDriver_Dedicated::MainLoop()
_networking = false;
} else {
/* We can load this game, so go ahead */
- SwitchMode(SM_LOAD);
+ SwitchToMode(SM_LOAD);
}
}