Skip to content

Commit

Permalink
API: Added Def_Get() identifier DD_DEF_MUSIC_CDTRACK
Browse files Browse the repository at this point in the history
Returns the CD track attributed to the referenced music definition.
  • Loading branch information
danij-deng committed Jan 24, 2014
1 parent b6b852d commit c2eef61
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions doomsday/api/dd_share.h
Expand Up @@ -219,6 +219,7 @@ enum {
DD_PLUGIN_HOMEURL,
DD_PLUGIN_DOCSURL,
DD_DEF_ACTION,
DD_DEF_MUSIC_CDTRACK,

// Non-integer/special values for Set/Get
DD_UNUSED9, // DD_TRANSLATIONTABLES_ADDRESS,
Expand Down
1 change: 1 addition & 0 deletions doomsday/client/include/def_main.h
Expand Up @@ -102,6 +102,7 @@ int Def_GetActionNum(char const *id);
spritenum_t Def_GetSpriteNum(char const *name);

int Def_GetModelNum(const char* id);
ded_music_t* Def_GetMusic(char const *id);
int Def_GetMusicNum(const char* id);
int Def_GetSoundNum(const char* id);
ded_flag_t* Def_GetFlag(const char* id);
Expand Down
22 changes: 22 additions & 0 deletions doomsday/client/src/def_main.cpp
Expand Up @@ -293,6 +293,21 @@ int Def_GetSoundNumForName(const char* name)
return 0;
}

ded_music_t* Def_GetMusic(char const *id)
{
if(id && id[0] && defs.count.music.num)
{
for(int i = 0; i < defs.count.music.num; ++i)
{
if(!stricmp(defs.music[i].id, id))
{
return &defs.music[i];
}
}
}
return 0;
}

int Def_GetMusicNum(const char* id)
{
int idx = -1;
Expand Down Expand Up @@ -2214,6 +2229,13 @@ int Def_Get(int type, const char* id, void* out)
case DD_DEF_MUSIC:
return Def_GetMusicNum(id);

case DD_DEF_MUSIC_CDTRACK:
if(ded_music_t *music = Def_GetMusic(id))
{
return music->cdTrack;
}
return false;

case DD_DEF_MAP_INFO: {
ddmapinfo_t *mout;
struct uri_s *mapUri = Uri_NewWithPath2(id, RC_NULL);
Expand Down

0 comments on commit c2eef61

Please sign in to comment.