From fc1fbfe8b351884e5ca5ef2b04d9b23869793c56 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 8 Apr 2021 16:35:26 +0200 Subject: [PATCH] - fixed .def 'music' parsing. This was incomplete and just ignored Duke's special music, and the levelnum generation used an outdated formula so that it never managed to assign any music to the maps. --- source/core/mapinfo.cpp | 6 ++++-- source/core/raze_music.cpp | 1 + source/core/raze_music.h | 1 + source/games/duke/src/sounds.cpp | 1 - source/games/duke/src/sounds.h | 2 -- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/source/core/mapinfo.cpp b/source/core/mapinfo.cpp index 506cae54c..609081f7f 100644 --- a/source/core/mapinfo.cpp +++ b/source/core/mapinfo.cpp @@ -38,6 +38,7 @@ #include "raze_music.h" #include "filesystem.h" #include "printf.h" +#include "raze_sound.h" FString gSkillNames[MAXSKILLS]; FString gVolumeNames[MAXVOLUMES]; @@ -109,7 +110,8 @@ bool SetMusicForMap(const char* mapname, const char* music, bool namehack) { if (!stricmp(mapname, specials[i])) { - // todo: store this properly. + if (specialmusic.Size() <= i) specialmusic.Resize(i + 1); + specialmusic[i] = music; return true; } } @@ -127,7 +129,7 @@ bool SetMusicForMap(const char* mapname, const char* music, bool namehack) if (numMatches != 4 || toupper(b1) != 'E' || toupper(b2) != 'L') return false; - index = FindMapByLevelNum(ep*100 + lev); + index = FindMapByLevelNum(levelnum(ep - 1, lev - 1)); } if (index != nullptr) diff --git a/source/core/raze_music.cpp b/source/core/raze_music.cpp index 69cc5dbba..8586dbc00 100644 --- a/source/core/raze_music.cpp +++ b/source/core/raze_music.cpp @@ -46,6 +46,7 @@ static bool mus_blocked; static FString lastStartedMusic; +TArray specialmusic; MusicAliasMap MusicAliases; MusicAliasMap LevelMusicAliases; diff --git a/source/core/raze_music.h b/source/core/raze_music.h index a9051d650..a87644406 100644 --- a/source/core/raze_music.h +++ b/source/core/raze_music.h @@ -6,6 +6,7 @@ typedef TMap MusicAliasMap; extern MusicAliasMap MusicAliases; +extern TArray specialmusic; // Totally minimalistic interface - should be all the game modules need. void Mus_InitMusic(); diff --git a/source/games/duke/src/sounds.cpp b/source/games/duke/src/sounds.cpp index 79970b348..aefc53400 100644 --- a/source/games/duke/src/sounds.cpp +++ b/source/games/duke/src/sounds.cpp @@ -65,7 +65,6 @@ inline DDukeActor* getSndActor(const void* source) return source ? &hittype[((spritetype*)source) - sprite] : nullptr; } -TArray specialmusic; static FSoundID currentCommentarySound; static DDukeActor* currentCommentarySprite; // todo: GC this once actors become objects diff --git a/source/games/duke/src/sounds.h b/source/games/duke/src/sounds.h index 883496606..415af4406 100644 --- a/source/games/duke/src/sounds.h +++ b/source/games/duke/src/sounds.h @@ -74,8 +74,6 @@ void S_ParseDeveloperCommentary(); void StopCommentary(); bool StartCommentary(int tag, DDukeActor* sprnum); -extern TArray specialmusic; - END_DUKE_NS