Skip to content

Commit

Permalink
- fixed Blood cutscene setup to avoid dependency on the sound code in…
Browse files Browse the repository at this point in the history
…itialization.

It now only stores the sound name or ID but not the internal index which is only looked up when needed.
  • Loading branch information
coelckers committed May 2, 2021
1 parent 575a38d commit a1381c0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
9 changes: 9 additions & 0 deletions source/core/mapinfo.cpp
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions source/core/mapinfo.h
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions source/core/screenjob.cpp
Expand Up @@ -205,7 +205,7 @@ void CutsceneDef::Create(DObject* runner)
}
else if (video.IsNotEmpty())
{
AddGenericVideo(runner, video, sound, framespersec);
AddGenericVideo(runner, video, GetSound(), framespersec);
}
}

Expand All @@ -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;
Expand Down
13 changes: 3 additions & 10 deletions source/games/blood/src/blood.cpp
Expand Up @@ -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();

Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions source/games/blood/src/levels.cpp
Expand Up @@ -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);
Expand All @@ -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
Expand Down

0 comments on commit a1381c0

Please sign in to comment.