Skip to content

Commit

Permalink
libcommon: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Feb 22, 2014
1 parent 542ad9b commit 6b873cd
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
15 changes: 2 additions & 13 deletions doomsday/plugins/common/include/g_common.h
Expand Up @@ -156,7 +156,6 @@ D_CMD( CCmdExitLevel );
#if __cplusplus
#include "gamestatereader.h"

class SaveInfo;
class SaveSlots;

/**
Expand All @@ -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
2 changes: 0 additions & 2 deletions doomsday/plugins/common/include/saveinfo.h
Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions doomsday/plugins/common/src/g_game.cpp
Expand Up @@ -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()
Expand Down
24 changes: 20 additions & 4 deletions doomsday/plugins/common/src/saveinfo.cpp
Expand Up @@ -29,6 +29,20 @@
#include <de/NativePath>
#include <cstring>

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.
Expand Down Expand Up @@ -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()
{
Expand All @@ -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("");
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/doom/src/d_main.cpp
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion doomsday/plugins/heretic/src/h_main.cpp
Expand Up @@ -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();
Expand Down

0 comments on commit 6b873cd

Please sign in to comment.