diff --git a/doomsday/plugins/common/include/p_savedef.h b/doomsday/plugins/common/include/p_savedef.h index 6ccfd1112e..0ab322df0d 100644 --- a/doomsday/plugins/common/include/p_savedef.h +++ b/doomsday/plugins/common/include/p_savedef.h @@ -70,7 +70,6 @@ # define SAVEGAME_DEFAULT_DIR "hexndata" # define MOBJ_XX_PLAYER -2 -# define MAX_MAPS 99 # define BASE_SLOT 6 # define REBORN_SLOT 7 # define REBORN_DESCRIPTION "TEMP GAME" diff --git a/doomsday/plugins/common/include/p_saveg.h b/doomsday/plugins/common/include/p_saveg.h index 0d8514e8d7..0b81edc33a 100644 --- a/doomsday/plugins/common/include/p_saveg.h +++ b/doomsday/plugins/common/include/p_saveg.h @@ -87,6 +87,20 @@ const gamesaveinfo_t* SV_GetGameSaveInfoForSlot(int slot); boolean SV_GetClientGameSavePathForGameId(uint gameId, ddstring_t* path); #endif +#if __JHEXEN__ +void SV_HxInitBaseSlot(void); + +/** + * Copies the base slot to the reborn slot. + */ +void SV_HxUpdateRebornSlot(void); + +void SV_HxClearRebornSlot(void); + +int SV_HxGetRebornSlot(void); +boolean SV_HxRebornSlotAvailable(void); +#endif + boolean SV_SaveGame(int slot, const char* name); boolean SV_LoadGame(int slot); diff --git a/doomsday/plugins/common/include/p_saveio.h b/doomsday/plugins/common/include/p_saveio.h index c48fa415a3..1c61d17714 100644 --- a/doomsday/plugins/common/include/p_saveio.h +++ b/doomsday/plugins/common/include/p_saveio.h @@ -92,16 +92,6 @@ boolean SV_GetGameSavePathForSlot(int slot, ddstring_t* path); boolean SV_GetGameSavePathForMapSlot(uint map, int slot, ddstring_t* path); #endif -#if __JHEXEN__ - -void SV_HxInitBaseSlot(void); -void SV_HxUpdateRebornSlot(void); -void SV_HxClearRebornSlot(void); -boolean SV_HxRebornSlotAvailable(void); -int SV_HxGetRebornSlot(void); - -boolean SV_ExistingFile(char *name); - /** * Deletes all save game files associated with a slot number. */ @@ -112,8 +102,10 @@ void SV_ClearSaveSlot(int slot); */ void SV_CopySaveSlot(int sourceSlot, int destSlot); -saveptr_t* SV_HxSavePtr(void); +#if __JHEXEN__ +boolean SV_ExistingFile(char* name); +saveptr_t* SV_HxSavePtr(void); #endif // __JHEXEN__ /* @@ -132,6 +124,7 @@ void SV_WriteLong(unsigned int val); void SV_WriteLong(long val); #endif void SV_WriteFloat(float val); + void SV_Read(void* data, int len); byte SV_ReadByte(void); short SV_ReadShort(void); diff --git a/doomsday/plugins/common/src/p_saveg.c b/doomsday/plugins/common/src/p_saveg.c index 932cbe1a00..9577654281 100644 --- a/doomsday/plugins/common/src/p_saveg.c +++ b/doomsday/plugins/common/src/p_saveg.c @@ -397,6 +397,47 @@ void SV_Register(void) Con_AddVariable(cvars + i); } +#if __JHEXEN__ +void SV_HxInitBaseSlot(void) +{ + errorIfNotInited("SV_HxInitBaseSlot"); + SV_ClearSaveSlot(BASE_SLOT); +} + +void SV_HxUpdateRebornSlot(void) +{ + errorIfNotInited("SV_HxUpdateRebornSlot"); + SV_ClearSaveSlot(REBORN_SLOT); + SV_CopySaveSlot(BASE_SLOT, REBORN_SLOT); +} + +void SV_HxClearRebornSlot(void) +{ + errorIfNotInited("SV_HxClearRebornSlot"); + SV_ClearSaveSlot(REBORN_SLOT); +} + +int SV_HxGetRebornSlot(void) +{ + errorIfNotInited("SV_HxGetRebornSlot"); + return (REBORN_SLOT); +} + +boolean SV_HxRebornSlotAvailable(void) +{ + ddstring_t path; + boolean result = false; + errorIfNotInited("SV_HxRebornSlotAvailable"); + Str_InitStd(&path); + if(SV_GetGameSavePathForSlot(REBORN_SLOT, &path)) + { + result = SV_ExistingFile(Str_Text(&path)); + } + Str_Free(&path); + return result; +} +#endif + #if __JHEXEN__ void SV_SetSaveVersion(int version) { diff --git a/doomsday/plugins/common/src/p_saveio.c b/doomsday/plugins/common/src/p_saveio.c index 5b024d5f55..1ca87b2685 100644 --- a/doomsday/plugins/common/src/p_saveio.c +++ b/doomsday/plugins/common/src/p_saveio.c @@ -34,6 +34,8 @@ #include "p_savedef.h" #include "materialarchive.h" +#define MAX_HUB_MAPS 99 + static boolean inited; static LZFILE* savefile; static ddstring_t savePath; // e.g., "savegame/" @@ -269,13 +271,14 @@ boolean SV_ExistingFile(char* name) return false; } } +#endif void SV_ClearSaveSlot(int slot) { AutoStr* path; { int i; - for(i = 0; i < MAX_MAPS; ++i) + for(i = 0; i < MAX_HUB_MAPS; ++i) { path = composeGameSavePathForSlot2(slot, i); removeFile(path); @@ -284,7 +287,6 @@ void SV_ClearSaveSlot(int slot) path = composeGameSavePathForSlot(slot); removeFile(path); } -#endif boolean SV_IsValidSlot(int slot) { @@ -520,14 +522,13 @@ boolean SV_GetGameSavePathForSlot(int slot, ddstring_t* path) #if __JHEXEN__ boolean SV_GetGameSavePathForMapSlot(uint map, int slot, ddstring_t* path) { - errorIfNotInited("SV_GetGameSavePathForSlot"); + errorIfNotInited("SV_GetGameSavePathForMapSlot"); if(!path) return false; Str_CopyOrClear(path, composeGameSavePathForSlot2(slot, (int)map)); return !Str_IsEmpty(path); } #endif -#if __JHEXEN__ void SV_CopySaveSlot(int sourceSlot, int destSlot) { AutoStr* src, *dst; @@ -549,7 +550,7 @@ void SV_CopySaveSlot(int sourceSlot, int destSlot) } { int i; - for(i = 0; i < MAX_MAPS; ++i) + for(i = 0; i < MAX_HUB_MAPS; ++i) { src = composeGameSavePathForSlot2(sourceSlot, i); dst = composeGameSavePathForSlot2(destSlot, i); @@ -561,43 +562,6 @@ void SV_CopySaveSlot(int sourceSlot, int destSlot) copyFile(src, dst); } -/** - * Copies the base slot to the reborn slot. - */ -void SV_HxUpdateRebornSlot(void) -{ - errorIfNotInited("SV_HxUpdateRebornSlot"); - SV_ClearSaveSlot(REBORN_SLOT); - SV_CopySaveSlot(BASE_SLOT, REBORN_SLOT); -} - -void SV_HxClearRebornSlot(void) -{ - errorIfNotInited("SV_HxClearRebornSlot"); - SV_ClearSaveSlot(REBORN_SLOT); -} - -int SV_HxGetRebornSlot(void) -{ - errorIfNotInited("SV_HxGetRebornSlot"); - return (REBORN_SLOT); -} - -boolean SV_HxRebornSlotAvailable(void) -{ - AutoStr* path; - errorIfNotInited("SV_HxRebornSlotAvailable"); - path = composeGameSavePathForSlot(REBORN_SLOT); - return path && SV_ExistingFile(Str_Text(path)); -} - -void SV_HxInitBaseSlot(void) -{ - errorIfNotInited("SV_HxInitBaseSlot"); - SV_ClearSaveSlot(BASE_SLOT); -} -#endif - void SV_Write(const void* data, int len) { errorIfNotInited("SV_Write");