diff --git a/doomsday/libdoomsday/include/doomsday/defs/ded.h b/doomsday/libdoomsday/include/doomsday/defs/ded.h index 5981b9194e..f626145ee2 100644 --- a/doomsday/libdoomsday/include/doomsday/defs/ded.h +++ b/doomsday/libdoomsday/include/doomsday/defs/ded.h @@ -86,7 +86,8 @@ struct LIBDOOMSDAY_PUBLIC ded_s DEDArray sounds; // Music. - DEDArray music; + //DEDArray music; + DEDRegister musics; // Map information. //DEDArray mapInfo; @@ -144,6 +145,8 @@ struct LIBDOOMSDAY_PUBLIC ded_s int addModel(); + int addMusic(); + int addSky(); //ded_flag_t *getFlag(char const *flag) const; @@ -181,19 +184,17 @@ struct LIBDOOMSDAY_PUBLIC ded_s * @param name Sound name. * @return If the name is not found, returns the NULL sound index (zero). */ - int getSoundNumForName(const char* name) const; - - ded_music_t *getMusic(char const *id) const; + int getSoundNumForName(char const *name) const; - int getMusicNum(const char* id) const; + int getMusicNum(char const *id) const; - ded_value_t* getValueById(char const* id) const; + ded_value_t *getValueById(char const *id) const; - ded_value_t* getValueByUri(de::Uri const &uri) const; + ded_value_t *getValueByUri(de::Uri const &uri) const; - ded_compositefont_t* findCompositeFontDef(de::Uri const& uri) const; + ded_compositefont_t *findCompositeFontDef(de::Uri const &uri) const; - ded_compositefont_t* getCompositeFont(char const* uriCString) const; + ded_compositefont_t *getCompositeFont(char const *uriCString) const; protected: void release(); @@ -219,7 +220,7 @@ LIBDOOMSDAY_PUBLIC int DED_AddMaterialLayerStage(ded_material_layer_t *ml); int DED_AddMaterialDecorationStage(ded_material_decoration_t *li); //int DED_AddSky(ded_t* ded, char const* id); int DED_AddSound(ded_t* ded, char const* id); -LIBDOOMSDAY_PUBLIC int DED_AddMusic(ded_t* ded, char const* id); +//LIBDOOMSDAY_PUBLIC int DED_AddMusic(ded_t* ded, char const* id); //int DED_AddMapInfo(ded_t* ded, char const* uri); int DED_AddText(ded_t* ded, char const* id); int DED_AddTextureEnv(ded_t* ded, char const* id); diff --git a/doomsday/libdoomsday/include/doomsday/defs/dedtypes.h b/doomsday/libdoomsday/include/doomsday/defs/dedtypes.h index 007af45aca..c1989bb836 100644 --- a/doomsday/libdoomsday/include/doomsday/defs/dedtypes.h +++ b/doomsday/libdoomsday/include/doomsday/defs/dedtypes.h @@ -46,7 +46,7 @@ typedef ded_stringid_t ded_string_t; typedef ded_stringid_t ded_mobjid_t; typedef ded_stringid_t ded_stateid_t; typedef ded_stringid_t ded_soundid_t; -typedef ded_stringid_t ded_musicid_t; +//typedef ded_stringid_t ded_musicid_t; typedef ded_stringid_t ded_funcid_t; typedef char ded_func_t[DED_FUNC_LEN + 1]; typedef int ded_flags_t; @@ -331,6 +331,7 @@ typedef struct LIBDOOMSDAY_PUBLIC ded_sound_s { } } ded_sound_t; +#if 0 typedef struct LIBDOOMSDAY_PUBLIC ded_music_s { ded_musicid_t id; // ID of this piece of music. ded_string_t lumpName; // Lump name. @@ -345,7 +346,6 @@ typedef struct LIBDOOMSDAY_PUBLIC ded_music_s { } } ded_music_t; -#if 0 typedef struct LIBDOOMSDAY_PUBLIC ded_skylayer_s { ded_flags_t flags; de::Uri* material; @@ -405,9 +405,7 @@ typedef struct LIBDOOMSDAY_PUBLIC ded_sky_s { } } } ded_sky_t; -#endif -#if 0 typedef struct LIBDOOMSDAY_PUBLIC ded_mapinfo_s { de::Uri* uri; // ID of the map (e.g. E2M3 or MAP21). ded_string_t name; // Name of the map. diff --git a/doomsday/libdoomsday/src/defs/ded.cpp b/doomsday/libdoomsday/src/defs/ded.cpp index 3f175a0f2d..800702d43c 100644 --- a/doomsday/libdoomsday/src/defs/ded.cpp +++ b/doomsday/libdoomsday/src/defs/ded.cpp @@ -21,6 +21,7 @@ #include "doomsday/defs/episode.h" #include "doomsday/defs/mapinfo.h" #include "doomsday/defs/model.h" +#include "doomsday/defs/music.h" #include "doomsday/defs/sky.h" #include @@ -54,6 +55,7 @@ ded_s::ded_s() , episodes(names.addRecord("episodes")) , mapInfos(names.addRecord("mapInfos")) , models (names.addRecord("models")) + , musics (names.addRecord("musics")) , skies (names.addRecord("skies")) { flags.addLookupKey("id"); @@ -61,6 +63,7 @@ ded_s::ded_s() mapInfos.addLookupKey("id"); models.addLookupKey("id", DEDRegister::OnlyFirst); models.addLookupKey("state"); + musics.addLookupKey("id", DEDRegister::OnlyFirst); skies.addLookupKey("id"); clear(); @@ -105,6 +108,13 @@ int ded_s::addModel() return def.geti("__order__"); } +int ded_s::addMusic() +{ + Record &def = musics.append(); + defn::Music(def).resetToDefaults(); + return def.geti("__order__"); +} + int ded_s::addSky() { Record &def = skies.append(); @@ -122,7 +132,7 @@ void ded_s::release() lights.clear(); models.clear(); sounds.clear(); - music.clear(); + musics.clear(); mapInfos.clear(); skies.clear(); details.clear(); @@ -147,32 +157,6 @@ int DED_AddMobj(ded_t* ded, char const* idstr) return ded->mobjs.indexOf(mo); } -#if 0 -int DED_AddSky(ded_t* ded, char const* id) -{ - ded_sky_t *sky = ded->skies.append(); - int i; - - strcpy(sky->id, id); - sky->height = DEFAULT_SKY_HEIGHT; - for(i = 0; i < NUM_SKY_LAYERS; ++i) - { - sky->layers[i].offset = DEFAULT_SKY_SPHERE_XOFFSET; - sky->layers[i].colorLimit = DEFAULT_SKY_SPHERE_FADEOUT_LIMIT; - } - for(i = 0; i < NUM_SKY_MODELS; ++i) - { - sky->models[i].frameInterval = 1; - sky->models[i].color[0] = 1; - sky->models[i].color[1] = 1; - sky->models[i].color[2] = 1; - sky->models[i].color[3] = 1; - } - - return ded->skies.indexOf(sky); -} -#endif - int DED_AddState(ded_t* ded, char const* id) { ded_state_t *st = ded->states.append(); @@ -225,54 +209,6 @@ int DED_AddSound(ded_t* ded, char const* id) return ded->sounds.indexOf(snd); } -int DED_AddMusic(ded_t* ded, char const* id) -{ - ded_music_t* mus = ded->music.append(); - strcpy(mus->id, id); - return ded->music.indexOf(mus); -} - -#if 0 -int DED_AddMapInfo(ded_t* ded, char const* uri) -{ - ded_mapinfo_t* inf = ded->mapInfo.append(); - int i; - - if(uri) - { - inf->uri = new de::Uri(uri, RC_NULL); - if(inf->uri->scheme().isEmpty()) - inf->uri->setScheme("Maps"); - } - inf->gravity = 1; - inf->parTime = -1; // unknown - - inf->fogColor[0] = DEFAULT_FOG_COLOR_RED; - inf->fogColor[1] = DEFAULT_FOG_COLOR_GREEN; - inf->fogColor[2] = DEFAULT_FOG_COLOR_BLUE; - inf->fogDensity = DEFAULT_FOG_DENSITY; - inf->fogStart = DEFAULT_FOG_START; - inf->fogEnd = DEFAULT_FOG_END; - - inf->sky.height = DEFAULT_SKY_HEIGHT; - for(i = 0; i < NUM_SKY_LAYERS; ++i) - { - inf->sky.layers[i].offset = DEFAULT_SKY_SPHERE_XOFFSET; - inf->sky.layers[i].colorLimit = DEFAULT_SKY_SPHERE_FADEOUT_LIMIT; - } - for(i = 0; i < NUM_SKY_MODELS; ++i) - { - inf->sky.models[i].frameInterval = 1; - inf->sky.models[i].color[0] = 1; - inf->sky.models[i].color[1] = 1; - inf->sky.models[i].color[2] = 1; - inf->sky.models[i].color[3] = 1; - } - - return ded->mapInfo.indexOf(inf); -} -#endif - int DED_AddText(ded_t* ded, char const* id) { ded_text_t* txt = ded->text.append(); @@ -509,20 +445,6 @@ int ded_s::getStateNum(char const *id) const return idx; } -/* -ded_flag_t *ded_s::getFlag(char const *flag) const -{ - if(!flag || !flag[0]) return 0; - - for(int i = flags.size() - 1; i >= 0; i--) - { - if(!qstricmp(flags[i].id, flag)) - return &flags[i]; - } - - return 0; -}*/ - int ded_s::evalFlags2(char const *ptr) const { LOG_AS("Def_EvalFlags"); @@ -636,30 +558,23 @@ int ded_s::getSoundNumForName(const char *name) const return 0; } -ded_music_t *ded_s::getMusic(char const *id) const +int ded_s::getMusicNum(const char* id) const { - if(id && id[0] && music.size()) + if(Record const *def = musics.tryFind("id", id)) { - for(int i = 0; i < music.size(); ++i) - { - if(!qstricmp(music[i].id, id)) - return &music[i]; - } + return def->geti("__order__"); } - return 0; -} + return -1; -int ded_s::getMusicNum(const char* id) const -{ - int idx = -1; - if(id && id[0] && music.size()) + /*int idx = -1; + if(id && id[0] && musics.size()) { int i = 0; do { - if(!qstricmp(music[i].id, id)) idx = i; - } while(idx == -1 && ++i < music.size()); + if(!qstricmp(musics[i].id, id)) idx = i; + } while(idx == -1 && ++i < musics.size()); } - return idx; + return idx;*/ } ded_value_t* ded_s::getValueById(char const* id) const diff --git a/doomsday/libdoomsday/src/defs/dedparser.cpp b/doomsday/libdoomsday/src/defs/dedparser.cpp index cb9adece7b..39fedda7d8 100644 --- a/doomsday/libdoomsday/src/defs/dedparser.cpp +++ b/doomsday/libdoomsday/src/defs/dedparser.cpp @@ -43,6 +43,7 @@ #include "doomsday/defs/mapgraphnode.h" #include "doomsday/defs/mapinfo.h" #include "doomsday/defs/model.h" +#include "doomsday/defs/music.h" #include "doomsday/defs/sky.h" #include "doomsday/filesys/fs_main.h" #include "doomsday/filesys/fs_util.h" @@ -775,6 +776,7 @@ DENG2_PIMPL(DEDParser) int prevMaterialDefIdx = -1; // For "Copy". int prevModelDefIdx = -1; // For "Copy". int prevMapInfoDefIdx = -1; // For "Copy". + int prevMusicDefIdx = -1; // For "Copy". int prevSkyDefIdx = -1; // For "Copy". int prevDetailDefIdx = -1; // For "Copy". int prevGenDefIdx = -1; // For "Copy". @@ -1731,25 +1733,31 @@ DENG2_PIMPL(DEDParser) } if(ISTOKEN("Music")) - { // A new music. - ded_music_t* mus; + { + // New musics are appended to the end of the list. + idx = ded->addMusic(); + Record &mus = ded->musics[idx]; - idx = DED_AddMusic(ded, ""); - mus = &ded->music[idx]; + if(prevMusicDefIdx >= 0) + { + if(bCopyNext) ded->musics.copy(prevMusicDefIdx, mus); + } FINDBEGIN; - for(;;) + forever { READLABEL; - RV_STR("ID", mus->id) - RV_STR("Lump", mus->lumpName) - RV_URI("File name", &mus->path, "Music") - RV_URI("File", &mus->path, "Music") - RV_URI("Ext", &mus->path, "Music") // Both work. - RV_INT("CD track", mus->cdTrack) + RV_STR("ID", mus["id"]) + RV_STR("Lump", mus["lumpName"]) + RV_URI("File name", mus["path"], "Music") + RV_URI("File", mus["path"], "Music") + RV_URI("Ext", mus["path"], "Music") // Both work. + RV_INT("CD track", mus["cdTrack"]) RV_END CHECKSC; } + + prevMusicDefIdx = idx; } if(ISTOKEN("Sky"))