- fixed sound issues with DSDHacked.

* forward declarations must be allowed.
* this must disable map-local SNDINFOs because the added sounds would get lost otherwise.
This commit is contained in:
Christoph Oelckers 2023-09-13 18:44:14 +02:00
parent f72da434a8
commit 2fe0a7c60d
4 changed files with 22 additions and 2 deletions

View file

@ -3358,6 +3358,8 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
if (!batchrun) Printf ("DecalLibrary: Load decals.\n"); if (!batchrun) Printf ("DecalLibrary: Load decals.\n");
DecalLibrary.ReadAllDecals (); DecalLibrary.ReadAllDecals ();
auto numbasesounds = soundEngine->GetNumSounds();
// Load embedded Dehacked patches // Load embedded Dehacked patches
D_LoadDehLumps(FromIWAD); D_LoadDehLumps(FromIWAD);
@ -3387,6 +3389,9 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
// Create replacements for dehacked pickups // Create replacements for dehacked pickups
FinishDehPatch(); FinishDehPatch();
auto numdehsounds = soundEngine->GetNumSounds();
if (numbasesounds < numdehsounds) S_LockLocalSndinfo(); // DSDHacked sounds are not compatible with map-local SNDINFOs.
if (!batchrun) Printf("M_Init: Init menus.\n"); if (!batchrun) Printf("M_Init: Init menus.\n");
SetDefaultMenuColors(); SetDefaultMenuColors();
M_Init(); M_Init();

View file

@ -270,7 +270,7 @@ struct MBFParamState
FSoundID GetSoundArg(int i, int def = 0) FSoundID GetSoundArg(int i, int def = 0)
{ {
int num = argsused & (1 << i) ? (int)args[i] : def; int num = argsused & (1 << i) ? (int)args[i] : def;
return DehFindSound(num-1, true); return DehFindSound(num-1);
} }
double GetFloatArg(int i, double def = 0) double GetFloatArg(int i, double def = 0)

View file

@ -172,6 +172,7 @@ struct FSavedPlayerSoundInfo
// This specifies whether Timidity or Windows playback is preferred for a certain song (only useful for Windows.) // This specifies whether Timidity or Windows playback is preferred for a certain song (only useful for Windows.)
MusicAliasMap MusicAliases; MusicAliasMap MusicAliases;
static bool sndinfo_locked;
// EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- // EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
@ -581,7 +582,10 @@ void S_ParseSndInfo (bool redefine)
{ {
int lump; int lump;
if (!redefine) SavedPlayerSounds.Clear(); // clear skin sounds only for initial parsing. if (redefine && sndinfo_locked) return;
SavedPlayerSounds.Clear(); // clear skin sounds only for initial parsing.
S_ClearSoundData(); // remove old sound data first! S_ClearSoundData(); // remove old sound data first!
CurrentPitchMask = 0; CurrentPitchMask = 0;
@ -610,6 +614,11 @@ void S_ParseSndInfo (bool redefine)
S_CheckIntegrity(); S_CheckIntegrity();
} }
void S_LockLocalSndinfo()
{
sndinfo_locked = true;
}
//========================================================================== //==========================================================================
// //
// Adds a level specific SNDINFO lump // Adds a level specific SNDINFO lump
@ -618,6 +627,11 @@ void S_ParseSndInfo (bool redefine)
void S_AddLocalSndInfo(int lump) void S_AddLocalSndInfo(int lump)
{ {
if (sndinfo_locked)
{
Printf("Local SNDINFO cannot be combined with DSDHacked sounds!");
return;
}
S_AddSNDINFO(lump); S_AddSNDINFO(lump);
soundEngine->HashSounds (); soundEngine->HashSounds ();

View file

@ -65,6 +65,7 @@ extern MusicAliasMap MusicAliases;
// [RH] S_sfx "maintenance" routines // [RH] S_sfx "maintenance" routines
void S_ClearSoundData(); void S_ClearSoundData();
void S_ParseSndInfo (bool redefine); void S_ParseSndInfo (bool redefine);
void S_LockLocalSndinfo();
bool S_AreSoundsEquivalent (AActor *actor, FSoundID id1, FSoundID id2); bool S_AreSoundsEquivalent (AActor *actor, FSoundID id1, FSoundID id2);
FSoundID S_LookupPlayerSound (const char *playerclass, int gender, FSoundID refid); FSoundID S_LookupPlayerSound (const char *playerclass, int gender, FSoundID refid);