Skip to content

Commit

Permalink
Fixed|Hexen: Record Variable 'songLump' not found
Browse files Browse the repository at this point in the history
Removed obsolete logic for the Hexen specific, "currentMap" handling
Updated the SndInfoParser to modify the relevant Music definition
directly (Hexen uses separate Music definitions for each map).

IssueID #1910
  • Loading branch information
danij-deng committed Nov 23, 2014
1 parent c111db2 commit 360e4e2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 41 deletions.
17 changes: 0 additions & 17 deletions doomsday/plugins/common/src/gamesession.cpp
Expand Up @@ -630,23 +630,6 @@ DENG2_PIMPL(GameSession), public SavedSession::IMapStateReaderFactory
// Restart the map music?
if(!briefing)
{
#if __JHEXEN__
/**
* @note Kludge: Due to the way music is managed with Hexen, unless we explicitly stop
* the current playing track the engine will not change tracks. This is due to the use
* of the runtime-updated "currentmap" definition (the engine thinks music has not changed
* because the current Music definition is the same).
*
* It only worked previously was because the waiting-for-map-load song was started prior
* to map loading.
*
* @todo Rethink the Music definition stuff with regard to Hexen. Why not create definitions
* during startup by parsing MAPINFO?
*/
S_StopMusic();
//S_StartMusic("chess", true); // Waiting-for-map-load song
#endif

S_MapMusic(mapUri);
S_PauseMusic(true);
}
Expand Down
22 changes: 7 additions & 15 deletions doomsday/plugins/common/src/p_sound.cpp
Expand Up @@ -36,22 +36,11 @@ void S_MapMusic(de::Uri const &mapUri)
{
if(Record const *mapInfo = Defs().mapInfos.tryFind("id", mapUri.compose()))
{
#ifdef __JHEXEN__
// Update the 'currentmap' music definition.
String const songId = "currentmap";

Record &music = Defs().musics.find("id", songId);
music.set("lumpName", mapInfo->gets("songLump"));
music.set("cdTrack", mapInfo->geti("cdTrack", 0));
#else
String const songId = mapInfo->gets("music");
#endif

int const songNumber = Defs().getMusicNum(songId.toUtf8().constData());
if(S_StartMusicNum(songNumber, true))
Block const musicIdUtf8 = mapInfo->gets("music").toUtf8();
if(S_StartMusic(musicIdUtf8.constData(), true))
{
// Set the game status cvar for the map music.
Con_SetInteger2("map-music", songNumber, SVF_WRITE_OVERRIDE);
Con_SetInteger2("map-music", Defs().getMusicNum(musicIdUtf8.constData()), SVF_WRITE_OVERRIDE);
}
}
}
Expand Down Expand Up @@ -120,7 +109,10 @@ void SndInfoParser(ddstring_s const *path)
{
if(Record *mapInfo = Defs().mapInfos.tryFind("id", G_ComposeMapUri(0, mapNumber - 1).compose()))
{
mapInfo->set("songLump", Str_Text(lumpName));
if(Record *music = Defs().musics.tryFind("id", mapInfo->gets("music")))
{
music->set("lumpName", Str_Text(lumpName));
}
}
}
continue;
Expand Down
5 changes: 0 additions & 5 deletions doomsday/plugins/hexen/defs/jhexen.ded
Expand Up @@ -22,11 +22,6 @@ Sound {
Max channels = -1;
}

# The contents of the 'currentmap' definition change at runtime.
Music {
ID = "currentmap";
}

Include "flags.ded";
Include "fonts.ded";
Include "objects.ded";
Expand Down
12 changes: 8 additions & 4 deletions doomsday/plugins/idtech1converter/src/mapinfotranslator.cpp
Expand Up @@ -79,7 +79,7 @@ namespace internal {

// Add all expected fields with their default values.
addText ("id", "");
addNumber ("cdTrack", 0);
addNumber ("cdTrack", 1);
}
};

Expand Down Expand Up @@ -1433,9 +1433,13 @@ DENG2_PIMPL_NOREF(MapInfoTranslator)

String const musicId = mapId + "_music";
os << "\n\nMusic {"
<< "\n ID = \"" + musicId + "\";"
<< "\n Lump = \"" + info.gets("music") + "\";"
<< "\n CD Track = " + String::number(info.geti("cdTrack")) + ";"
<< "\n ID = \"" + musicId + "\";";
String const musicLumpName = info.gets("music");
if(!musicLumpName.isEmpty())
{
os << "\n Lump = \"" + musicLumpName + "\";";
}
os << "\n CD Track = " + String::number(info.geti("cdTrack")) + ";"
<< "\n}";

bool const doubleSky = info.getb("doubleSky");
Expand Down

0 comments on commit 360e4e2

Please sign in to comment.