+
+ if (g_settings->getBool("enable_local_map_saving")
+ && !is_simple_singleplayer_game) {
+ const std::string world_path = porting::path_user + DIR_DELIM + "worlds"
+ + DIR_DELIM + "server_" + g_settings->get("address")
+ + "_" + g_settings->get("remote_port");
+
+ SubgameSpec gamespec;
+ if (!getWorldExists(world_path)) {
+ gamespec = findSubgame(g_settings->get("default_game"));
+ if (!gamespec.isValid())
+ gamespec = findSubgame("minimal");
+ } else {
+ std::string world_gameid = getWorldGameId(world_path, false);
+ gamespec = findWorldSubgame(world_path);
+ }
+ if (!gamespec.isValid()) {
+ errorstream << "Couldn't find subgame for local map saving." << std::endl;
+ return;
+ }
+
+ localserver = new Server(world_path, gamespec, false, false);
+ localdb = new Database_SQLite3(&(ServerMap&)localserver->getMap(), world_path);
+ localdb->beginSave();
+ actionstream << "Local map saving started, map will be saved at '" << world_path << "'" << std::endl;
+ } else {
+ localdb = NULL;
+ }