Skip to content

Commit

Permalink
Refactor|Game Save: Moved the save file path out of SaveInfo
Browse files Browse the repository at this point in the history
The save file path for a game save state should not be stored within
SaveInfo as this prevents us from "hot swapping" this metadata when
the associated logical save slot changes (e.g., when copying a slot).
  • Loading branch information
danij-deng committed Jul 31, 2012
1 parent 1a2e6e9 commit d6e62ae
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 162 deletions.
10 changes: 4 additions & 6 deletions doomsday/plugins/common/include/p_saveio.h
Expand Up @@ -59,17 +59,15 @@ const char* SV_SavePath(void);
const char* SV_ClientSavePath(void);
#endif

boolean SV_RecogniseState(SaveInfo* info);

/*
* File management
*/
LZFILE* SV_OpenFile(const char* fileName, const char* mode);
LZFILE* SV_OpenFile(const char* filePath, const char* mode);
void SV_CloseFile(void);
LZFILE* SV_File(void);
boolean SV_ExistingFile(char* name);
int SV_RemoveFile(const ddstring_t* path);
void SV_CopyFile(const ddstring_t* srcPath, const ddstring_t* destPath);
boolean SV_ExistingFile(const char* filePath);
int SV_RemoveFile(const Str* filePath);
void SV_CopyFile(const Str* srcPath, const Str* destPath);

#if __JHEXEN__
saveptr_t* SV_HxSavePtr(void);
Expand Down
8 changes: 0 additions & 8 deletions doomsday/plugins/common/include/saveinfo.h
Expand Up @@ -48,35 +48,27 @@ typedef struct saveheader_s {
* SaveInfo instance.
*/
typedef struct saveinfo_s {
ddstring_t filePath;
ddstring_t name;
uint gameId;
saveheader_t header;
} SaveInfo;

SaveInfo* SaveInfo_New(void);
SaveInfo* SaveInfo_NewWithFilePath(const ddstring_t* filePath);

void SaveInfo_Delete(SaveInfo* info);

const ddstring_t* SaveInfo_FilePath(SaveInfo* info);

uint SaveInfo_GameId(SaveInfo* info);

const saveheader_t* SaveInfo_Header(SaveInfo* info);

const ddstring_t* SaveInfo_Name(SaveInfo* info);

void SaveInfo_SetFilePath(SaveInfo* info, ddstring_t* newFilePath);

void SaveInfo_SetGameId(SaveInfo* info, uint newGameId);

void SaveInfo_SetName(SaveInfo* info, const ddstring_t* newName);

void SaveInfo_Configure(SaveInfo* info);

void SaveInfo_Update(SaveInfo* info);

/**
* @return Is this state loadable for the current game session.
*/
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/common/src/hu_menu.c
Expand Up @@ -5578,12 +5578,12 @@ void Hu_MenuUpdateGameSaveWidgets(void)
{
mn_object_t* obj = MN_MustFindObjectOnPage(page, 0, saveSlotObjectIds[i]);
mndata_edit_t* edit = (mndata_edit_t*) obj->_typedata;
SaveInfo* info = SV_SaveInfoForSlot(edit->data2);
const char* text = "";

MNObject_SetFlags(obj, FO_SET, MNF_DISABLED);
if(SaveInfo_IsLoadable(info))
if(SV_IsSlotUsed(edit->data2))
{
SaveInfo* info = SV_SaveInfoForSlot(edit->data2);
text = Str_Text(SaveInfo_Name(info));
MNObject_SetFlags(obj, FO_CLEAR, MNF_DISABLED);
}
Expand Down

0 comments on commit d6e62ae

Please sign in to comment.