(svn r22512) -Add: Save heightmap.

pull/155/head
alberth 14 years ago
parent 4b295664ad
commit cae2d84af3

@ -365,7 +365,7 @@ DEF_CONSOLE_CMD(ConLoad)
if (item != NULL) { if (item != NULL) {
switch (item->type) { switch (item->type) {
case FIOS_TYPE_FILE: case FIOS_TYPE_OLDFILE: { case FIOS_TYPE_FILE: case FIOS_TYPE_OLDFILE: {
_switch_mode = SM_LOAD; _switch_mode = SM_LOAD_GAME;
SetFiosType(item->type); SetFiosType(item->type);
strecpy(_file_to_saveload.name, FiosBrowseTo(item), lastof(_file_to_saveload.name)); strecpy(_file_to_saveload.name, FiosBrowseTo(item), lastof(_file_to_saveload.name));

@ -527,7 +527,7 @@ public:
case SLWW_LOAD_BUTTON: case SLWW_LOAD_BUTTON:
if (this->selected != NULL && !_load_check_data.HasErrors() && (_load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs())) { 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); const char *name = FiosBrowseTo(this->selected);
SetFiosType(this->selected->type); SetFiosType(this->selected->type);
@ -649,7 +649,7 @@ public:
UpdateTextBufferSize(&this->text); UpdateTextBufferSize(&this->text);
} else if (this->IsWidgetLowered(SLWW_SAVE_GAME)) { // Save button clicked } 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)); 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) */ /* In the editor set up the vehicle engines correctly (date might have changed) */

@ -456,7 +456,7 @@ int ttd_main(int argc, char *argv[])
case 'g': case 'g':
if (mgo.opt != NULL) { if (mgo.opt != NULL) {
strecpy(_file_to_saveload.name, mgo.opt, lastof(_file_to_saveload.name)); 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; _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 */ /* if the file doesn't exist or it is not a valid savegame, let the saveload code show an error */
@ -854,10 +854,10 @@ void SwitchToMode(SwitchMode new_mode)
{ {
#ifdef ENABLE_NETWORK #ifdef ENABLE_NETWORK
/* If we are saving something, the network stays in his current state */ /* 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 the network is active, make it not-active */
if (_networking) { 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(); NetworkReboot();
} else { } else {
NetworkDisconnect(); NetworkDisconnect();
@ -883,7 +883,7 @@ void SwitchToMode(SwitchMode new_mode)
} }
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */
/* Make sure all AI controllers are gone at quiting game */ /* 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) { switch (new_mode) {
case SM_EDITOR: // Switch to scenario editor case SM_EDITOR: // Switch to scenario editor
@ -900,7 +900,7 @@ void SwitchToMode(SwitchMode new_mode)
MakeNewGame(false, new_mode == SM_NEWGAME); MakeNewGame(false, new_mode == SM_NEWGAME);
break; break;
case SM_LOAD: { // Load game, Play Scenario case SM_LOAD_GAME: { // Load game, Play Scenario
ResetGRFConfig(true); ResetGRFConfig(true);
ResetWindowSystem(); ResetWindowSystem();
@ -964,7 +964,7 @@ void SwitchToMode(SwitchMode new_mode)
} }
break; break;
case SM_SAVE: // Save game case SM_SAVE_GAME: // Save game.
/* Make network saved games on pause compatible to singleplayer */ /* Make network saved games on pause compatible to singleplayer */
if (SaveOrLoad(_file_to_saveload.name, SL_SAVE, NO_DIRECTORY) != SL_OK) { if (SaveOrLoad(_file_to_saveload.name, SL_SAVE, NO_DIRECTORY) != SL_OK) {
SetDParamStr(0, GetSaveLoadErrorString()); SetDParamStr(0, GetSaveLoadErrorString());
@ -974,6 +974,11 @@ void SwitchToMode(SwitchMode new_mode)
} }
break; 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 case SM_GENRANDLAND: // Generate random land within scenario editor
SetLocalCompany(OWNER_NONE); SetLocalCompany(OWNER_NONE);
GenerateWorld(GWM_RANDOM, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y); GenerateWorld(GWM_RANDOM, 1 << _settings_game.game_creation.map_x, 1 << _settings_game.game_creation.map_y);

@ -27,9 +27,10 @@ enum SwitchMode {
SM_NEWGAME, ///< New Game --> 'Random game'. SM_NEWGAME, ///< New Game --> 'Random game'.
SM_RESTARTGAME, ///< Restart --> 'Random game' with current settings. SM_RESTARTGAME, ///< Restart --> 'Random game' with current settings.
SM_EDITOR, ///< Switch to scenario editor. 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_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_GENRANDLAND, ///< Generate random land within scenario editor.
SM_LOAD_SCENARIO, ///< Load scenario from scenario editor. SM_LOAD_SCENARIO, ///< Load scenario from scenario editor.
SM_START_HEIGHTMAP, ///< Load a heightmap and start a new game from it. SM_START_HEIGHTMAP, ///< Load a heightmap and start a new game from it.

@ -270,8 +270,8 @@ void VideoDriver_Dedicated::MainLoop()
_network_dedicated = true; _network_dedicated = true;
_current_company = _local_company = COMPANY_SPECTATOR; _current_company = _local_company = COMPANY_SPECTATOR;
/* If SwitchMode is SM_LOAD, it means that the user used the '-g' options */ /* If SwitchMode is SM_LOAD_GAME, it means that the user used the '-g' options */
if (_switch_mode != SM_LOAD) { if (_switch_mode != SM_LOAD_GAME) {
StartNewGameWithoutGUI(GENERATE_NEW_SEED); StartNewGameWithoutGUI(GENERATE_NEW_SEED);
SwitchToMode(_switch_mode); SwitchToMode(_switch_mode);
_switch_mode = SM_NONE; _switch_mode = SM_NONE;
@ -285,7 +285,7 @@ void VideoDriver_Dedicated::MainLoop()
_networking = false; _networking = false;
} else { } else {
/* We can load this game, so go ahead */ /* We can load this game, so go ahead */
SwitchToMode(SM_LOAD); SwitchToMode(SM_LOAD_GAME);
} }
} }

Loading…
Cancel
Save