- fixed Blood cutscene setup to avoid dependency on the sound code initialization.

It now only stores the sound name or ID but not the internal index which is only looked up when needed.
This commit is contained in:
Christoph Oelckers 2021-05-02 18:10:59 +02:00
parent 575a38d835
commit a1381c0ff2
5 changed files with 21 additions and 20 deletions

View file

@ -121,6 +121,15 @@ CCMD(mapinfo)
}
}
int CutsceneDef::GetSound()
{
int id;
if (soundName.IsNotEmpty()) id = soundEngine->FindSound(soundName);
if (id <= 0) id = soundEngine->FindSoundByResID(soundID);
return id;
}
MapRecord *FindMapByName(const char *nm)
{
for (auto& map : mapList)

View file

@ -84,8 +84,7 @@ struct CutsceneDef
FString video;
FString function;
FString soundName;
int soundID; // ResID not SoundID!
int sound = 0;
int soundID = -1; // ResID not SoundID!
int framespersec = 0; // only relevant for ANM.
bool transitiononly = false; // only play when transitioning between maps, but not when starting on a map or ending a game.

View file

@ -205,7 +205,7 @@ void CutsceneDef::Create(DObject* runner)
}
else if (video.IsNotEmpty())
{
AddGenericVideo(runner, video, sound, framespersec);
AddGenericVideo(runner, video, GetSound(), framespersec);
}
}
@ -227,7 +227,7 @@ bool CutsceneDef::Create(DObject* runner, MapRecord* map, bool transition)
}
else if (video.IsNotEmpty())
{
AddGenericVideo(runner, video, sound, framespersec);
AddGenericVideo(runner, video, GetSound(), framespersec);
return true;
}
return false;

View file

@ -427,16 +427,6 @@ void GameInterface::app_init()
if (!tileInit(0, NULL))
I_FatalError("TILES###.ART files not found");
//----------
// There's a small problem here. We have a nasty circular dependency thanks to .def's all-inclusive mentality.
// snd may depend on rffdefineid in .def
// .def depends on level definitions.
// level definitions depend on sound to resolve cutscene sounds.
// Conclusion: All map related definitions need to be taken out of .def - meaning 'definecutscene' cannot be done in there
// Unless that is done no sound related data can be done with rffdefineid.
Printf(PRINT_NONOTIFY, "Initializing sound system\n");
sndInit();
levelLoadDefaults();
LoadDefinitions();
@ -454,6 +444,9 @@ void GameInterface::app_init()
Printf(PRINT_NONOTIFY, "Initializing weapon animations\n");
WeaponInit();
Printf(PRINT_NONOTIFY, "Initializing sound system\n");
sndInit();
myconnectindex = connecthead = 0;
gNetPlayers = numplayers = 1;
connectpoint2[0] = -1;

View file

@ -174,9 +174,9 @@ void levelLoadDefaults(void)
if (i > 1) volume->flags |= VF_SHAREWARELOCK;
csB.video = cleanPath(BloodINI->GetKeyString(buffer, "CutSceneB", ""));
csB.sound = soundEngine->FindSoundByResID(BloodINI->GetKeyInt(buffer, "CutWavB", -1) + 0x40000000);
if (csB.sound == 0)
csB.sound = soundEngine->FindSound(cleanPath(BloodINI->GetKeyString(buffer, "CutWavB", "")));
int soundint = BloodINI->GetKeyInt(buffer, "CutWavB", -1);
if (soundint > 0) csB.soundID = soundint + 0x40000000;
else csB.soundName = cleanPath(BloodINI->GetKeyString(buffer, "CutWavB", ""));
//pEpisodeInfo->bloodbath = BloodINI->GetKeyInt(buffer, "BloodBathOnly", 0);
cutALevel = BloodINI->GetKeyInt(buffer, "CutSceneALevel", 0);
@ -202,9 +202,9 @@ void levelLoadDefaults(void)
{
CutsceneDef& csA = pLevelInfo->intro;
csA.video = cleanPath(BloodINI->GetKeyString(buffer, "CutSceneA", ""));
csA.sound = soundEngine->FindSoundByResID(BloodINI->GetKeyInt(buffer, "CutWavA", -1) + 0x40000000);
if (csA.sound == 0)
csA.sound = soundEngine->FindSound(cleanPath(BloodINI->GetKeyString(buffer, "CutWavA", "")));
int soundint = BloodINI->GetKeyInt(buffer, "CutWavA", -1);
if (soundint > 0) csA.soundID = soundint + 0x40000000;
else csA.soundName = cleanPath(BloodINI->GetKeyString(buffer, "CutWavA", ""));
}
}
// Now resolve the level links