diff --git a/doomsday/plugins/common/include/g_common.h b/doomsday/plugins/common/include/g_common.h index 35e238d74d..358d58004e 100644 --- a/doomsday/plugins/common/include/g_common.h +++ b/doomsday/plugins/common/include/g_common.h @@ -156,7 +156,6 @@ D_CMD( CCmdExitLevel ); #if __cplusplus #include "gamestatereader.h" -class SaveInfo; class SaveSlots; /** @@ -165,20 +164,10 @@ class SaveSlots; SaveSlots &G_SaveSlots(); /** - * Declare a new saved game state reader/interpreter. - * - * @param recognizer Format recognizer function. - * @param maker Reader instantiator function. + * Returns the game's GameStateReaderFactory. */ -void G_DeclareGameStateReader(GameStateRecognizeFunc recognizer, GameStateReaderMakeFunc maker); +GameStateReaderFactory &G_GameStateReaderFactory(); -/** - * Determines whether the game session associated with save @a info is interpretable as a - * potentially loadable savegame state. - * - * @param info SaveInfo to attempt to read game session header into. - */ -bool G_RecognizeGameState(SaveInfo &info); #endif // __cplusplus #endif // LIBCOMMON_GAME_H diff --git a/doomsday/plugins/common/include/saveinfo.h b/doomsday/plugins/common/include/saveinfo.h index c62228e990..0abd47a0dc 100644 --- a/doomsday/plugins/common/include/saveinfo.h +++ b/doomsday/plugins/common/include/saveinfo.h @@ -87,12 +87,10 @@ class SaveInfo */ bool gameSessionIsLoadable() const; -#if __JHEXEN__ /** * Determines whether a saved map session exists. */ bool haveMapSession(uint map) const; -#endif /** * Attempt to update the save info from the named saved game session file. If the save path diff --git a/doomsday/plugins/common/src/g_game.cpp b/doomsday/plugins/common/src/g_game.cpp index a9351daafd..a004a9e914 100644 --- a/doomsday/plugins/common/src/g_game.cpp +++ b/doomsday/plugins/common/src/g_game.cpp @@ -937,14 +937,9 @@ SaveSlots &G_SaveSlots() return sslots; } -void G_DeclareGameStateReader(GameStateRecognizeFunc recognizer, GameStateReaderMakeFunc maker) +GameStateReaderFactory &G_GameStateReaderFactory() { - gameStateReaderFactory.declareReader(recognizer, maker); -} - -bool G_RecognizeGameState(SaveInfo &info) -{ - return gameStateReaderFactory.recognize(info); + return gameStateReaderFactory; } de::Path G_ChooseRootSaveDirectory() diff --git a/doomsday/plugins/common/src/saveinfo.cpp b/doomsday/plugins/common/src/saveinfo.cpp index a4cca01d33..72e5b1f009 100644 --- a/doomsday/plugins/common/src/saveinfo.cpp +++ b/doomsday/plugins/common/src/saveinfo.cpp @@ -29,6 +29,20 @@ #include #include +namespace internal +{ + static bool usingSeparateMapSessionFiles() + { +#ifdef __JHEXEN__ + return true; +#else + return false; +#endif + } +} + +using namespace internal; + DENG2_PIMPL_NOREF(SaveInfo) { de::String fileName; ///< Name of the game state file. @@ -306,12 +320,14 @@ bool SaveInfo::gameSessionIsLoadable() const return true; // It's good! } -#if __JHEXEN__ bool SaveInfo::haveMapSession(uint map) const { - return SV_ExistingFile(SV_SavePath() / fileNameForMap(map)); + if(usingSeparateMapSessionFiles()) + { + return SV_ExistingFile(SV_SavePath() / fileNameForMap(map)); + } + return haveGameSession(); } -#endif void SaveInfo::updateFromFile() { @@ -324,7 +340,7 @@ void SaveInfo::updateFromFile() } // Is this a recognized game state? - if(!G_RecognizeGameState(*this)) + if(!G_GameStateReaderFactory().recognize(*this)) { // Clear the info. setUserDescription(""); diff --git a/doomsday/plugins/doom/src/d_main.cpp b/doomsday/plugins/doom/src/d_main.cpp index ff0ac9e026..a8182af7f4 100644 --- a/doomsday/plugins/doom/src/d_main.cpp +++ b/doomsday/plugins/doom/src/d_main.cpp @@ -398,7 +398,8 @@ void D_PostInit() G_CommonPostInit(); // Declare the Doom V9 game state reader/interpreter. - G_DeclareGameStateReader(&DoomV9GameStateReader::recognize, &DoomV9GameStateReader::make); + G_GameStateReaderFactory().declareReader(&DoomV9GameStateReader::recognize, + &DoomV9GameStateReader::make); // Initialize ammo info. P_InitAmmoInfo(); diff --git a/doomsday/plugins/heretic/src/h_main.cpp b/doomsday/plugins/heretic/src/h_main.cpp index 03c98b79cd..0c556ab527 100644 --- a/doomsday/plugins/heretic/src/h_main.cpp +++ b/doomsday/plugins/heretic/src/h_main.cpp @@ -334,7 +334,8 @@ void H_PostInit() G_CommonPostInit(); // Declare the Heretic V13 game state reader/interpreter. - G_DeclareGameStateReader(&HereticV13GameStateReader::recognize, &HereticV13GameStateReader::make); + G_GameStateReaderFactory().declareReader(&HereticV13GameStateReader::recognize, + &HereticV13GameStateReader::make); // Initialize weapon info using definitions. P_InitWeaponInfo();