Skip to content

Commit

Permalink
Resource System: Changed default savegame folder to /home/savegames
Browse files Browse the repository at this point in the history
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/<game-id> while Hexen
used /home/hexndata/<game-id>).

Existing old savegames are automatically converted by the engine and
will be output to the new /home/savegames/<game-id> location.

Keeping the new .save packages separate from the old savegames should
help to keep things tidy.
  • Loading branch information
danij-deng committed Mar 21, 2014
1 parent a402ecf commit 532a189
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions doomsday/client/src/resource/resourcesystem.cpp
Expand Up @@ -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"));
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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<Folder>(String("/savegame") / gameId);
/// Update the /savegames folder.
Folder &outputFolder = App::rootFolder().locate<Folder>(String("/savegames") / gameId);
outputFolder.populate(Folder::PopulateOnlyThisFolder);

addSavedSession(repoPath);
Expand All @@ -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())
Expand Down
10 changes: 5 additions & 5 deletions doomsday/libdeng2/src/game/savedsession.cpp
Expand Up @@ -215,7 +215,7 @@ DENG2_PIMPL(SavedSession)

PackageFolder *tryLocatePackage()
{
return App::fileSystem().root().tryLocate<PackageFolder>(String("/savegame") / repoPath + ".save");
return App::fileSystem().root().tryLocate<PackageFolder>(String("/savegames") / repoPath + ".save");
}

DENG2_PIMPL_AUDIENCE(MetadataChange)
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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);
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/g_game.cpp
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/gamesessionwriter.cpp
Expand Up @@ -97,7 +97,7 @@ void GameSessionWriter::write(String const &userDescription)
Writer_Delete(writer);
}

File &outFile = App::rootFolder().locate<Folder>("/savegame").replaceFile(d->session.path() + ".save");
File &outFile = App::rootFolder().locate<Folder>("/savegames").replaceFile(d->session.path() + ".save");
de::Writer(outFile) << arch;
outFile.flush();
outFile.setMode(File::ReadOnly);
Expand Down

0 comments on commit 532a189

Please sign in to comment.