Skip to content

Commit

Permalink
Refactor|libcommon|SaveInfo|SaveSlots: Use C++ SaveInfo and SaveSlots…
Browse files Browse the repository at this point in the history
… APIs throughout, dumped C APIs
  • Loading branch information
danij-deng committed Feb 18, 2014
1 parent afb1f2a commit a375b55
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 371 deletions.
2 changes: 1 addition & 1 deletion doomsday/plugins/common/include/p_saveg.h
Expand Up @@ -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

Expand Down
42 changes: 1 addition & 41 deletions doomsday/plugins/common/include/saveinfo.h
Expand Up @@ -20,11 +20,10 @@

#ifndef LIBCOMMON_SAVEINFO
#define LIBCOMMON_SAVEINFO
#ifdef __cplusplus

#include "doomsday.h"
#include "common.h"

#ifdef __cplusplus
#include <de/Path>

/**
Expand Down Expand Up @@ -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
36 changes: 2 additions & 34 deletions doomsday/plugins/common/include/saveslots.h
Expand Up @@ -20,11 +20,10 @@

#ifndef LIBCOMMON_SAVESLOTS_H
#define LIBCOMMON_SAVESLOTS_H
#ifdef __cplusplus

#include "common.h"
#include "saveinfo.h"

#ifdef __cplusplus
#include <de/Error>
#include <de/Path>

Expand Down Expand Up @@ -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

0 comments on commit a375b55

Please sign in to comment.