From a1381c0ff2c01d6952bf13fd95e937f725afd53f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 2 May 2021 18:10:59 +0200 Subject: [PATCH] - 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. --- source/core/mapinfo.cpp | 9 +++++++++ source/core/mapinfo.h | 3 +-- source/core/screenjob.cpp | 4 ++-- source/games/blood/src/blood.cpp | 13 +++---------- source/games/blood/src/levels.cpp | 12 ++++++------ 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/source/core/mapinfo.cpp b/source/core/mapinfo.cpp index 1a8a606db..4b52d6677 100644 --- a/source/core/mapinfo.cpp +++ b/source/core/mapinfo.cpp @@ -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) diff --git a/source/core/mapinfo.h b/source/core/mapinfo.h index 43c029e93..4b4ed1ad4 100644 --- a/source/core/mapinfo.h +++ b/source/core/mapinfo.h @@ -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. diff --git a/source/core/screenjob.cpp b/source/core/screenjob.cpp index 1c5bd0597..993c97ce1 100644 --- a/source/core/screenjob.cpp +++ b/source/core/screenjob.cpp @@ -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; diff --git a/source/games/blood/src/blood.cpp b/source/games/blood/src/blood.cpp index 4af549d52..789ec5d71 100644 --- a/source/games/blood/src/blood.cpp +++ b/source/games/blood/src/blood.cpp @@ -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; diff --git a/source/games/blood/src/levels.cpp b/source/games/blood/src/levels.cpp index b69ab4527..bbb2d2c3a 100644 --- a/source/games/blood/src/levels.cpp +++ b/source/games/blood/src/levels.cpp @@ -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