Skip to content

Commit

Permalink
libcommon|SaveSlots: Updated wrt saved session file format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Mar 9, 2014
1 parent 4bffeba commit 1630a51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 33 deletions.
19 changes: 4 additions & 15 deletions doomsday/plugins/common/include/saveslots.h
Expand Up @@ -80,20 +80,9 @@ class SaveSlots
de::game::SessionMetadata const &saveMetadata() const;

/**
* Returns the saved session game state file path (in the repository).
*
* @see mapStateFilePath()
*/
de::Path stateFilePath() const;

/**
* Returns the saved session map state file path (in the repository). Note that
* depending on how the game is configured, this may be the same as the game state
* file path.
*
* @see stateFilePath()
* Returns the saved session file path (in the repository).
*/
de::Path mapStateFilePath(Uri const *mapUri) const;
de::Path filePath() const;

/**
* Returns the saved session for the logical save slot.
Expand Down Expand Up @@ -156,7 +145,7 @@ class SaveSlots
Slot &slot(de::String slotId) const;

/**
* Lookup a slot by searching for a saved game session with a matching user description.
* Lookup a slot by searching for a saved session with a matching user description.
* The search is in ascending slot identifier order.
*
* @param description Description of the game-save to look for (not case sensitive).
Expand All @@ -168,7 +157,7 @@ class SaveSlots
Slot *slotByUserDescription(de::String description) const;

/**
* Copies all the saved session state files from one slot to another.
* Copies the saved session file from one slot to another.
*
* @see hasSlot()
*/
Expand Down
21 changes: 3 additions & 18 deletions doomsday/plugins/common/src/saveslots.cpp
Expand Up @@ -29,8 +29,6 @@
#include <de/Observers>
#include <map>

#define MAX_HUB_MAPS 99

static int cvarLastSlot = -1; ///< @c -1= Not yet loaded/saved in this game session.
static int cvarQuickSlot = -1; ///< @c -1= Not yet chosen/determined.

Expand Down Expand Up @@ -165,7 +163,7 @@ void SaveSlots::Slot::clear()
App_Log(DE2_RES_MSG, "Clearing save slot '%s'", d->id.toLatin1().constData());
}

savedSession().deleteFilesInRepository();
savedSession().deleteFileInRepository();
}

void SaveSlots::Slot::replaceSavedSession(SavedSession *newSession)
Expand All @@ -186,18 +184,12 @@ void SaveSlots::Slot::replaceSavedSession(SavedSession *newSession)
}
}

Path SaveSlots::Slot::stateFilePath() const
Path SaveSlots::Slot::filePath() const
{
SavedSession &session = savedSession();
return session.repository().folder().path() / session.fileName();
}

Path SaveSlots::Slot::mapStateFilePath(Uri const *mapUri) const
{
SavedSession &session = savedSession();
return session.repository().folder().path() / session.fileNameForMap(Str_Text(Uri_Compose(mapUri)));
}

DENG2_PIMPL_NOREF(SaveSlots)
{
typedef std::map<String, Slot *> Slots;
Expand Down Expand Up @@ -282,14 +274,7 @@ void SaveSlots::copySlot(String sourceSlotId, String destSlotId)
// Clear all save files at destination slot.
destSlot.clear();

for(int i = 0; i < MAX_HUB_MAPS; ++i)
{
Uri *mapUri = G_ComposeMapUri(gameEpisode, i);
SV_CopyFile(sourceSlot.mapStateFilePath(mapUri), destSlot.mapStateFilePath(mapUri));
Uri_Delete(mapUri);
}

SV_CopyFile(sourceSlot.stateFilePath(), destSlot.stateFilePath());
SV_CopyFile(sourceSlot.filePath(), destSlot.filePath());

// Copy save info too.
destSlot.replaceSavedSession(new SavedSession(sourceSlot.savedSession()));
Expand Down

0 comments on commit 1630a51

Please sign in to comment.