From a375b55849c0fb86ac9956698383940b47967e58 Mon Sep 17 00:00:00 2001 From: danij Date: Tue, 18 Feb 2014 00:40:56 +0000 Subject: [PATCH] Refactor|libcommon|SaveInfo|SaveSlots: Use C++ SaveInfo and SaveSlots APIs throughout, dumped C APIs --- doomsday/plugins/common/include/p_saveg.h | 2 +- doomsday/plugins/common/include/saveinfo.h | 42 +------ doomsday/plugins/common/include/saveslots.h | 36 +----- doomsday/plugins/common/src/g_game.cpp | 111 ++++++++--------- doomsday/plugins/common/src/hu_menu.cpp | 13 +- doomsday/plugins/common/src/saveinfo.cpp | 129 -------------------- doomsday/plugins/common/src/saveslots.cpp | 95 -------------- doomsday/plugins/doom/src/d_main.cpp | 4 +- doomsday/plugins/doom64/src/d_main.cpp | 4 +- doomsday/plugins/heretic/src/h_main.cpp | 4 +- doomsday/plugins/hexen/src/h2_main.cpp | 4 +- 11 files changed, 73 insertions(+), 371 deletions(-) diff --git a/doomsday/plugins/common/include/p_saveg.h b/doomsday/plugins/common/include/p_saveg.h index e43c79a6af..ce3e29d199 100644 --- a/doomsday/plugins/common/include/p_saveg.h +++ b/doomsday/plugins/common/include/p_saveg.h @@ -32,9 +32,9 @@ DENG_EXTERN_C int saveToRealPlayerNum[MAXPLAYERS]; DENG_EXTERN_C targetplraddress_t *targetPlayerAddrs; #endif +#ifdef __cplusplus DENG_EXTERN_C SaveSlots *saveSlots; -#ifdef __cplusplus extern "C" { #endif diff --git a/doomsday/plugins/common/include/saveinfo.h b/doomsday/plugins/common/include/saveinfo.h index 1f0ec71448..48b19c9951 100644 --- a/doomsday/plugins/common/include/saveinfo.h +++ b/doomsday/plugins/common/include/saveinfo.h @@ -20,11 +20,10 @@ #ifndef LIBCOMMON_SAVEINFO #define LIBCOMMON_SAVEINFO +#ifdef __cplusplus #include "doomsday.h" #include "common.h" - -#ifdef __cplusplus #include /** @@ -143,43 +142,4 @@ class SaveInfo }; #endif // __cplusplus - -// C wrapper API --------------------------------------------------------------- - -#ifdef __cplusplus -extern "C" { -#else -typedef void *SaveInfo; -#endif - -SaveInfo *SaveInfo_New(void); -SaveInfo *SaveInfo_Dup(SaveInfo const *other); - -void SaveInfo_Delete(SaveInfo *info); - -SaveInfo *SaveInfo_Copy(SaveInfo *info, SaveInfo const *other); -dd_bool SaveInfo_IsLoadable(SaveInfo *info); -Str const *SaveInfo_GameIdentityKey(SaveInfo const *info); -void SaveInfo_SetGameIdentityKey(SaveInfo *info, Str const *newGameIdentityKey); -Str const *SaveInfo_Description(SaveInfo const *info); -void SaveInfo_SetDescription(SaveInfo *info, Str const *newDescription); -int SaveInfo_Version(SaveInfo const *info); -void SaveInfo_SetVersion(SaveInfo *info, int newVersion); -uint SaveInfo_SessionId(SaveInfo const *info); -void SaveInfo_SetSessionId(SaveInfo *info, uint newSessionId); -Uri const *SaveInfo_MapUri(SaveInfo const *info); -void SaveInfo_SetMapUri(SaveInfo *info, Uri const *newMapUri); -#if !__JHEXEN__ -int SaveInfo_MapTime(SaveInfo const *info); -void SaveInfo_SetMapTime(SaveInfo *info, int newMapTime); -#endif -GameRuleset const *SaveInfo_GameRules(SaveInfo const *info); -void SaveInfo_SetGameRules(SaveInfo *info, GameRuleset const *newRules); -void SaveInfo_Write(SaveInfo *info, Writer *writer); -void SaveInfo_Read(SaveInfo *info, Reader *reader); - -#ifdef __cplusplus -} // extern "C" -#endif - #endif // LIBCOMMON_SAVEINFO diff --git a/doomsday/plugins/common/include/saveslots.h b/doomsday/plugins/common/include/saveslots.h index 7363ddaa1c..ca7a181f39 100644 --- a/doomsday/plugins/common/include/saveslots.h +++ b/doomsday/plugins/common/include/saveslots.h @@ -20,11 +20,10 @@ #ifndef LIBCOMMON_SAVESLOTS_H #define LIBCOMMON_SAVESLOTS_H +#ifdef __cplusplus #include "common.h" #include "saveinfo.h" - -#ifdef __cplusplus #include #include @@ -171,37 +170,6 @@ class SaveSlots private: DENG2_PRIVATE(d) }; -#endif // __cplusplus - -// C wrapper API --------------------------------------------------------------- - -#ifdef __cplusplus -extern "C" { -#else -typedef void *SaveSlots; -#endif - -SaveSlots *SaveSlots_New(int slotCount); -void SaveSlots_Delete(SaveSlots *sslots); - -void SaveSlots_ClearAllSaveInfo(SaveSlots *sslots); -void SaveSlots_UpdateAllSaveInfo(SaveSlots *sslots); -int SaveSlots_SlotCount(SaveSlots const *sslots); -dd_bool SaveSlots_IsValidSlot(SaveSlots const *sslots, int slot); -AutoStr *SaveSlots_ComposeSlotIdentifier(SaveSlots const *sslots, int slot); -int SaveSlots_ParseSlotIdentifier(SaveSlots const *sslots, char const *str); -int SaveSlots_FindSlotWithSaveDescription(SaveSlots const *sslots, char const *description); -dd_bool SaveSlots_SlotInUse(SaveSlots const *sslots, int slot); -dd_bool SaveSlots_SlotIsUserWritable(SaveSlots const *sslots, int slot); -SaveInfo *SaveSlots_SaveInfo(SaveSlots *sslots, int slot); -void SaveSlots_ReplaceSaveInfo(SaveSlots *sslots, int slot, SaveInfo *newInfo); -void SaveSlots_ClearSlot(SaveSlots *sslots, int slot); -void SaveSlots_CopySlot(SaveSlots *sslots, int sourceSlot, int destSlot); - -void SaveSlots_ConsoleRegister(); - -#ifdef __cplusplus -} // extern "C" -#endif +#endif // __cplusplus #endif // LIBCOMMON_SAVESLOTS_H diff --git a/doomsday/plugins/common/src/g_game.cpp b/doomsday/plugins/common/src/g_game.cpp index 1341f21728..ff082c5d87 100644 --- a/doomsday/plugins/common/src/g_game.cpp +++ b/doomsday/plugins/common/src/g_game.cpp @@ -502,7 +502,7 @@ void G_CommonPreInit() G_Register(); // Read-only game status cvars (for playsim). Pause_Register(); G_ControlRegister(); // For controls/input. - SaveSlots_ConsoleRegister(); // Game-save system. + SaveSlots::consoleRegister(); // Game-save system. Hu_MenuRegister(); // For the menu. GUI_Register(); // For the UI library. Hu_MsgRegister(); // For the game messages. @@ -2064,7 +2064,7 @@ int rebornLoadConfirmResponse(msgresponse_t response, int userValue, void* userP { #if __JHEXEN__ // Load the last autosave? (Not optional in Hexen). - if(SaveSlots_SlotInUse(saveSlots, AUTO_SLOT)) + if(saveSlots->slotInUse(AUTO_SLOT)) { gaLoadGameSlot = AUTO_SLOT; G_SetGameAction(GA_LOADGAME); @@ -2101,13 +2101,13 @@ void G_DoReborn(int plrNum) int lastSlot = -1; // First ensure we have up-to-date info. - SaveSlots_UpdateAllSaveInfo(saveSlots); + saveSlots->updateAllSaveInfo(); // Use the latest save? if(cfg.loadLastSaveOnReborn) { lastSlot = Con_GetInteger("game-save-last-slot"); - if(!SaveSlots_SlotInUse(saveSlots, lastSlot)) lastSlot = -1; + if(!saveSlots->slotInUse(lastSlot)) lastSlot = -1; } // Use the latest autosave? (Not optional in Hexen). @@ -2115,7 +2115,7 @@ void G_DoReborn(int plrNum) if(cfg.loadAutoSaveOnReborn) { autoSlot = AUTO_SLOT; - if(!SaveSlots_SlotInUse(saveSlots, autoSlot)) autoSlot = -1; + if(!saveSlots->slotInUse(autoSlot)) autoSlot = -1; } #endif @@ -2128,9 +2128,9 @@ void G_DoReborn(int plrNum) { // Everything appears to be in order - schedule the game-save load! #if !__JHEXEN__ - const int chosenSlot = (lastSlot >= 0? lastSlot : autoSlot); + int const chosenSlot = (lastSlot >= 0? lastSlot : autoSlot); #else - const int chosenSlot = lastSlot; + int const chosenSlot = lastSlot; #endif if(!cfg.confirmRebornLoad) { @@ -2140,8 +2140,8 @@ void G_DoReborn(int plrNum) else { // Compose the confirmation message. - SaveInfo *info = SaveSlots_SaveInfo(saveSlots, chosenSlot); - AutoStr *msg = Str_Appendf(AutoStr_NewStd(), REBORNLOAD_CONFIRM, Str_Text(SaveInfo_Description(info))); + SaveInfo *info = saveSlots->saveInfoPtr(chosenSlot); + AutoStr *msg = Str_Appendf(AutoStr_NewStd(), REBORNLOAD_CONFIRM, Str_Text(info->description())); S_LocalSound(SFX_REBORNLOAD_CONFIRM, NULL); Hu_MsgStart(MSG_YESNO, Str_Text(msg), rebornLoadConfirmResponse, chosenSlot, 0); } @@ -2150,7 +2150,7 @@ void G_DoReborn(int plrNum) // Autosave loading cannot be disabled in Hexen. #if __JHEXEN__ - if(SaveSlots_SlotInUse(saveSlots, AUTO_SLOT)) + if(saveSlots->slotInUse(AUTO_SLOT)) { gaLoadGameSlot = AUTO_SLOT; G_SetGameAction(GA_LOADGAME); @@ -2166,13 +2166,13 @@ void G_DoReborn(int plrNum) static void G_InitNewGame() { #if __JHEXEN__ - SaveSlots_ClearSlot(saveSlots, BASE_SLOT); + saveSlots->clearSlot(BASE_SLOT); #endif /// @todo Do not clear this save slot. Instead we should set a game state /// flag to signal when a new game should be started instead of loading /// the autosave slot. - SaveSlots_ClearSlot(saveSlots, AUTO_SLOT); + saveSlots->clearSlot(AUTO_SLOT); #if __JHEXEN__ Game_InitACScriptsForNewGame(); @@ -2804,7 +2804,7 @@ void G_DoLeaveMap() { if(!gameRules.deathmatch) { - SaveSlots_ClearSlot(saveSlots, BASE_SLOT); + saveSlots->clearSlot(BASE_SLOT); } } @@ -2968,9 +2968,9 @@ dd_bool G_LoadGame(int slot) // no guarantee that the game-save will be accessible come load time. // First ensure we have up-to-date info. - SaveSlots_UpdateAllSaveInfo(saveSlots); + saveSlots->updateAllSaveInfo(); - if(!SaveSlots_SlotInUse(saveSlots, slot)) + if(!saveSlots->slotInUse(slot)) { App_Log(DE2_RES_ERROR, "Cannot load from save slot #%i: not in use", slot); return false; @@ -2999,7 +2999,7 @@ void G_DoLoadGame() if(IS_NETGAME) return; // Copy the base slot to the autosave slot. - SaveSlots_CopySlot(saveSlots, BASE_SLOT, AUTO_SLOT); + saveSlots->copySlot(BASE_SLOT, AUTO_SLOT); #endif } @@ -3018,7 +3018,7 @@ dd_bool G_IsSaveGamePossible() dd_bool G_SaveGame2(int slot, char const *name) { - if(0 > slot || slot >= SaveSlots_SlotCount(saveSlots)) return false; + if(0 > slot || slot >= saveSlots->slotCount()) return false; if(!G_IsSaveGamePossible()) return false; @@ -3102,11 +3102,11 @@ void G_DoSaveGame() else { // No name specified. - SaveInfo *info = SaveSlots_SaveInfo(saveSlots, gaSaveGameSlot); - if(!gaSaveGameGenerateName && !Str_IsEmpty(SaveInfo_Description(info))) + SaveInfo *info = saveSlots->saveInfoPtr(gaSaveGameSlot); + if(!gaSaveGameGenerateName && !Str_IsEmpty(info->description())) { // Slot already in use; reuse the existing name. - name = Str_Text(SaveInfo_Description(info)); + name = Str_Text(info->description()); } else { @@ -3962,15 +3962,12 @@ D_CMD(LoadGame) } // Ensure we have up-to-date info. - SaveSlots_UpdateAllSaveInfo(saveSlots); + saveSlots->updateAllSaveInfo(); - slot = SaveSlots_ParseSlotIdentifier(saveSlots, argv[1]); - if(SaveSlots_SlotInUse(saveSlots, slot)) + slot = saveSlots->parseSlotIdentifier(argv[1]); + if(saveSlots->slotInUse(slot)) { // A known used slot identifier. - SaveInfo *info; - AutoStr *msg; - if(confirm || !cfg.confirmQuickGameSave) { // Try to schedule a GA_LOADGAME action. @@ -3978,9 +3975,9 @@ D_CMD(LoadGame) return G_LoadGame(slot); } - info = SaveSlots_SaveInfo(saveSlots, slot); + SaveInfo *info = saveSlots->saveInfoPtr(slot); // Compose the confirmation message. - msg = Str_Appendf(AutoStr_NewStd(), QLPROMPT, Str_Text(SaveInfo_Description(info))); + AutoStr *msg = Str_Appendf(AutoStr_NewStd(), QLPROMPT, Str_Text(info->description())); S_LocalSound(SFX_QUICKLOAD_PROMPT, NULL); Hu_MsgStart(MSG_YESNO, Str_Text(msg), loadGameConfirmResponse, slot, 0); @@ -4036,9 +4033,8 @@ D_CMD(SaveGame) { DENG_UNUSED(src); - const dd_bool confirm = (argc >= 3 && !stricmp(argv[argc-1], "confirm")); - player_t* player = &players[CONSOLEPLAYER]; - int slot; + dd_bool const confirm = (argc >= 3 && !stricmp(argv[argc-1], "confirm")); + player_t *player = &players[CONSOLEPLAYER]; if(G_QuitInProgress()) return false; @@ -4063,17 +4059,16 @@ D_CMD(SaveGame) } // Ensure we have up-to-date info. - SaveSlots_UpdateAllSaveInfo(saveSlots); + saveSlots->updateAllSaveInfo(); - slot = SaveSlots_ParseSlotIdentifier(saveSlots, argv[1]); - if(SaveSlots_SlotIsUserWritable(saveSlots, slot)) + int slot = saveSlots->parseSlotIdentifier(argv[1]); + if(saveSlots->slotIsUserWritable(slot)) { // A known slot identifier. - dd_bool const slotIsUsed = SaveSlots_SlotInUse(saveSlots, slot); - SaveInfo *info = SaveSlots_SaveInfo(saveSlots, slot); - ddstring_t localName, *name; - AutoStr *msg; + dd_bool const slotIsUsed = saveSlots->slotInUse(slot); + SaveInfo *info = saveSlots->saveInfoPtr(slot); + ddstring_t localName; Str_InitStatic(&localName, (argc >= 3 && stricmp(argv[2], "confirm"))? argv[2] : ""); if(!slotIsUsed || confirm || !cfg.confirmQuickGameSave) { @@ -4083,10 +4078,10 @@ D_CMD(SaveGame) } // Compose the confirmation message. - msg = Str_Appendf(AutoStr_NewStd(), QSPROMPT, Str_Text(SaveInfo_Description(info))); + AutoStr *msg = Str_Appendf(AutoStr_NewStd(), QSPROMPT, Str_Text(info->description())); // Make a copy of the name. - name = Str_Copy(Str_New(), &localName); + ddstring_t *name = Str_Copy(Str_New(), &localName); S_LocalSound(SFX_QUICKSAVE_PROMPT, NULL); Hu_MsgStart(MSG_YESNO, Str_Text(msg), saveGameConfirmResponse, slot, (void*)name); @@ -4103,10 +4098,14 @@ D_CMD(SaveGame) } // Clearly the caller needs some assistance... - if(!SaveSlots_IsValidSlot(saveSlots, slot)) + if(!saveSlots->isValidSlot(slot)) + { App_Log(DE2_SCR_WARNING, "Failed to determine save slot from \"%s\"", argv[1]); + } else + { App_Log(DE2_LOG_ERROR, "Save slot #%i is non-user-writable", slot); + } // No action means the command failed. return false; @@ -4122,19 +4121,17 @@ D_CMD(QuickSaveGame) dd_bool G_DeleteSaveGame(int slot) { - SaveInfo *info; - - if(!SaveSlots_SlotIsUserWritable(saveSlots, slot)) return false; - if(!SaveSlots_SlotInUse(saveSlots, slot)) return false; + if(!saveSlots->slotIsUserWritable(slot)) return false; + if(!saveSlots->slotInUse(slot)) return false; // A known slot identifier. - info = SaveSlots_SaveInfo(saveSlots, slot); + SaveInfo *info = saveSlots->saveInfoPtr(slot); DENG_ASSERT(info != 0); - SaveSlots_ClearSlot(saveSlots, slot); + saveSlots->clearSlot(slot); if(Hu_MenuIsActive()) { - mn_page_t* activePage = Hu_MenuActivePage(); + mn_page_t *activePage = Hu_MenuActivePage(); if(activePage == Hu_MenuFindPageByName("LoadGame") || activePage == Hu_MenuFindPageByName("SaveGame")) { @@ -4166,11 +4163,11 @@ D_CMD(DeleteGameSave) if(G_QuitInProgress()) return false; // Ensure we have up-to-date info. - SaveSlots_UpdateAllSaveInfo(saveSlots); + saveSlots->updateAllSaveInfo(); - int slot = SaveSlots_ParseSlotIdentifier(saveSlots, argv[1]); - if(SaveSlots_SlotIsUserWritable(saveSlots, slot) && - SaveSlots_SlotInUse(saveSlots, slot)) + int slot = saveSlots->parseSlotIdentifier(argv[1]); + if(saveSlots->slotIsUserWritable(slot) && + saveSlots->slotInUse(slot)) { // A known slot identifier. if(confirm) @@ -4180,8 +4177,8 @@ D_CMD(DeleteGameSave) else { // Compose the confirmation message. - SaveInfo *info = SaveSlots_SaveInfo(saveSlots, slot); - AutoStr *msg = Str_Appendf(AutoStr_NewStd(), DELETESAVEGAME_CONFIRM, Str_Text(SaveInfo_Description(info))); + SaveInfo *info = saveSlots->saveInfoPtr(slot); + AutoStr *msg = Str_Appendf(AutoStr_NewStd(), DELETESAVEGAME_CONFIRM, Str_Text(info->description())); S_LocalSound(SFX_DELETESAVEGAME_CONFIRM, NULL); Hu_MsgStart(MSG_YESNO, Str_Text(msg), deleteSaveGameConfirmResponse, slot, 0); } @@ -4189,10 +4186,14 @@ D_CMD(DeleteGameSave) } // Clearly the caller needs some assistance... - if(!SaveSlots_IsValidSlot(saveSlots, slot)) + if(!saveSlots->isValidSlot(slot)) + { App_Log(DE2_SCR_WARNING, "Failed to determine save slot from \"%s\"", argv[1]); + } else + { App_Log(DE2_LOG_ERROR, "Save slot #%i is non-user-writable", slot); + } // No action means the command failed. return false; diff --git a/doomsday/plugins/common/src/hu_menu.cpp b/doomsday/plugins/common/src/hu_menu.cpp index 2597b43e28..42b5cdfeec 100644 --- a/doomsday/plugins/common/src/hu_menu.cpp +++ b/doomsday/plugins/common/src/hu_menu.cpp @@ -5734,29 +5734,26 @@ void Hu_MenuUpdateGameSaveWidgets() MNF_ID6, MNF_ID7 #endif }; - mn_page_t *page; - int i; if(!menuActive) return; // Prompt a refresh of the game-save info. We don't yet actively monitor // the contents of the game-save paths, so instead we settle for manual // updates whenever the save/load menu is opened. - SaveSlots_UpdateAllSaveInfo(saveSlots); + saveSlots->updateAllSaveInfo(); // Update widgets. - page = Hu_MenuFindPageByName("LoadGame"); - for(i = 0; i < NUMSAVESLOTS; ++i) + mn_page_t *page = Hu_MenuFindPageByName("LoadGame"); + for(int i = 0; i < NUMSAVESLOTS; ++i) { mn_object_t *obj = MN_MustFindObjectOnPage(page, 0, saveSlotObjectIds[i]); mndata_edit_t *edit = (mndata_edit_t *) obj->_typedata; char const *text = ""; MNObject_SetFlags(obj, FO_SET, MNF_DISABLED); - if(SaveSlots_SlotInUse(saveSlots, edit->data2)) + if(saveSlots->slotInUse(edit->data2)) { - SaveInfo *info = SaveSlots_SaveInfo(saveSlots, edit->data2); - text = Str_Text(SaveInfo_Description(info)); + text = Str_Text(saveSlots->saveInfo(edit->data2).description()); MNObject_SetFlags(obj, FO_CLEAR, MNF_DISABLED); } MNEdit_SetText(obj, MNEDIT_STF_NO_ACTION, text); diff --git a/doomsday/plugins/common/src/saveinfo.cpp b/doomsday/plugins/common/src/saveinfo.cpp index c67cadd480..f310c26d30 100644 --- a/doomsday/plugins/common/src/saveinfo.cpp +++ b/doomsday/plugins/common/src/saveinfo.cpp @@ -456,132 +456,3 @@ void SaveInfo::setMagic(int newMagic) { d->magic = newMagic; } - -// C wrapper API --------------------------------------------------------------- - -SaveInfo *SaveInfo_New() -{ - return new SaveInfo; -} - -SaveInfo *SaveInfo_Dup(SaveInfo const *other) -{ - DENG_ASSERT(other != 0); - return new SaveInfo(*other); -} - -void SaveInfo_Delete(SaveInfo *info) -{ - if(info) delete info; -} - -SaveInfo *SaveInfo_Copy(SaveInfo *info, SaveInfo const *other) -{ - DENG_ASSERT(info != 0 && other != 0); - *info = *other; - return info; -} - -uint SaveInfo_SessionId(SaveInfo const *info) -{ - DENG_ASSERT(info != 0); - return info->sessionId(); -} - -void SaveInfo_SetSessionId(SaveInfo *info, uint newSessionId) -{ - DENG_ASSERT(info != 0); - info->setSessionId(newSessionId); -} - -Str const *SaveInfo_GameIdentityKey(SaveInfo const *info) -{ - DENG_ASSERT(info != 0); - return info->gameIdentityKey(); -} - -void SaveInfo_SetGameIdentityKey(SaveInfo *info, Str const *newGameIdentityKey) -{ - DENG_ASSERT(info != 0); - info->setGameIdentityKey(newGameIdentityKey); -} - -Str const *SaveInfo_Description(SaveInfo const *info) -{ - DENG_ASSERT(info != 0); - return info->description(); -} - -void SaveInfo_SetDescription(SaveInfo *info, Str const *newName) -{ - DENG_ASSERT(info != 0); - info->setDescription(newName); -} - -int SaveInfo_Version(SaveInfo const *info) -{ - DENG_ASSERT(info != 0); - return info->version(); -} - -void SaveInfo_SetVersion(SaveInfo *info, int newVersion) -{ - DENG_ASSERT(info != 0); - info->setVersion(newVersion); -} - -Uri const *SaveInfo_MapUri(SaveInfo const *info) -{ - DENG_ASSERT(info != 0); - return info->mapUri(); -} - -void SaveInfo_SetMapUri(SaveInfo *info, Uri const *newMapUri) -{ - DENG_ASSERT(info != 0); - info->setMapUri(newMapUri); -} - -#if !__JHEXEN__ -int SaveInfo_MapTime(SaveInfo const *info) -{ - DENG_ASSERT(info != 0); - return info->mapTime(); -} - -void SaveInfo_SetMapTime(SaveInfo *info, int newMapTime) -{ - DENG_ASSERT(info != 0); - info->setMapTime(newMapTime); -} -#endif - -GameRuleset const *SaveInfo_GameRules(SaveInfo const *info) -{ - DENG_ASSERT(info != 0); - return &info->gameRules(); -} - -void SaveInfo_SetGameRules(SaveInfo *info, GameRuleset const *newRules) -{ - DENG_ASSERT(info != 0 && newRules != 0); - info->setGameRules(*newRules); -} - -dd_bool SaveInfo_IsLoadable(SaveInfo *info) -{ - DENG_ASSERT(info != 0); - return info->isLoadable(); -} - -void SaveInfo_Write(SaveInfo *info, Writer *writer) -{ - DENG_ASSERT(info != 0); - info->write(writer); -} - -void SaveInfo_Read(SaveInfo *info, Reader *reader) -{ - DENG_ASSERT(info != 0); - info->read(reader); -} diff --git a/doomsday/plugins/common/src/saveslots.cpp b/doomsday/plugins/common/src/saveslots.cpp index 2d26a633ca..885679e19d 100644 --- a/doomsday/plugins/common/src/saveslots.cpp +++ b/doomsday/plugins/common/src/saveslots.cpp @@ -369,98 +369,3 @@ void SaveSlots::consoleRegister() // static // Aliases for obsolete cvars: C_VAR_BYTE("menu-quick-ask", &cfg.confirmQuickGameSave, 0, 0, 1); } - -// C wrapper API --------------------------------------------------------------- - -SaveSlots *SaveSlots_New(int slotCount) -{ - return new SaveSlots(slotCount); -} - -void SaveSlots_Delete(SaveSlots *sslots) -{ - delete sslots; -} - -void SaveSlots_ClearAllSaveInfo(SaveSlots *sslots) -{ - DENG_ASSERT(sslots != 0); - sslots->clearAllSaveInfo(); -} - -void SaveSlots_UpdateAllSaveInfo(SaveSlots *sslots) -{ - DENG_ASSERT(sslots != 0); - sslots->updateAllSaveInfo(); -} - -int SaveSlots_SlotCount(SaveSlots const *sslots) -{ - DENG_ASSERT(sslots != 0); - return sslots->slotCount(); -} - -dd_bool SaveSlots_IsValidSlot(SaveSlots const *sslots, int slot) -{ - DENG_ASSERT(sslots != 0); - return sslots->isValidSlot(slot); -} - -AutoStr *SaveSlots_ComposeSlotIdentifier(SaveSlots const *sslots, int slot) -{ - DENG_ASSERT(sslots != 0); - return sslots->composeSlotIdentifier(slot); -} - -int SaveSlots_ParseSlotIdentifier(SaveSlots const *sslots, char const *str) -{ - DENG_ASSERT(sslots != 0); - return sslots->parseSlotIdentifier(str); -} - -int SaveSlots_FindSlotWithSaveDescription(SaveSlots const *sslots, char const *description) -{ - DENG_ASSERT(sslots != 0); - return sslots->findSlotWithSaveDescription(description); -} - -dd_bool SaveSlots_SlotInUse(SaveSlots const *sslots, int slot) -{ - DENG_ASSERT(sslots != 0); - return sslots->slotInUse(slot); -} - -dd_bool SaveSlots_SlotIsUserWritable(SaveSlots const *sslots, int slot) -{ - DENG_ASSERT(sslots != 0); - return sslots->slotIsUserWritable(slot); -} - -SaveInfo *SaveSlots_SaveInfo(SaveSlots *sslots, int slot) -{ - DENG_ASSERT(sslots != 0); - return sslots->saveInfoPtr(slot); -} - -void SaveSlots_ReplaceSaveInfo(SaveSlots *sslots, int slot, SaveInfo *newInfo) -{ - DENG_ASSERT(sslots != 0); - sslots->replaceSaveInfo(slot, newInfo); -} - -void SaveSlots_ClearSlot(SaveSlots *sslots, int slot) -{ - DENG_ASSERT(sslots != 0); - sslots->clearSlot(slot); -} - -void SaveSlots_CopySlot(SaveSlots *sslots, int sourceSlot, int destSlot) -{ - DENG_ASSERT(sslots != 0); - sslots->copySlot(sourceSlot, destSlot); -} - -void SaveSlots_ConsoleRegister() -{ - SaveSlots::consoleRegister(); -} diff --git a/doomsday/plugins/doom/src/d_main.cpp b/doomsday/plugins/doom/src/d_main.cpp index 90037702cd..90361e45dc 100644 --- a/doomsday/plugins/doom/src/d_main.cpp +++ b/doomsday/plugins/doom/src/d_main.cpp @@ -451,8 +451,8 @@ void D_PostInit() p = CommandLine_Check("-loadgame"); if(p && p < myargc - 1) { - int const slotNumber = SaveSlots_ParseSlotIdentifier(saveSlots, CommandLine_At(p + 1)); - if(SaveSlots_SlotIsUserWritable(saveSlots, slotNumber) && G_LoadGame(slotNumber)) + int const slotNumber = saveSlots->parseSlotIdentifier(CommandLine_At(p + 1)); + if(saveSlots->slotIsUserWritable(slotNumber) && G_LoadGame(slotNumber)) { // No further initialization is to be done. return; diff --git a/doomsday/plugins/doom64/src/d_main.cpp b/doomsday/plugins/doom64/src/d_main.cpp index cecd4a9649..4b988521a5 100644 --- a/doomsday/plugins/doom64/src/d_main.cpp +++ b/doomsday/plugins/doom64/src/d_main.cpp @@ -358,8 +358,8 @@ void D_PostInit() p = CommandLine_Check("-loadgame"); if(p && p < myargc - 1) { - int const slotNumber = SaveSlots_ParseSlotIdentifier(saveSlots, CommandLine_At(p + 1)); - if(SaveSlots_SlotIsUserWritable(saveSlots, slotNumber) && G_LoadGame(slotNumber)) + int const slotNumber = saveSlots->parseSlotIdentifier(CommandLine_At(p + 1)); + if(saveSlots->slotIsUserWritable(slotNumber) && G_LoadGame(slotNumber)) { // No further initialization is to be done. return; diff --git a/doomsday/plugins/heretic/src/h_main.cpp b/doomsday/plugins/heretic/src/h_main.cpp index 7166ce2cd4..a90b91daa9 100644 --- a/doomsday/plugins/heretic/src/h_main.cpp +++ b/doomsday/plugins/heretic/src/h_main.cpp @@ -379,8 +379,8 @@ void H_PostInit() p = CommandLine_Check("-loadgame"); if(p && p < myargc - 1) { - int const slotNumber = SaveSlots_ParseSlotIdentifier(saveSlots, CommandLine_At(p + 1)); - if(SaveSlots_SlotIsUserWritable(saveSlots, slotNumber) && G_LoadGame(slotNumber)) + int const slotNumber = saveSlots->parseSlotIdentifier(CommandLine_At(p + 1)); + if(saveSlots->slotIsUserWritable(slotNumber) && G_LoadGame(slotNumber)) { // No further initialization is to be done. return; diff --git a/doomsday/plugins/hexen/src/h2_main.cpp b/doomsday/plugins/hexen/src/h2_main.cpp index 30aeb28a13..daaaac0eac 100644 --- a/doomsday/plugins/hexen/src/h2_main.cpp +++ b/doomsday/plugins/hexen/src/h2_main.cpp @@ -355,8 +355,8 @@ void X_PostInit() p = CommandLine_CheckWith("-loadgame", 1); if(p != 0) { - int const slotNumber = SaveSlots_ParseSlotIdentifier(saveSlots, CommandLine_At(p + 1)); - if(SaveSlots_SlotIsUserWritable(saveSlots, slotNumber) && G_LoadGame(slotNumber)) + int const slotNumber = saveSlots->parseSlotIdentifier(CommandLine_At(p + 1)); + if(saveSlots->slotIsUserWritable(slotNumber) && G_LoadGame(slotNumber)) { // No further initialization is to be done. return;