Skip to content

Commit

Permalink
#5729: Add a dedicated command for writing an automatic map backup.
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Aug 28, 2021
1 parent 17ffb38 commit 4701489
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
8 changes: 8 additions & 0 deletions radiantcore/map/Map.cpp
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions radiantcore/map/Map.h
Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions radiantcore/map/autosaver/AutoSaver.cpp
Expand Up @@ -26,6 +26,7 @@
#include "module/StaticModule.h"
#include "messages/NotificationMessage.h"
#include "messages/AutomaticMapSaveRequest.h"
#include "map/Map.h"

#include <fmt/format.h>

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
{
Expand All @@ -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);
}
}
}
Expand Down

0 comments on commit 4701489

Please sign in to comment.