From 532a1890c2d78088e9cee616082fa19775c22396 Mon Sep 17 00:00:00 2001 From: danij Date: Fri, 21 Mar 2014 17:19:21 +0000 Subject: [PATCH] Resource System: Changed default savegame folder to /home/savegames For consistency with the naming convention used for most other types of resource, the new savegame system by default uses /home/savegames as the root savegame folder, for all games. Within this folder are subfolders for each game, named according to the identity key of the game for which the .save packages are intended. Previously a game specific /home subfolder was used for the old format savegame files (e.g., Doom used /home/savegame/ while Hexen used /home/hexndata/). Existing old savegames are automatically converted by the engine and will be output to the new /home/savegames/ location. Keeping the new .save packages separate from the old savegames should help to keep things tidy. --- doomsday/client/src/resource/resourcesystem.cpp | 12 ++++++------ doomsday/libdeng2/src/game/savedsession.cpp | 10 +++++----- doomsday/plugins/common/src/g_game.cpp | 2 +- doomsday/plugins/common/src/gamesessionwriter.cpp | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/doomsday/client/src/resource/resourcesystem.cpp b/doomsday/client/src/resource/resourcesystem.cpp index b3f385a08b..bfd9abdd75 100644 --- a/doomsday/client/src/resource/resourcesystem.cpp +++ b/doomsday/client/src/resource/resourcesystem.cpp @@ -338,7 +338,7 @@ DENG2_PIMPL(ResourceSystem) , fontManifestIdMap (0) , modelRepository (0) #endif - , nativeSavePath (App::app().nativeHomePath() / "savegame") // default + , nativeSavePath (App::app().nativeHomePath() / "savegames") // default { LOG_AS("ResourceSystem"); resClasses.append(new ResourceClass("RC_PACKAGE", "Packages")); @@ -387,7 +387,7 @@ DENG2_PIMPL(ResourceSystem) // Else use the default. // Create the user's saved game folder if it doesn't yet exist. - App::fileSystem().makeFolder("/savegame", FS::DontInheritFeeds) + App::fileSystem().makeFolder("/savegames", FS::DontInheritFeeds) .attach(new DirectoryFeed(nativeSavePath, DirectoryFeed::AllowWrite | DirectoryFeed::CreateIfMissing)); } @@ -1918,7 +1918,7 @@ DENG2_PIMPL(ResourceSystem) /** * Insert/replace a SavedSession in the db. * - * @param repoPath Unique /savegame relative path (and identifier for the saved session). + * @param repoPath Unique /savegames relative path (and identifier for the saved session). * * @todo This extra step is unnecessary. SavedSession should inherit from PackageFolder. */ @@ -1960,8 +1960,8 @@ DENG2_PIMPL(ResourceSystem) /// @todo kludge: Give the converter a chance to complete. TimeDelta::fromMilliSeconds(1000).sleep(); - /// Update the /savegame folder. - Folder &outputFolder = App::rootFolder().locate(String("/savegame") / gameId); + /// Update the /savegames folder. + Folder &outputFolder = App::rootFolder().locate(String("/savegames") / gameId); outputFolder.populate(Folder::PopulateOnlyThisFolder); addSavedSession(repoPath); @@ -1982,7 +1982,7 @@ DENG2_PIMPL(ResourceSystem) // Once created, any existing saved sessions in this folder will be added automatically. // Make the native folder if necessary and populate the folder contents. - Folder &saveFolder = App::fileSystem().makeFolder(String("/savegame") / gameId); + Folder &saveFolder = App::fileSystem().makeFolder(String("/savegames") / gameId); // Find any .save packages in this folder and generate sessions for the db. DENG2_FOR_EACH_CONST(Folder::Contents, i, saveFolder.contents()) diff --git a/doomsday/libdeng2/src/game/savedsession.cpp b/doomsday/libdeng2/src/game/savedsession.cpp index 558d5005f6..6f113e5c34 100644 --- a/doomsday/libdeng2/src/game/savedsession.cpp +++ b/doomsday/libdeng2/src/game/savedsession.cpp @@ -215,7 +215,7 @@ DENG2_PIMPL(SavedSession) PackageFolder *tryLocatePackage() { - return App::fileSystem().root().tryLocate(String("/savegame") / repoPath + ".save"); + return App::fileSystem().root().tryLocate(String("/savegames") / repoPath + ".save"); } DENG2_PIMPL_AUDIENCE(MetadataChange) @@ -257,7 +257,7 @@ String SavedSession::description() const { return metadataAsStyledText(metadata()) + "\n" + String(_E(l) "Source file: " _E(.)_E(i) "\"%1\"") - .arg(hasFile()? NativePath(String("/home/savegame") / d->repoPath + ".save").pretty() : "None"); + .arg(hasFile()? NativePath(String("/home/savegames") / d->repoPath + ".save").pretty() : "None"); } String SavedSession::path() const @@ -272,7 +272,7 @@ void SavedSession::setPath(String newPath) bool SavedSession::hasFile() const { - return App::fileSystem().root().has(String("/savegame") / d->repoPath + ".save"); + return App::fileSystem().root().has(String("/savegames") / d->repoPath + ".save"); } PackageFolder &SavedSession::locateFile() @@ -334,7 +334,7 @@ void SavedSession::copyFile(SavedSession const &source) { if(&source == this) return; // Sanity check. - File &destFile = App::fileSystem().root().replaceFile(String("/savegame") / d->repoPath + ".save"); + File &destFile = App::fileSystem().root().replaceFile(String("/savegames") / d->repoPath + ".save"); Writer(destFile) << source.locateFile().archive(); destFile.flush(); destFile.setMode(File::ReadOnly); @@ -348,7 +348,7 @@ void SavedSession::removeFile() { if(hasFile()) { - App::fileSystem().root().removeFile(String("/savegame") / d->repoPath + ".save"); + App::fileSystem().root().removeFile(String("/savegames") / d->repoPath + ".save"); } /// Force a metadata update. diff --git a/doomsday/plugins/common/src/g_game.cpp b/doomsday/plugins/common/src/g_game.cpp index 3567b84e5c..9b471bc331 100644 --- a/doomsday/plugins/common/src/g_game.cpp +++ b/doomsday/plugins/common/src/g_game.cpp @@ -2931,7 +2931,7 @@ static int saveGameStateWorker(void *context) try { - de::Path const sessionPath = de::String("/savegame") / session->path(); + de::Path const sessionPath = de::String("/savegames") / session->path(); App_Log(DE2_LOG_VERBOSE, "Attempting save game to \"%s\"", sessionPath.toString().toLatin1().constData()); diff --git a/doomsday/plugins/common/src/gamesessionwriter.cpp b/doomsday/plugins/common/src/gamesessionwriter.cpp index fb5fce7ab1..e7eb4395a9 100644 --- a/doomsday/plugins/common/src/gamesessionwriter.cpp +++ b/doomsday/plugins/common/src/gamesessionwriter.cpp @@ -97,7 +97,7 @@ void GameSessionWriter::write(String const &userDescription) Writer_Delete(writer); } - File &outFile = App::rootFolder().locate("/savegame").replaceFile(d->session.path() + ".save"); + File &outFile = App::rootFolder().locate("/savegames").replaceFile(d->session.path() + ".save"); de::Writer(outFile) << arch; outFile.flush(); outFile.setMode(File::ReadOnly);