diff --git a/src/d_main.cpp b/src/d_main.cpp index 40c724496..c428059e6 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2209,15 +2209,15 @@ void D_DoomMain (void) // [RH] Load sound environments S_ParseReverbDef (); + // [RH] Parse any SNDINFO lumps + Printf ("S_InitData: Load sound definitions.\n"); + S_InitData (); + // [RH] Parse through all loaded mapinfo lumps Printf ("G_ParseMapInfo: Load map definitions.\n"); G_ParseMapInfo (iwad_info->MapInfo); ReadStatistics(); - // [RH] Parse any SNDINFO lumps - Printf ("S_InitData: Load sound definitions.\n"); - S_InitData (); - Printf ("Texman.Init: Init texture manager.\n"); TexMan.Init(); C_InitConback(); diff --git a/src/g_level.h b/src/g_level.h index bc30b5603..c246e5b7e 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -36,8 +36,8 @@ #include "doomtype.h" #include "doomdef.h" -//#include "autosegs.h" #include "sc_man.h" +#include "s_sound.h" struct level_info_t; struct cluster_info_t; @@ -327,6 +327,8 @@ struct level_info_t TArray specialactions; + TArray PrecacheSounds; + level_info_t() { Reset(); diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index 38440c8f0..1d229267e 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -269,6 +269,7 @@ void level_info_t::Reset() teamdamage = 0.f; specialactions.Clear(); DefaultEnvironment = 0; + PrecacheSounds.Clear(); } @@ -1029,7 +1030,7 @@ DEFINE_MAP_OPTION(specialaction, true) sa->Action = P_FindLineSpecial(parse.sc.String, &min_arg, &max_arg); if (sa->Action == 0 || min_arg < 0) { - parse.sc.ScriptError("Unknown specialaction '%s'"); + parse.sc.ScriptError("Unknown specialaction '%s'", parse.sc.String); } int j = 0; while (j < 5 && parse.sc.CheckString(",")) @@ -1040,6 +1041,25 @@ DEFINE_MAP_OPTION(specialaction, true) if (parse.format_type == parse.FMT_Old) parse.sc.SetCMode(false); } +DEFINE_MAP_OPTION(PrecacheSounds, true) +{ + parse.ParseAssign(); + + do + { + parse.sc.MustGetString(); + FSoundID snd = parse.sc.String; + if (snd == 0) + { + parse.sc.ScriptMessage("Unknown sound \"%s\"", parse.sc.String); + } + else + { + info->PrecacheSounds.Push(snd); + } + } while (parse.sc.CheckString(",")); +} + DEFINE_MAP_OPTION(redirect, true) { parse.ParseAssign(); diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 9749d635c..dadd1a6d7 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -477,7 +477,8 @@ void S_PrecacheLevel () AActor *actor; TThinkerIterator iterator; - while ( (actor = iterator.Next ()) != NULL ) + // Precache all sounds known to be used by the currently spawned actors. + while ( (actor = iterator.Next()) != NULL ) { S_sfx[actor->SeeSound].bUsed = true; S_sfx[actor->AttackSound].bUsed = true; @@ -486,6 +487,11 @@ void S_PrecacheLevel () S_sfx[actor->ActiveSound].bUsed = true; S_sfx[actor->UseSound].bUsed = true; } + // Precache all extra sounds requested by this map. + for (i = 0; i < level.info->PrecacheSounds.Size(); ++i) + { + S_sfx[level.info->PrecacheSounds[i]].bUsed = true; + } for (i = 1; i < S_sfx.Size(); ++i) {