diff --git a/radiantcore/map/Map.cpp b/radiantcore/map/Map.cpp index c9a78ee3a1..3be53b3639 100644 --- a/radiantcore/map/Map.cpp +++ b/radiantcore/map/Map.cpp @@ -886,6 +886,12 @@ void Map::saveMapCopyAs(const cmd::ArgumentList& args) } } +void Map::saveAutomaticMapBackup(const cmd::ArgumentList& args) +{ + // Use the saveDirect routine to not change with the _lastCopyMapName member + saveDirect(args[0].getString()); +} + void Map::registerCommands() { GlobalCommandSystem().addCommand("NewMap", Map::newMap); @@ -902,6 +908,8 @@ void Map::registerCommands() GlobalCommandSystem().addCommand("SaveMap", std::bind(&Map::saveMapCmd, this, std::placeholders::_1)); GlobalCommandSystem().addCommand("SaveMapAs", Map::saveMapAs); GlobalCommandSystem().addCommand("SaveMapCopyAs", std::bind(&Map::saveMapCopyAs, this, std::placeholders::_1), { cmd::ARGTYPE_STRING | cmd::ARGTYPE_OPTIONAL }); + // Command used by the autosaver to save a copy without messing with the remembered paths + GlobalCommandSystem().addCommand("SaveAutomaticBackup", std::bind(&Map::saveAutomaticMapBackup, this, std::placeholders::_1), { cmd::ARGTYPE_STRING }); GlobalCommandSystem().addCommand("ExportMap", Map::exportMap); GlobalCommandSystem().addCommand("SaveSelected", Map::exportSelection); GlobalCommandSystem().addCommand("ReloadSkins", map::algorithm::reloadSkins); diff --git a/radiantcore/map/Map.h b/radiantcore/map/Map.h index 04433cfee5..050718e5cb 100644 --- a/radiantcore/map/Map.h +++ b/radiantcore/map/Map.h @@ -220,6 +220,9 @@ class Map : */ void saveMapCopyAs(const cmd::ArgumentList& args); + // Used by the auto saver + void saveAutomaticMapBackup(const cmd::ArgumentList& args); + /** greebo: Asks the user for the .pfb file and exports the file/selection */ static void saveSelectedAsPrefab(const cmd::ArgumentList& args); diff --git a/radiantcore/map/autosaver/AutoSaver.cpp b/radiantcore/map/autosaver/AutoSaver.cpp index 401a889266..8011d37c26 100644 --- a/radiantcore/map/autosaver/AutoSaver.cpp +++ b/radiantcore/map/autosaver/AutoSaver.cpp @@ -26,6 +26,7 @@ #include "module/StaticModule.h" #include "messages/NotificationMessage.h" #include "messages/AutomaticMapSaveRequest.h" +#include "map/Map.h" #include @@ -103,7 +104,7 @@ void AutoMapSaver::saveSnapshot() rMessage() << "Autosaving snapshot to " << filename << std::endl; // Dump to map to the next available filename - GlobalCommandSystem().executeCommand("SaveMapCopyAs", filename); + GlobalCommandSystem().executeCommand("SaveAutomaticBackup", filename); handleSnapshotSizeLimit(existingSnapshots, snapshotPath, mapName); } @@ -245,7 +246,7 @@ void AutoMapSaver::performAutosave() rMessage() << "Autosaving unnamed map to " << autoSaveFilename << std::endl; // Invoke the save call - GlobalCommandSystem().executeCommand("SaveMapCopyAs", autoSaveFilename); + GlobalCommandSystem().executeCommand("SaveAutomaticBackup", autoSaveFilename); } else { @@ -261,7 +262,7 @@ void AutoMapSaver::performAutosave() rMessage() << "Autosaving map to " << filename << std::endl; // Invoke the save call - GlobalCommandSystem().executeCommand("SaveMapCopyAs", filename); + GlobalCommandSystem().executeCommand("SaveAutomaticBackup", filename); } } }