summaryrefslogtreecommitdiff
path: root/console_cmds.c
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2005-03-25 18:26:49 +0000
committerDarkvater <Darkvater@openttd.org>2005-03-25 18:26:49 +0000
commit017a60aa3c84cf490e4a8143d71f8b92958e67c0 (patch)
tree0b6bd350de656d9a68bac0a381a0fecd43e610fb /console_cmds.c
parentebf07edaf870fb1feebdbbbec1bb5cfcdef2320a (diff)
downloadopenttd-017a60aa3c84cf490e4a8143d71f8b92958e67c0.tar.xz
(svn r2069) - Feature: [ 1168743 ] save command for console (pkirchhofer)
Diffstat (limited to 'console_cmds.c')
-rw-r--r--console_cmds.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/console_cmds.c b/console_cmds.c
index a086443bc..6cd903ec4 100644
--- a/console_cmds.c
+++ b/console_cmds.c
@@ -145,6 +145,35 @@ extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm);
extern void BuildFileList(void);
extern void SetFiosType(const byte fiostype);
+/* Save the map to current dir */
+static void SaveMap(const char *filename)
+{
+ char buf[200];
+
+ snprintf(buf, sizeof(buf), "%s%s%s.sav", _path.save_dir, PATHSEP, filename);
+ IConsolePrint(_iconsole_color_default, "Saving map...");
+
+ if (SaveOrLoad(buf, SL_SAVE) != SL_OK) {
+ IConsolePrint(_iconsole_color_error, "SaveMap failed");
+ } else
+ IConsolePrintF(_iconsole_color_default, "Map sucessfully saved to %s", buf);
+}
+
+/* Save the map to a file */
+DEF_CONSOLE_CMD(ConSave)
+{
+ /* We need 1 argument */
+ if (argc == 2) {
+ /* Save the map */
+ SaveMap(argv[1]);
+ return NULL;
+ }
+
+ /* Give usage */
+ IConsolePrint(_iconsole_color_default, "Unknown usage. Usage: save <filename>");
+ return NULL;
+}
+
/* Load a file-number from current dir */
static void LoadMap(uint no)
{
@@ -1240,6 +1269,7 @@ void IConsoleStdLibRegister(void)
IConsoleCmdRegister("set", ConSet);
IConsoleCmdRegister("alias", ConAlias);
IConsoleCmdRegister("load", ConLoad);
+ IConsoleCmdRegister("save", ConSave);
IConsoleCmdRegister("list_files", ConListFiles);
IConsoleCmdRegister("scan_files", ConScanFiles);
IConsoleCmdRegister("goto_dir", ConGotoDir);