Fix original cutscene music lifecycle and verify walking lab route
This commit is contained in:
1 parent
c929f942e1
commit
b58138d7ba
16 files changed
+282
-18
No files matched your search
@@ -7,6 +7,7 @@ public sealed class SceneAudio : IDisposable
|
||||
{
|
||||
private readonly PreparedEntityResources resources;
|
||||
private SdlAudio? music, speech;
|
||||
private (string Database, int Id)? selectedMusic;
|
||||
private readonly List<SdlAudio> effects = [];
|
||||
private readonly Dictionary<string, SdlAudio> loops = new(StringComparer.OrdinalIgnoreCase);
|
||||
public int EffectCount => effects.Count;
|
||||
@@ -17,8 +18,15 @@ public sealed class SceneAudio : IDisposable
|
||||
public SceneAudio(PreparedEntityResources resources) => this.resources = resources;
|
||||
public void Music(string database, int id)
|
||||
{
|
||||
music?.Dispose(); music = null;
|
||||
if (resources.Wave(database, id) is { } wave) music = new(wave.Path, true);
|
||||
selectedMusic = (database, id);
|
||||
RestartMusic();
|
||||
}
|
||||
public void StopMusic() { music?.Dispose(); music = null; }
|
||||
public void RestartMusic()
|
||||
{
|
||||
StopMusic();
|
||||
if (selectedMusic is { } selection && resources.Wave(selection.Database, selection.Id) is { } wave)
|
||||
music = new(wave.Path, true);
|
||||
}
|
||||
public void Speech(string database, int id)
|
||||
{
|
||||
@@ -57,5 +65,5 @@ public sealed class SceneAudio : IDisposable
|
||||
for (var i = effects.Count - 1; i >= 0; i--)
|
||||
if (effects[i].QueuedBytes == 0) { effects[i].Dispose(); effects.RemoveAt(i); }
|
||||
}
|
||||
public void Dispose() { StopEffects(); StopSpeech(); music?.Dispose(); music = null; }
|
||||
public void Dispose() { StopEffects(); StopSpeech(); StopMusic(); }
|
||||
}
|
||||
@@ -80,6 +80,8 @@ public sealed class SceneDirector
|
||||
public Vector3? CameraEye { get; private set; }
|
||||
public Vector3? CameraTarget { get; private set; }
|
||||
public event Action<string, int>? Speech;
|
||||
public event Action? MusicStopped;
|
||||
public event Action? MusicRestarted;
|
||||
public event Action<DirectorActor>? ActorChanged;
|
||||
public event Action<string, string>? Unsupported;
|
||||
|
||||
@@ -359,6 +361,10 @@ public sealed class SceneDirector
|
||||
if (!IsNone(animation)) { target.Animation = animation!; ActorChanged?.Invoke(target); }
|
||||
shot = new Shot(entity, index, target, duration);
|
||||
UpdateCamera(shot);
|
||||
// CAM416776..4167E1 stops the selected music handle and unloads its
|
||||
// database before speech. Do not infer this from every speech stream:
|
||||
// standalone MCA activation has a separate source path.
|
||||
if (index < 0) MusicStopped?.Invoke();
|
||||
Speech?.Invoke(database, sound);
|
||||
}
|
||||
|
||||
@@ -482,11 +488,15 @@ public sealed class SceneDirector
|
||||
|
||||
private void RestoreControl()
|
||||
{
|
||||
var wasControlled = Controlled;
|
||||
shot = null;
|
||||
ControlledTag = level.Player?.Tag;
|
||||
InventoryEnabled = true;
|
||||
CameraEye = CameraTarget = null;
|
||||
skipping = false;
|
||||
// DEFAULT447D5C skips the restart if Jimmy already owns control;
|
||||
//447F12..447F45 reloads his selected music and starts wave0 again.
|
||||
if (!wasControlled) MusicRestarted?.Invoke();
|
||||
// Original DEFAULT invokes a Jimmy help/inventory callback at SCENE30;
|
||||
// it does not assign a new task value or complete the lab.
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ internal static class Program
|
||||
--audio PATH Play recovered WAV; --loop-audio repeats it
|
||||
--audio-smoke PATH Verify audio-stream consumption
|
||||
--scene-audio-smoke PATH Verify music/speech streams from entities.json
|
||||
--cutscene-audio-smoke PATH Verify original cutscene music stop/restart
|
||||
--effects-audio-smoke PATH Verify default effect bank and loop lifetime
|
||||
--smoke-transition Headless VR01 RETURN / renderer-recreation check
|
||||
--smoke-lab-route Headless source lab contact route / next-scene rebuild
|
||||
@@ -98,6 +99,33 @@ internal static class Program
|
||||
if (parent.Exists && parent.LinkTarget != null) throw new ArgumentException("Save output directory must not redirect through a symbolic link");
|
||||
}
|
||||
if (args.Contains("--verify-assets")) return VerifyAssets(root);
|
||||
if (Option(args, "--cutscene-audio-smoke") is { } cutsceneManifest)
|
||||
{
|
||||
var bank = new PreparedEntityResources(cutsceneManifest);
|
||||
var cutsceneLevel = GamLevel.Load(AssetPath.Resolve(root, "gam/level1b.gam"));
|
||||
var cutsceneSave = OriginalSave.Load(AssetPath.Resolve(root, "NewGame.tsk"));
|
||||
var cutscene = new SceneDirector(cutsceneLevel, new TaskStates(cutsceneSave.Tasks), bank.Duration);
|
||||
using var mixer = new SceneAudio(bank);
|
||||
cutscene.Speech += mixer.Speech;
|
||||
cutscene.MusicStopped += mixer.StopMusic;
|
||||
cutscene.MusicRestarted += mixer.RestartMusic;
|
||||
mixer.Music("musicsecretlab.omt", 0);
|
||||
if (mixer.QueuedMusicBytes <= 0) throw new InvalidOperationException("No gameplay music before cutscene test");
|
||||
cutscene.Begin(cutsceneLevel.FindStart()!);
|
||||
var silentDuring = mixer.QueuedMusicBytes == 0 && mixer.QueuedSpeechBytes > 0;
|
||||
for (var tick = 0; tick < 18000 && !cutscene.Controlled; tick++)
|
||||
{
|
||||
cutscene.Step(FixedStepClock.Step);
|
||||
if (!cutscene.Controlled && mixer.QueuedMusicBytes != 0) silentDuring = false;
|
||||
}
|
||||
var naturalRestart = cutscene.Controlled && mixer.QueuedMusicBytes > 0;
|
||||
cutscene.Begin(cutsceneLevel.FindStart()!);
|
||||
var resetSilent = mixer.QueuedMusicBytes == 0;
|
||||
mixer.StopSpeech(); cutscene.Skip();
|
||||
var skipRestart = cutscene.Controlled && mixer.QueuedMusicBytes > 0;
|
||||
Console.WriteLine($"Cutscene audio: music silent through intro={silentDuring}, natural restart={naturalRestart}, reset silent={resetSilent}, skip restart={skipRestart}.");
|
||||
return silentDuring && naturalRestart && resetSilent && skipRestart ? 0 : 2;
|
||||
}
|
||||
if (Option(args, "--effects-audio-smoke") is { } effectsManifest)
|
||||
{
|
||||
using var mixer = new SceneAudio(new PreparedEntityResources(effectsManifest));
|
||||
@@ -325,6 +353,8 @@ internal static class Program
|
||||
if (sceneAudio != null)
|
||||
{
|
||||
director.Speech += sceneAudio.Speech;
|
||||
director.MusicStopped += sceneAudio.StopMusic;
|
||||
director.MusicRestarted += sceneAudio.RestartMusic;
|
||||
interactions!.SoundEffect += id => sceneAudio.Effect(id);
|
||||
mechanisms!.Sound += (actor, id, loop) => sceneAudio.Effect(id, loop ? actor.Tag : null);
|
||||
mechanisms.StopSound += actor => sceneAudio.StopLoop(actor.Tag);
|
||||
|
||||
Reference in new issue
Block a user