Prevent failed combat movies from blocking

This commit is contained in:
gamer147
2026-07-21 20:46:10 -04:00
parent 6b58dd156e
commit f53056818d
10 changed files with 84 additions and 37 deletions

View File

@@ -171,13 +171,14 @@ public class MovieOpcodeTests
}
[Fact]
public void QueryMovieStopTimeWarnsAndReturnsMinusOneWhenMetadataIsUnavailable()
public void LoadedMovieWithoutBackendMetadataUsesImmediateZeroDuration()
{
var table = OpcodeTableJson.Load(Paths.OpcodesJson);
var script = ScriptAssembler.Assemble(table, "MISSING-MOVIE-TIME", new List<(int, Operand[])>
{
(0x236, new[] { new Operand(0, 0x33), new Operand(0, 5), new Operand(0, 2), new Operand(0, 0) }),
(0x23f, new[] { new Operand(3, 0x1234), new Operand(0, 5) }),
(0x23a, new[] { new Operand(3, 0x1235), new Operand(0, 5) }),
(0x2, System.Array.Empty<Operand>()),
}, System.Array.Empty<string>());
var host = new RecordingHost();
@@ -185,10 +186,11 @@ public class MovieOpcodeTests
vm.Run();
Assert.Equal(-1, vm.Globals[0x1234]);
string warning = Assert.Single(host.Warnings);
Assert.Contains("movie stop-time unavailable MISSING-MOVIE-TIME@", warning);
Assert.Contains("surface=5; returning -1", warning);
Assert.Equal(0, vm.Globals[0x1234]);
Assert.True(vm.Gfx.TryGetMovieStopTime(5, out long? retained));
Assert.Equal(0, retained);
Assert.Equal(0, vm.Globals[0x1235]);
Assert.Empty(host.Warnings);
}
[Fact]

View File

@@ -1684,7 +1684,10 @@ public sealed class VirtualMachine
// The native CMovieToTexture renderer replaces the pixels of the already-created surface.
// Retain the same resource binding so the compositor resolves live movie frames for its objects.
Gfx.SetSurface(surfaceSlot, resourceId, 0);
Gfx.SetMovieStopTime(surfaceSlot, stopTimeMs);
// Native never encounters a missing system decoder for shipped assets. If a host backend
// cannot initialize one, model the valid movie as completing immediately: BTL feeds this
// value into its effect timeline, where zero is a safe duration and -1 is not meaningful.
Gfx.SetMovieStopTime(surfaceSlot, stopTimeMs ?? 0);
return pc + 1; // native cmd size 9 resumes at the next instruction; playback is asynchronous
}
// ---- gfx command-buffer ops (VM-internal GfxState; docs/engine-re.md op-contract table) ----