X-Git-Url: https://git.jsancho.org/?p=lugaru.git;a=blobdiff_plain;f=Source%2FDevtools%2FConsoleCmds.cpp;h=f3ac22c0fbeaf594f225d5191e5c43d38fdfc1a1;hp=b11e12a7fb528b2b43e9ac62bf56fe3572afa239;hb=7ed95b0f483ca64a550e391f8151d7ceb30acc18;hpb=475fb97fd19a8bc2c58c603d0bc5dcf8cc63b40d diff --git a/Source/Devtools/ConsoleCmds.cpp b/Source/Devtools/ConsoleCmds.cpp index b11e12a..f3ac22c 100644 --- a/Source/Devtools/ConsoleCmds.cpp +++ b/Source/Devtools/ConsoleCmds.cpp @@ -177,12 +177,18 @@ void ch_map(const char *args) void ch_save(const char *args) { - std::string map_path = Folders::getUserDataPath() + "/Maps/" + args; + std::string map_path = Folders::getUserDataPath() + "/Maps"; + Folders::makeDirectory(map_path); + map_path = map_path + "/" + args; int mapvers = 12; FILE *tfile; tfile = fopen( map_path.c_str(), "wb" ); + if (tfile == NULL) { + perror((std::string("Couldn't open file ") + map_path + " for saving").c_str()); + return; + } fpackf(tfile, "Bi", mapvers); fpackf(tfile, "Bi", maptype); fpackf(tfile, "Bi", hostile);