changeset 17732:7f9fc59bec49 draft

(svn r22512) -Add: Save heightmap.
author alberth <alberth@openttd.org>
date Sat, 28 May 2011 13:55:34 +0000
parents ff826de69369
children 162a9d189af3
files src/console_cmds.cpp src/fios_gui.cpp src/openttd.cpp src/openttd.h src/video/dedicated_v.cpp
diffstat 5 files changed, 20 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -365,7 +365,7 @@
 	if (item != NULL) {
 		switch (item->type) {
 			case FIOS_TYPE_FILE: case FIOS_TYPE_OLDFILE: {
-				_switch_mode = SM_LOAD;
+				_switch_mode = SM_LOAD_GAME;
 				SetFiosType(item->type);
 
 				strecpy(_file_to_saveload.name, FiosBrowseTo(item), lastof(_file_to_saveload.name));
--- a/src/fios_gui.cpp
+++ b/src/fios_gui.cpp
@@ -527,7 +527,7 @@
 
 			case SLWW_LOAD_BUTTON:
 				if (this->selected != NULL && !_load_check_data.HasErrors() && (_load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs())) {
-					_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD;
+					_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD_GAME;
 
 					const char *name = FiosBrowseTo(this->selected);
 					SetFiosType(this->selected->type);
@@ -649,7 +649,7 @@
 
 			UpdateTextBufferSize(&this->text);
 		} else if (this->IsWidgetLowered(SLWW_SAVE_GAME)) { // Save button clicked
-			_switch_mode = SM_SAVE;
+			_switch_mode = SM_SAVE_GAME;
 			FiosMakeSavegameName(_file_to_saveload.name, this->text.buf, sizeof(_file_to_saveload.name));
 
 			/* In the editor set up the vehicle engines correctly (date might have changed) */
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -456,7 +456,7 @@
 		case 'g':
 			if (mgo.opt != NULL) {
 				strecpy(_file_to_saveload.name, mgo.opt, lastof(_file_to_saveload.name));
-				_switch_mode = SM_LOAD;
+				_switch_mode = SM_LOAD_GAME;
 				_file_to_saveload.mode = SL_LOAD;
 
 				/* if the file doesn't exist or it is not a valid savegame, let the saveload code show an error */
@@ -854,10 +854,10 @@
 {
 #ifdef ENABLE_NETWORK
 	/* If we are saving something, the network stays in his current state */
-	if (new_mode != SM_SAVE) {
+	if (new_mode != SM_SAVE_GAME) {
 		/* If the network is active, make it not-active */
 		if (_networking) {
-			if (_network_server && (new_mode == SM_LOAD || new_mode == SM_NEWGAME || new_mode == SM_RESTARTGAME)) {
+			if (_network_server && (new_mode == SM_LOAD_GAME || new_mode == SM_NEWGAME || new_mode == SM_RESTARTGAME)) {
 				NetworkReboot();
 			} else {
 				NetworkDisconnect();
@@ -883,7 +883,7 @@
 	}
 #endif /* ENABLE_NETWORK */
 	/* Make sure all AI controllers are gone at quiting game */
-	if (new_mode != SM_SAVE) AI::KillAll();
+	if (new_mode != SM_SAVE_GAME) AI::KillAll();
 
 	switch (new_mode) {
 		case SM_EDITOR: // Switch to scenario editor
@@ -900,7 +900,7 @@
 			MakeNewGame(false, new_mode == SM_NEWGAME);
 			break;
 
-		case SM_LOAD: { // Load game, Play Scenario
+		case SM_LOAD_GAME: { // Load game, Play Scenario
 			ResetGRFConfig(true);
 			ResetWindowSystem();
 
@@ -964,7 +964,7 @@
 			}
 			break;
 
-		case SM_SAVE: // Save game
+		case SM_SAVE_GAME: // Save game.
 			/* Make network saved games on pause compatible to singleplayer */
 			if (SaveOrLoad(_file_to_saveload.name, SL_SAVE, NO_DIRECTORY) != SL_OK) {
 				SetDParamStr(0, GetSaveLoadErrorString());
@@ -974,6 +974,11 @@
 			}
 			break;
 
+		case SM_SAVE_HEIGHTMAP: // Save heightmap.
+			MakeHeightmapScreenshot(_file_to_saveload.name);
+			DeleteWindowById(WC_SAVELOAD, 0);
+			break;
+
 		case SM_GENRANDLAND: // Generate random land within scenario editor
 			SetLocalCompany(OWNER_NONE);
 			GenerateWorld(GWM_RANDOM, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y);
--- a/src/openttd.h
+++ b/src/openttd.h
@@ -27,9 +27,10 @@
 	SM_NEWGAME,         ///< New Game --> 'Random game'.
 	SM_RESTARTGAME,     ///< Restart --> 'Random game' with current settings.
 	SM_EDITOR,          ///< Switch to scenario editor.
-	SM_LOAD,            ///< Load game, Play Scenario.
+	SM_LOAD_GAME,       ///< Load game, Play Scenario.
 	SM_MENU,            ///< Switch to game intro menu.
-	SM_SAVE,            ///< Save game.
+	SM_SAVE_GAME,       ///< Save game.
+	SM_SAVE_HEIGHTMAP,  ///< Save heightmap.
 	SM_GENRANDLAND,     ///< Generate random land within scenario editor.
 	SM_LOAD_SCENARIO,   ///< Load scenario from scenario editor.
 	SM_START_HEIGHTMAP, ///< Load a heightmap and start a new game from it.
--- a/src/video/dedicated_v.cpp
+++ b/src/video/dedicated_v.cpp
@@ -270,8 +270,8 @@
 	_network_dedicated = true;
 	_current_company = _local_company = COMPANY_SPECTATOR;
 
-	/* If SwitchMode is SM_LOAD, it means that the user used the '-g' options */
-	if (_switch_mode != SM_LOAD) {
+	/* If SwitchMode is SM_LOAD_GAME, it means that the user used the '-g' options */
+	if (_switch_mode != SM_LOAD_GAME) {
 		StartNewGameWithoutGUI(GENERATE_NEW_SEED);
 		SwitchToMode(_switch_mode);
 		_switch_mode = SM_NONE;
@@ -285,7 +285,7 @@
 			_networking = false;
 		} else {
 			/* We can load this game, so go ahead */
-			SwitchToMode(SM_LOAD);
+			SwitchToMode(SM_LOAD_GAME);
 		}
 	}