From 2a71847a5db3163cd23b55cd92103185a59dd926 Mon Sep 17 00:00:00 2001 From: gamer147 Date: Tue, 7 Jul 2026 15:22:40 -0400 Subject: [PATCH] refactor(hosting): drop CallScript/OnStub from IHost (now trace events) Co-Authored-By: Claude Opus 4.8 --- engine/Age.Cli/Program.cs | 6 +----- engine/Age.Engine.Tests/CallScriptIntegrationTests.cs | 3 --- engine/Age.Engine.Tests/CallScriptTests.cs | 3 --- engine/Age.Engine.Tests/GameSessionTests.cs | 2 -- engine/Age.Engine.Tests/TestSupport.cs | 4 +--- engine/Age.Engine.Tests/TextureGeometryTests.cs | 2 -- engine/Age.Engine.Tests/TextureOpsTests.cs | 2 -- engine/Age.Engine/Hosting/CaptureHost.cs | 4 ---- engine/Age.Engine/Hosting/IHost.cs | 2 -- 9 files changed, 2 insertions(+), 26 deletions(-) diff --git a/engine/Age.Cli/Program.cs b/engine/Age.Cli/Program.cs index 34c6a16..ffbf242 100644 --- a/engine/Age.Cli/Program.cs +++ b/engine/Age.Cli/Program.cs @@ -17,7 +17,7 @@ if (args[0] == "run") var runHost = new CaptureHost(); var vm = new VirtualMachine(script, table, runHost, null, provider); vm.Run(); - Console.WriteLine($"{Path.GetFileName(args[1])}: {vm.Steps} steps, {vm.Emitted.Count} show-text, {runHost.CallScriptCount} call-scripts (halt: {vm.HaltReason})"); + Console.WriteLine($"{Path.GetFileName(args[1])}: {vm.Steps} steps, {vm.Emitted.Count} show-text, {vm.CallScriptDispatches} call-scripts (halt: {vm.HaltReason})"); foreach (var (off, text, scr) in vm.Emitted.Take(30)) Console.WriteLine($" [{scr} 0x{off:x}] {text}"); var sources = vm.Emitted.Select(e => e.Script).Distinct().ToList(); Console.WriteLine($"source scripts ({sources.Count}): {string.Join(", ", sources)}"); @@ -213,8 +213,6 @@ sealed class AudioTraceHost : IHost : $"{e.Archive} {e.Name}" + (ResourceMap.AudioPath(e) == null ? " [NO FILE]" : ""))); } public void ShowText(int offset, string text) { } - public void CallScript(long id) { } - public void OnStub(int opcode) { } public void WaitForInput() { } public void CreateTexture(int slot, int width, int height) { } public void SetTexture(long resourceId, int slot) { } @@ -263,8 +261,6 @@ sealed class GfxTraceHost : IHost Events.Add($"create-texture slot={slot} {width}x{height}"); } public void ShowText(int offset, string text) { } - public void CallScript(long id) { } - public void OnStub(int opcode) { } public void WaitForInput() { } public void PlayBgm(long id) { } public void PlayVoice(long id) { } diff --git a/engine/Age.Engine.Tests/CallScriptIntegrationTests.cs b/engine/Age.Engine.Tests/CallScriptIntegrationTests.cs index 1351cd1..593337b 100644 --- a/engine/Age.Engine.Tests/CallScriptIntegrationTests.cs +++ b/engine/Age.Engine.Tests/CallScriptIntegrationTests.cs @@ -7,10 +7,7 @@ public class CallScriptIntegrationTests { private sealed class NullHost : IHost { - public int CallScripts; public void ShowText(int o, string t) { } - public void CallScript(long id) => CallScripts++; - public void OnStub(int op) { } public void WaitForInput() { } public void CreateTexture(int s, int w, int h) { } public void SetTexture(long r, int s) { } diff --git a/engine/Age.Engine.Tests/CallScriptTests.cs b/engine/Age.Engine.Tests/CallScriptTests.cs index aca7f6f..b3a83b6 100644 --- a/engine/Age.Engine.Tests/CallScriptTests.cs +++ b/engine/Age.Engine.Tests/CallScriptTests.cs @@ -13,10 +13,7 @@ public class CallScriptTests private sealed class NullHost : IHost { - public List Calls = new(); public void ShowText(int o, string t) { } - public void CallScript(long id) => Calls.Add(id); - public void OnStub(int op) { } public void WaitForInput() { } public void CreateTexture(int s, int w, int h) { } public void SetTexture(long r, int s) { } diff --git a/engine/Age.Engine.Tests/GameSessionTests.cs b/engine/Age.Engine.Tests/GameSessionTests.cs index a0eed2a..bfd440e 100644 --- a/engine/Age.Engine.Tests/GameSessionTests.cs +++ b/engine/Age.Engine.Tests/GameSessionTests.cs @@ -28,8 +28,6 @@ public class GameSessionTests public int Voices; public List Emitted = new(); public void ShowText(int o, string t) => Emitted.Add(o); - public void CallScript(long id) { } - public void OnStub(int op) { } public void WaitForInput() { } public void CreateTexture(int s, int w, int h) { } public void SetTexture(long r, int s) { } diff --git a/engine/Age.Engine.Tests/TestSupport.cs b/engine/Age.Engine.Tests/TestSupport.cs index cba1d6b..2ff20e3 100644 --- a/engine/Age.Engine.Tests/TestSupport.cs +++ b/engine/Age.Engine.Tests/TestSupport.cs @@ -8,11 +8,9 @@ using Age.Engine.Model; /// provider for synthetic call-script targets. internal sealed class RecordingHost : IHost { - public int Waits, CallScripts; + public int Waits; public readonly List<(int Offset, string Text)> Lines = new(); public void ShowText(int offset, string text) => Lines.Add((offset, text)); - public void CallScript(long id) => CallScripts++; - public void OnStub(int opcode) { } public void WaitForInput() => Waits++; public void CreateTexture(int slot, int w, int h) { } public void SetTexture(long resId, int slot) { } diff --git a/engine/Age.Engine.Tests/TextureGeometryTests.cs b/engine/Age.Engine.Tests/TextureGeometryTests.cs index 9118fdc..2ee9eba 100644 --- a/engine/Age.Engine.Tests/TextureGeometryTests.cs +++ b/engine/Age.Engine.Tests/TextureGeometryTests.cs @@ -10,8 +10,6 @@ public class TextureGeometryTests private sealed class FakeSizeHost : IHost { public void ShowText(int o, string t) { } - public void CallScript(long id) { } - public void OnStub(int op) { } public void WaitForInput() { } public void CreateTexture(int slot, int w, int h) { } public void SetTexture(long resId, int slot) { } diff --git a/engine/Age.Engine.Tests/TextureOpsTests.cs b/engine/Age.Engine.Tests/TextureOpsTests.cs index 1d31ad0..b2dbb92 100644 --- a/engine/Age.Engine.Tests/TextureOpsTests.cs +++ b/engine/Age.Engine.Tests/TextureOpsTests.cs @@ -12,8 +12,6 @@ public class TextureOpsTests public List<(int slot, int w, int h)> Draws = new(); public int Creates; public void ShowText(int o, string t) { } - public void CallScript(long id) { } - public void OnStub(int op) { } public void WaitForInput() { } public void CreateTexture(int slot, int w, int h) => Creates++; public void SetTexture(long resId, int slot) => Sets.Add((resId, slot)); diff --git a/engine/Age.Engine/Hosting/CaptureHost.cs b/engine/Age.Engine/Hosting/CaptureHost.cs index 81619e6..e7195cd 100644 --- a/engine/Age.Engine/Hosting/CaptureHost.cs +++ b/engine/Age.Engine/Hosting/CaptureHost.cs @@ -2,11 +2,7 @@ namespace Age.Engine.Hosting; public sealed class CaptureHost : IHost { public List<(int Offset, string Text)> Emitted { get; } = new(); - public int CallScriptCount { get; private set; } - public Dictionary Stubs { get; } = new(); public void ShowText(int offset, string text) => Emitted.Add((offset, text)); - public void CallScript(long id) => CallScriptCount++; - public void OnStub(int opcode) { Stubs.TryGetValue(opcode, out var c); Stubs[opcode] = c + 1; } public void WaitForInput() { } public void CreateTexture(int slot, int width, int height) { } public void SetTexture(long resourceId, int slot) { } diff --git a/engine/Age.Engine/Hosting/IHost.cs b/engine/Age.Engine/Hosting/IHost.cs index f1d4ce9..ccc04f5 100644 --- a/engine/Age.Engine/Hosting/IHost.cs +++ b/engine/Age.Engine/Hosting/IHost.cs @@ -2,8 +2,6 @@ namespace Age.Engine.Hosting; public interface IHost { void ShowText(int offset, string text); - void CallScript(long id); - void OnStub(int opcode); void WaitForInput(); void CreateTexture(int slot, int width, int height); void SetTexture(long resourceId, int slot);