Changeset - r11223:d5864a79dfb6
[Not reviewed]
master
0 8 0
yexo - 16 years ago 2009-02-25 00:45:52
yexo@openttd.org
(svn r15576) -Codechange: rename SwitchModes to SwitchMode and don't hardcode the values for that enum.
8 files changed with 28 insertions and 27 deletions:
0 comments (0 inline, 0 general)
src/console_cmds.cpp
Show inline comments
 
@@ -920,26 +920,26 @@ DEF_CONSOLE_CMD(ConNewGame)
 
	}
 

	
 
	StartNewGameWithoutGUI((argc == 2) ? (uint)atoi(argv[1]) : GENERATE_NEW_SEED);
 
	return true;
 
}
 

	
 
extern void SwitchMode(int new_mode);
 
extern void SwitchToMode(SwitchMode new_mode);
 

	
 
DEF_CONSOLE_CMD(ConRestart)
 
{
 
	if (argc == 0) {
 
		IConsoleHelp("Restart game. Usage: 'restart'");
 
		IConsoleHelp("Restarts a game. It tries to reproduce the exact same map as the game started with.");
 
		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;
 
}
 

	
 
DEF_CONSOLE_CMD(ConListAI)
 
{
 
	char buf[4096];
src/genworld_gui.cpp
Show inline comments
 
@@ -36,13 +36,13 @@ enum glwp_modes {
 
	GLWP_GENERATE,
 
	GLWP_HEIGHTMAP,
 
	GLWP_SCENARIO,
 
	GLWP_END
 
};
 

	
 
extern void SwitchMode(int new_mode);
 
extern void SwitchToMode(SwitchMode new_mode);
 
extern void MakeNewgameSettingsLive();
 

	
 
static inline void SetNewLandscapeType(byte landscape)
 
{
 
	_settings_newgame.game_creation.landscape = landscape;
 
	InvalidateWindowClasses(WC_SELECT_GAME);
src/gfx.cpp
Show inline comments
 
@@ -35,12 +35,13 @@ bool _right_button_down;    ///< Is righ
 
bool _right_button_clicked; ///< Is right mouse button clicked?
 
DrawPixelInfo _screen;
 
bool _screen_disable_anim = false;   ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
 
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;
 

	
 
Colour _cur_palette[256];
 
byte _stringwidth_table[FS_END][224]; ///< Cache containing width of often used characters. @see GetCharacterWidth()
src/network/network_gui.cpp
Show inline comments
 
@@ -27,13 +27,13 @@
 
#include "table/strings.h"
 
#include "../table/sprites.h"
 

	
 

	
 
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,
 
	STR_NETWORK_INTERNET_ADVERTISE,
 
	INVALID_STRING_ID
 
};
 
@@ -1017,13 +1017,13 @@ struct NetworkStartServerWindow : public
 
						SetFiosType(this->map->type);
 
						_file_to_saveload.filetype = FT_SCENARIO;
 
						strecpy(_file_to_saveload.name, name, lastof(_file_to_saveload.name));
 
						strecpy(_file_to_saveload.title, this->map->title, lastof(_file_to_saveload.title));
 

	
 
						delete this;
 
						SwitchMode(SM_START_SCENARIO);
 
						SwitchToMode(SM_START_SCENARIO);
 
					}
 
				}
 
				break;
 

	
 
			case NSSW_LOAD: // Load game
 
				_is_network_server = true;
 
@@ -1826,13 +1826,13 @@ struct NetworkJoinStatusWindow : Window 
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		if (widget == 2) { //Disconnect button
 
			NetworkDisconnect();
 
			SwitchMode(SM_MENU);
 
			SwitchToMode(SM_MENU);
 
			ShowNetworkGameWindow();
 
		}
 
	}
 

	
 
	virtual void OnQueryTextFinished(char *str)
 
	{
src/openttd.cpp
Show inline comments
 
@@ -864,13 +864,13 @@ bool SafeSaveOrLoad(const char *filename
 
		default:
 
			_game_mode = ogm;
 
			return false;
 
	}
 
}
 

	
 
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 */
 
	if (new_mode != SM_SAVE) {
 
		/* If the network is active, make it not-active */
 
		if (_networking) {
 
@@ -999,12 +999,14 @@ void SwitchMode(int new_mode)
 
		case SM_GENRANDLAND: /* Generate random land within scenario editor */
 
			SetLocalCompany(OWNER_NONE);
 
			GenerateWorld(GW_RANDOM, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y);
 
			/* XXX: set date */
 
			MarkWholeScreenDirty();
 
			break;
 

	
 
		default: NOT_REACHED();
 
	}
 

	
 
	if (_switch_mode_errorstr != INVALID_STRING_ID) {
 
		ShowErrorMessage(INVALID_STRING_ID, _switch_mode_errorstr, 0, 0);
 
	}
 
}
 
@@ -1143,13 +1145,13 @@ void GameLoop()
 

	
 
	/* make a screenshot? */
 
	if (IsScreenshotRequested()) ShowScreenshotResult(MakeScreenshot());
 

	
 
	/* switch game mode? */
 
	if (_switch_mode != SM_NONE) {
 
		SwitchMode(_switch_mode);
 
		SwitchToMode(_switch_mode);
 
		_switch_mode = SM_NONE;
 
	}
 

	
 
	IncreaseSpriteLRU();
 
	InteractiveRandom();
 

	
src/openttd.h
Show inline comments
 
@@ -8,24 +8,24 @@
 
enum GameMode {
 
	GM_MENU,
 
	GM_NORMAL,
 
	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 */
 
enum {
 
	DO_SHOW_TOWN_NAMES    = 0,
 
	DO_SHOW_STATION_NAMES = 1,
 
@@ -33,10 +33,11 @@ enum {
 
	DO_FULL_ANIMATION     = 3,
 
	DO_FULL_DETAIL        = 5,
 
	DO_WAYPOINTS          = 6,
 
};
 

	
 
extern GameMode _game_mode;
 
extern SwitchMode _switch_mode;
 
extern bool _exit_game;
 
extern int8 _pause_game;
 

	
 
#endif /* OPENTTD_H */
src/variables.h
Show inline comments
 
@@ -46,15 +46,12 @@ VARDEF int _caret_timer;
 

	
 
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;
 
VARDEF char *_highscore_file;
 
VARDEF char *_log_file;
 

	
src/video/dedicated_v.cpp
Show inline comments
 
@@ -123,13 +123,13 @@ static void CloseWindowsConsoleThread()
 
#endif
 

	
 

	
 
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;
 

	
 

	
 
const char *VideoDriver_Dedicated::Start(const char * const *parm)
 
{
 
@@ -258,25 +258,25 @@ void VideoDriver_Dedicated::MainLoop()
 
	_network_playas = COMPANY_SPECTATOR;
 
	_local_company = COMPANY_SPECTATOR;
 

	
 
	/* 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;
 
		/* First we need to test if the savegame can be loaded, else we will end up playing the
 
		 *  intro game... */
 
		if (!SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_NORMAL, BASE_DIR)) {
 
			/* Loading failed, pop out.. */
 
			DEBUG(net, 0, "Loading requested map failed, aborting");
 
			_networking = false;
 
		} else {
 
			/* We can load this game, so go ahead */
 
			SwitchMode(SM_LOAD);
 
			SwitchToMode(SM_LOAD);
 
		}
 
	}
 

	
 
	// Done loading, start game!
 

	
 
	if (!_networking) {
0 comments (0 inline, 0 general)