Skip to content

Commit

Permalink
API|libcommon: DD_GetVariable() now provides access to the DED database
Browse files Browse the repository at this point in the history
libcommon provides a Defs() helper function, returning a reference to
the engine's DED database (ded_t).
  • Loading branch information
danij-deng committed Jul 28, 2014
1 parent 9f1abd0 commit a7cd483
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
3 changes: 2 additions & 1 deletion doomsday/api/dd_share.h
Expand Up @@ -258,7 +258,8 @@ enum {
DD_TM_CEILING_Z, ///< output from P_CheckPosition
DD_SHIFT_DOWN,
DD_GAME_RECOMMENDS_SAVING, ///< engine asks whether game should be saved (e.g., when upgrading) (game's GetInteger)
DD_NOTIFY_GAME_SAVED ///< savegame was written
DD_NOTIFY_GAME_SAVED, ///< savegame was written
DD_DEFS ///< engine definition database (DED)
};

//------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions doomsday/client/src/dd_main.cpp
Expand Up @@ -2596,6 +2596,9 @@ void *DD_GetVariable(int ddvalue)
fracTic = gameTime * TICSPERSEC;
return &fracTic; }

case DD_DEFS:
return &defs;

default: break;
}

Expand Down
32 changes: 19 additions & 13 deletions doomsday/plugins/common/include/g_defs.h
Expand Up @@ -22,23 +22,16 @@
#define LIBCOMMON_DEFINITION_UTILS_H

#ifdef __cplusplus
#include <doomsday/defs/ded.h>
#include <doomsday/uri.h>

extern "C" {
#endif
typedef void EpisodeInfo;
typedef void MapInfo;

/**
* @return The default for a value (retrieved from Doomsday).
* Provides access to the engine's definition database (DED).
*/
int GetDefInt(char const *def, int *returnVal);

void GetDefState(char const *def, int *returnVal);

#ifdef __cplusplus
} // extern "C"

typedef void EpisodeInfo;
typedef void MapInfo;
ded_t &Defs();

/**
* @param id Identifier of the episode to lookup info for.
Expand Down Expand Up @@ -74,5 +67,18 @@ MapInfo *P_CurrentMapInfo();
*/
de::Uri P_TranslateMap(uint map);

#endif // __cplusplus
extern "C" {
#endif

/**
* @return The default for a value (retrieved from Doomsday).
*/
int GetDefInt(char const *def, int *returnVal);

void GetDefState(char const *def, int *returnVal);

#ifdef __cplusplus
} // extern "C"
#endif

#endif // LIBCOMMON_DEFINITION_UTILS_H
6 changes: 6 additions & 0 deletions doomsday/plugins/common/src/g_defs.cpp
Expand Up @@ -19,10 +19,16 @@
*/

#include "common.h"
#include "g_common.h"
#include "g_defs.h"

using namespace de;

ded_t &Defs()
{
return *static_cast<ded_t *>(DD_GetVariable(DD_DEFS));
}

int GetDefInt(char const *def, int *returnVal)
{
// Get the value.
Expand Down

0 comments on commit a7cd483

Please sign in to comment.