engine cleanup passes 4-7 + multi-instancing ambient rip
Squashes 146 commits from battle-engine-extraction. Net: 2,045 files changed, +11,896 / -158,687 lines. Ships engine passes 4-7 (dead-code cull, view-layer stub, receive-path shrink) plus the Phase-5 AsyncLocal ambient deletion that turns concurrent battles into a type-system property rather than a scope contract. ## What landed **Passes 4-7 (chunks 1-34):** Extended the Phase-4 const-false collapse into a cascading cull across the skill graph, view layer, and receive-path periphery. Six mode flags (IsWatchBattle/IsReplayBattle/IsAdmin/IsAdminWatch/IsPuzzleQuest/ IsAINetwork) became `const false`, every guarded block deleted. Field*.cs subclass ctors + BackGroundBase + ObjectChecker culled to no-ops. Mulligan family reworked to take a mgr param through IMulliganMgr.InitMulligan. Emotion/Recovery/Resource clusters null-stubbed. Prediction/OperationSimulator/ skill filters converted from static ambient reads to per-mgr reads via SkillPrm.ownerCard.SelfBattlePlayer.BattleMgr / ins.BattleMgr / this.BattleMgr. **Phase-5 ambient rip (chunks 35-47):** Deleted BattleAmbient / BattleAmbient- Context / TestBattleScope in full. Every per-battle mutable slot now lives on the mgr instance itself: mgr.InstanceIsForecast / InstanceIsRandomDraw / InstanceRecoveryInfo / InstanceViewerId / InstanceNetworkAgent / GameMgr BattleManagerBase.GetIns() returns null unconditionally; the residual static flags + 3 façades (Certification.ViewerId, Data.BattleRecoveryInfo, ToolboxGame.RealTimeNetworkAgent) are null-tolerant defaults kept for the handful of engine-internal readers that still reference their types. Zero BattleAmbient references anywhere in engine + node + tests. Added pre-seeded GameMgr ctor overload threaded through the mgr chain (BattleManagerBase → SingleBattleMgr / NetworkBattleManagerBase → NetworkStandard- BattleMgr → HeadlessBattleMgr / HeadlessNetworkBattleMgr). Fixtures build a GameMgr, seed it via HeadlessEngineEnv.SeedCharaIds/SeedNetUser, and pass it to the mgr's ctor — no ambient reach. Node side (SVSim.BattleNode/SessionBattleEngine): _ctx replaced with a plain GameMgr field; 34 `using var _ambient = BattleAmbient.Enter(_ctx)` scope wraps ripped from every accessor and mutator; EngineGlobalInit.WirePerSessionGameMgr takes GameMgr as a param and runs from SessionBattleEngine.SetupInternal BEFORE mgr construction. Test side: TestBattleScope deleted; 18 fixture [SetUp]s migrated to `HeadlessEngineEnv.EnsureProcessGlobals()`; MultiInstanceEngineTests rewritten around per-mgr construction (GetIns() → null is the pinned invariant). ## Regression fixes - **chunk-48** (MulliganCtrl): chunk-35's `= null` stubs on card lookups broke the live receive-driven Deal path (BattlePlayerBase.DrawCard NRE'd downstream of NetworkPlayerMulliganCtrl.StartMulliganVfx). Restored the three lookups via `_battlePlayer.BattleMgr.GetBattleCardIdx`. Engine tests were satisfied by the WireMulliganPhase seam; unit tests exposed the live-path gap. ## Ship state - SVSim.BattleEngine.Tests: 56/56 pass, 2 skip - SVSim.UnitTests: 1554/1554 pass (was 1523/31-fail before chunk 48) - Solution build: 0 source warnings (40 pre-existing NU1902 MessagePack CVEs in SVSim.EmulatedEntrypoint, unrelated) - Sequential PVP smoke: verified live (two back-to-back battles, no regression on cleanup/spinup) - Concurrent PVP smoke: verified live Adds tools/engine-port/ClosureAnalyzer/ — the Roslyn transitive-type-closure analyzer needed to make future cascade cleanup safe (per feedback memory "Engine cleanup needs closure tool" from the 2026-06-28 pass-3 failure). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -63,12 +63,8 @@ public class Mail : UIBase
|
||||
[SerializeField]
|
||||
private UIScrollView ScrollView;
|
||||
|
||||
private const int SCROLL_ITEM_COUNT = 5;
|
||||
|
||||
private List<GameObject> _scrollItems = new List<GameObject>();
|
||||
|
||||
private const int MaxMailObjIndex = 100;
|
||||
|
||||
private int _readMailID;
|
||||
|
||||
private List<MailData> _currentList;
|
||||
@@ -79,8 +75,6 @@ public class Mail : UIBase
|
||||
|
||||
private MAIL_ACTION_TYPE _mailActionType = MAIL_ACTION_TYPE.READ;
|
||||
|
||||
private const int HISTORY_MAX = 500;
|
||||
|
||||
private int _lastHistoryCount;
|
||||
|
||||
private List<string> _assetList = new List<string>();
|
||||
@@ -110,14 +104,14 @@ public class Mail : UIBase
|
||||
HistoryButton.buttons[0].onClick.Clear();
|
||||
HistoryButton.buttons[0].onClick.Add(new EventDelegate(delegate
|
||||
{
|
||||
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_TOGGLE_ON);
|
||||
|
||||
GiftInfoLabel.text = Wizard.Data.SystemText.Get("Mail_0028", 100.ToString());
|
||||
ChangeHistory();
|
||||
}));
|
||||
GiftButton.buttons[0].onClick.Clear();
|
||||
GiftButton.buttons[0].onClick.Add(new EventDelegate(delegate
|
||||
{
|
||||
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_TOGGLE_ON);
|
||||
|
||||
GiftInfoLabel.text = Wizard.Data.SystemText.Get("Mail_0027", 100.ToString());
|
||||
ChangeGift();
|
||||
}));
|
||||
@@ -135,12 +129,12 @@ public class Mail : UIBase
|
||||
|
||||
private void LoadTutorialResource()
|
||||
{
|
||||
// Pre-Phase-5b: async-loaded EffectTutorialData JSON via EffectMgr and paired the
|
||||
// UIManager view-change lock. Headless has no EffectMgr; the increment/decrement
|
||||
// pair collapses cleanly since headless never triggers view changes here.
|
||||
UIManager uiManager = UIManager.GetInstance();
|
||||
uiManager.Force_Increment_LockCountChangeView();
|
||||
_assetList.AddRange(GameMgr.GetIns().GetEffectMgr().InitCommonEffect("Json/EffectTutorialData", isBattle: true, isField: false, isBattleEffect: false, delegate
|
||||
{
|
||||
uiManager.Force_Decrement_LockCountChangeView();
|
||||
}));
|
||||
uiManager.Force_Decrement_LockCountChangeView();
|
||||
}
|
||||
|
||||
private void ShowTutorialDialog()
|
||||
@@ -220,11 +214,8 @@ public class Mail : UIBase
|
||||
}
|
||||
if (_tabType == TAB_TYPE.GIFT)
|
||||
{
|
||||
MailTopTask mailTopTask = GameMgr.GetIns().GetMailTopTask();
|
||||
if (Wizard.Data.MyPage.data.unread_mail_count > mailTopTask.LastPageRead * 100)
|
||||
{
|
||||
LoadNextPage();
|
||||
}
|
||||
// Pre-Phase-5b: reached MailTopTask.LastPageRead to decide whether to fetch the
|
||||
// next mail page. Headless has no MailTopTask; skip the mail-fetch branch entirely.
|
||||
}
|
||||
else if (_tabType == TAB_TYPE.HISTORY)
|
||||
{
|
||||
@@ -373,7 +364,7 @@ public class Mail : UIBase
|
||||
|
||||
private void OnReadMail(int mail_index, int mail_id)
|
||||
{
|
||||
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
|
||||
|
||||
_mailActionType = MAIL_ACTION_TYPE.READ;
|
||||
PrepareReceiveSingleMail(mail_index, mail_id);
|
||||
StartReadRequest();
|
||||
@@ -381,7 +372,7 @@ public class Mail : UIBase
|
||||
|
||||
private void OnReadAllMail(GameObject g)
|
||||
{
|
||||
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
|
||||
|
||||
_mailActionType = MAIL_ACTION_TYPE.READALL;
|
||||
OpenReadAllDialog(g);
|
||||
}
|
||||
@@ -464,22 +455,12 @@ public class Mail : UIBase
|
||||
|
||||
public static string GetTimeLeft(long seconds_since_unix)
|
||||
{
|
||||
// Pre-Phase-5b: computed remaining time using GameMgr's MailTopTask server-time delta.
|
||||
// Headless has no MailTopTask; return the "expires in N minutes" default with 0 minutes
|
||||
// to indicate no known time-remaining. TimeLeftUpdate is the only external caller and
|
||||
// only reads the returned string for UI label text.
|
||||
SystemText systemText = Wizard.Data.SystemText;
|
||||
MailTopTask mailTopTask = GameMgr.GetIns().GetMailTopTask();
|
||||
long num = (long)Time.realtimeSinceStartup - mailTopTask.RequestTime;
|
||||
long num2 = mailTopTask.ServerTime + num;
|
||||
TimeSpan timeSpan = TimeSpan.FromSeconds(seconds_since_unix - num2);
|
||||
if (timeSpan.TotalDays >= 1.0)
|
||||
{
|
||||
return systemText.Get("Mail_0047", ((int)timeSpan.TotalDays).ToString());
|
||||
}
|
||||
if (timeSpan.TotalHours >= 1.0)
|
||||
{
|
||||
return systemText.Get("Mail_0046", ((int)timeSpan.TotalHours).ToString());
|
||||
}
|
||||
int num3 = (int)timeSpan.TotalMinutes;
|
||||
num3 = ((num3 > 0) ? ((num3 <= 1) ? 1 : num3) : 0);
|
||||
return systemText.Get("Mail_0048", num3.ToString());
|
||||
return systemText.Get("Mail_0048", "0");
|
||||
}
|
||||
|
||||
private void OnRequestMailList(NetworkTask.ResultCode error)
|
||||
@@ -501,23 +482,16 @@ public class Mail : UIBase
|
||||
{
|
||||
_lastHistoryCount = count;
|
||||
}
|
||||
if (GameMgr.GetIns().GetMailTopTask().LastPageRead == 1)
|
||||
{
|
||||
ResetScrollWrap();
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateScrollSize();
|
||||
}
|
||||
// Pre-Phase-5b: checked MailTopTask.LastPageRead == 1 to reset the scroll wrap.
|
||||
// Headless has no MailTopTask; fall through to UpdateScrollSize (the general path).
|
||||
UpdateScrollSize();
|
||||
UIManager.GetInstance().closeInSceneCenterLoading();
|
||||
}
|
||||
|
||||
private void LoadNextPage()
|
||||
{
|
||||
UIManager.GetInstance().createInSceneCenterLoading();
|
||||
MailTopTask mailTopTask = GameMgr.GetIns().GetMailTopTask();
|
||||
mailTopTask.SetParameterToNextPage();
|
||||
StartCoroutine(Toolbox.NetworkManager.Connect(mailTopTask, OnRequestMailList, BaseTask.OnRequestFailed, BaseTask.OnFailedErrorCode));
|
||||
// Pre-Phase-5b: fetched next-page mail via MailTopTask. Headless has no mail service;
|
||||
// method becomes a no-op (the scroll wrap paths above handle empty results cleanly).
|
||||
}
|
||||
|
||||
private void UpdateScrollSize()
|
||||
@@ -558,9 +532,8 @@ public class Mail : UIBase
|
||||
|
||||
private static bool IsExpired(long seconds_since_unix)
|
||||
{
|
||||
MailTopTask mailTopTask = GameMgr.GetIns().GetMailTopTask();
|
||||
long num = (long)Time.realtimeSinceStartup - mailTopTask.RequestTime;
|
||||
long num2 = mailTopTask.ServerTime + num;
|
||||
return TimeSpan.FromSeconds(seconds_since_unix - num2).TotalSeconds <= 0.0;
|
||||
// Pre-Phase-5b: computed expiration via MailTopTask server-time delta. Headless
|
||||
// has no MailTopTask; treat everything as not-yet-expired.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user