diff --git a/src/g_level.h b/src/g_level.h index 016e256c35..4edf4409e3 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -239,6 +239,7 @@ struct FOptionalMapinfoDataPtr }; typedef TMap FOptData; +typedef TMap FMusicMap; struct level_info_t { @@ -298,6 +299,7 @@ struct level_info_t float teamdamage; FOptData optdata; + FMusicMap MusicMap; TArray specialactions; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index f12180ff88..ff896a0f10 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4290,6 +4290,11 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) mthing->args[0] = mthing->type - 14000; mthing->type = 14065; } + else if (mthing->type >= 14101 && mthing->type <= 14164) + { + mthing->args[0] = mthing->type - 14100; + mthing->type = 14165; + } // find which type to spawn i = DoomEdMap.FindType (mthing->type); diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index b5cfc1d82a..7f9cd8592e 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -2111,3 +2111,82 @@ void AAmbientSound::Deactivate (AActor *activator) } } } + + +//========================================================================== +// +// S_ParseMusInfo +// Parses MUSINFO lump. +// +//========================================================================== + +void S_ParseMusInfo() +{ + int lastlump = 0, lump; + + while ((lump = Wads.FindLump ("MUSINFO", &lastlump)) != -1) + { + FScanner sc(lump); + + while (sc.GetString()) + { + level_info_t *map = FindLevelInfo(sc.String); + + if (map == NULL) + { + // Don't abort for invalid maps + sc.ScriptMessage("Unknown map '%s'", sc.String); + } + while (sc.CheckNumber()) + { + int index = sc.Number; + sc.MustGetString(); + if (index > 0) + { + FName music = sc.String; + if (map != NULL) + { + map->MusicMap[index] = music; + } + } + } + } + } +} + + +//========================================================================== +// +// Music changer. Uses the sector action class to do its job +// +//========================================================================== + +class AMusicChanger : public ASectorAction +{ + DECLARE_CLASS (AMusicChanger, ASectorAction) +public: + virtual bool TriggerAction (AActor *triggerer, int activationType); +}; + +IMPLEMENT_CLASS(AMusicChanger) + +bool AMusicChanger::TriggerAction (AActor *triggerer, int activationType) +{ + if (activationType & SECSPAC_Enter) + { + if (args[0] != 0) + { + FName *music = level.info->MusicMap.CheckKey(args[0]); + + if (music != NULL) + { + S_ChangeMusic(music->GetChars(), args[1]); + } + } + else + { + S_ChangeMusic("*"); + } + } + return Super::TriggerAction (triggerer, activationType); +} diff --git a/src/s_sound.cpp b/src/s_sound.cpp index db0f0f21dd..b7a63e51b1 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -323,6 +323,7 @@ void S_InitData () LastLocalSndInfo = LastLocalSndSeq = ""; S_ParseSndInfo (); S_ParseSndSeq (-1); + S_ParseMusInfo(); } //========================================================================== diff --git a/src/s_sound.h b/src/s_sound.h index b616b9137e..41820bec78 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -353,6 +353,7 @@ void S_ShrinkPlayerSoundLists (); void S_UnloadSound (sfxinfo_t *sfx); sfxinfo_t *S_LoadSound(sfxinfo_t *sfx); unsigned int S_GetMSLength(FSoundID sound); +void S_ParseMusInfo(); // [RH] Prints sound debug info to the screen. // Modelled after Hexen's noise cheat. @@ -373,9 +374,9 @@ enum EMidiDevice { MDEV_DEFAULT = -1, MDEV_MMAPI = 0, - MDEV_TIMIDITY = 1, - MDEV_OPL = 2, - MDEV_FMOD = 3, + MDEV_OPL = 1, + MDEV_FMOD = 2, + MDEV_TIMIDITY = 3, }; typedef TMap MidiDeviceMap; diff --git a/wadsrc/static/actors/shared/sectoraction.txt b/wadsrc/static/actors/shared/sectoraction.txt index 24b81bc392..2d7fe2a80c 100644 --- a/wadsrc/static/actors/shared/sectoraction.txt +++ b/wadsrc/static/actors/shared/sectoraction.txt @@ -73,3 +73,9 @@ ACTOR SecActHitFakeFloor : SectorAction 9989 native { } +// Music changer ---------------------------------- + +ACTOR MusicChanger : SectorAction 14165 native +{ +} +