feat(engine-ambient): delete static fallbacks; add MultiInstanceEngineTests

Step 8 (final) of multi-instancing migration. All per-battle statics now
require a BattleAmbient scope — unwrapped writes throw InvalidOperationException
(fail-fast forcing function). MultiInstanceEngineTests proves correctness:
two parallel battles resolve independently, N=4/8/16 stress matches sequential
baseline, GameMgr.GetIns throws without scope.

Migration complete. EngineSessionGate gone. Suite fully green.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-07 23:19:37 -04:00
parent 9e93a7b198
commit c789d836f1
15 changed files with 449 additions and 131 deletions

View File

@@ -16,8 +16,6 @@ public class Certification : MonoBehaviour
private static string udid;
private static int _viewerIdFallback;
private static int short_udid;
private static string sessionId;
@@ -40,28 +38,13 @@ public class Certification : MonoBehaviour
public static int ViewerId
{
get
{
var c = SVSim.BattleEngine.Ambient.BattleAmbient.Current;
if (c != null) return c.ViewerId;
if (_viewerIdFallback == 0)
{
_viewerIdFallback = Toolbox.SavedataManager.GetInt("VIEWER_ID");
}
return _viewerIdFallback;
}
set
{
var c = SVSim.BattleEngine.Ambient.BattleAmbient.Current;
if (c != null)
{
// Inside a scope, ViewerId is fixed at scope entry — swallow the write.
return;
}
Toolbox.SavedataManager.SetInt("VIEWER_ID", value);
Toolbox.SavedataManager.Save();
_viewerIdFallback = value;
}
// Post-Task-8: strictly ambient. The historical SavedataManager-backed lazy decode was the
// client process's single-viewer-id source; in the headless multi-instance world the viewer
// id MUST come from the per-session ambient context. Setter is a no-op (BattleAmbientContext
// .ViewerId is `init`-only — fixed at scope entry per design — and the historical caller
// (SavedataManager.SetInt + Save) is dead in the server world).
get => SVSim.BattleEngine.Ambient.BattleAmbient.Require().ViewerId;
set { /* ambient ViewerId is init-only; SavedataManager path is dead headless */ }
}
public static int ShortUdid
@@ -152,7 +135,6 @@ public class Certification : MonoBehaviour
{
sessionId = null;
udid = null;
_viewerIdFallback = 0;
short_udid = 0;
Toolbox.SavedataManager.SetInt("VIEWER_ID", 0);
Toolbox.SavedataManager.SetInt("SHORT_UDID", 0);