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:
@@ -4,6 +4,10 @@ using System.Text;
|
||||
using Cute;
|
||||
using UnityEngine;
|
||||
using Wizard.RoomMatch;
|
||||
// TODO(engine-cleanup-pass2): 37 of 55 methods unrun in baseline
|
||||
// Type: Wizard.LocalLog
|
||||
// See data_dumps/reports/engine-cleanup/live-methods.baseline.txt
|
||||
|
||||
|
||||
namespace Wizard;
|
||||
|
||||
@@ -20,14 +24,10 @@ public class LocalLog
|
||||
{
|
||||
TRACE_ALL_LOG,
|
||||
TRACE_LOG,
|
||||
TRACE_LAST_LOG,
|
||||
TRACE_INQUIRY_LOG
|
||||
}
|
||||
TRACE_LAST_LOG }
|
||||
|
||||
public enum RecordType
|
||||
{
|
||||
CERBERUS,
|
||||
HADES
|
||||
}
|
||||
|
||||
private static string AccumulateLogPath = Application.persistentDataPath + "/accumulate_log";
|
||||
@@ -42,26 +42,10 @@ public class LocalLog
|
||||
|
||||
private static string _failureWriteClientLog = "";
|
||||
|
||||
private const string TRACELASTLOG_KEY1 = "LastTraceLog1";
|
||||
|
||||
private const string TRACELASTLOG_KEY2 = "LastTraceLog2";
|
||||
|
||||
private static int nowTraceTurn = 0;
|
||||
|
||||
private const string TRACELOG_KEY = "TraceLog";
|
||||
|
||||
private const string TRACE_SETTING_LOG_KEY = "TraceSettingLog";
|
||||
|
||||
private const string BATTLE_SETTING_INFO_TOP = "BattleSetting:";
|
||||
|
||||
private const string TRACE_INQUIRY_LOG_KEY = "TraceInquiryLog";
|
||||
|
||||
private static int currentTurn = -1;
|
||||
|
||||
private static string _roomCreateLog = "";
|
||||
|
||||
private static bool _isRoomCreateLogEnd = false;
|
||||
|
||||
private static string _loadResourceLog = "";
|
||||
|
||||
private static string _gungnirLog = "";
|
||||
@@ -76,8 +60,6 @@ public class LocalLog
|
||||
|
||||
private static bool _isLastTraceLogTimeAdd = false;
|
||||
|
||||
private const string _resourceLoadErrorText = "ResourcesManager ParallelAssetListExec Error";
|
||||
|
||||
private static StringBuilder _lastTraceLogStringBuilder = null;
|
||||
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
@@ -123,11 +105,6 @@ public class LocalLog
|
||||
MakeTreceLogToSend(TRACELOG_TYPE.TRACE_ALL_LOG, onSended);
|
||||
}
|
||||
|
||||
public static void SendClientInfoTraceLog(Action onSended)
|
||||
{
|
||||
MakeTreceLogToSend(TRACELOG_TYPE.TRACE_LOG, onSended);
|
||||
}
|
||||
|
||||
public static void SendLastTraceLog(Action onSended)
|
||||
{
|
||||
MakeTreceLogToSend(TRACELOG_TYPE.TRACE_LAST_LOG, onSended);
|
||||
@@ -143,7 +120,7 @@ public class LocalLog
|
||||
|
||||
private static void MakeTreceLogToSendLocked(TRACELOG_TYPE logType, Action onSended)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Certification.Udid) || Certification.ViewerId == 0)
|
||||
if (string.IsNullOrEmpty(Certification.Udid) /* Pre-Phase-5 chunk 39: Certification.ViewerId dropped — LocalLog is static-scope */)
|
||||
{
|
||||
onSended.Call();
|
||||
return;
|
||||
@@ -192,9 +169,9 @@ public class LocalLog
|
||||
{
|
||||
case TRACELOG_TYPE.TRACE_ALL_LOG:
|
||||
log = text2;
|
||||
if (ToolboxGame.RealTimeNetworkAgent != null)
|
||||
if (false) // Pre-Phase-5 (chunk 38): RTA has no static reach; log skips battle-id/socket-id
|
||||
{
|
||||
text = text + "bId" + ToolboxGame.RealTimeNetworkAgent.GetBattleId() + "\n";
|
||||
text = text + "bId0\n"; /* Pre-Phase-5 chunk 38: dead branch (RTA static removed) */
|
||||
}
|
||||
text += AppendLastLog(text3, text4);
|
||||
log2 = text5;
|
||||
@@ -268,7 +245,7 @@ public class LocalLog
|
||||
lock (_gate)
|
||||
{
|
||||
UIManager.ViewScene currentScene = UIManager.GetInstance().GetCurrentScene();
|
||||
string text = ((currentScene == UIManager.ViewScene.Battle && ToolboxGame.RealTimeNetworkAgent != null) ? "NetworkBattle" : currentScene.ToString());
|
||||
string text = (false /* Pre-Phase-5 (chunk 38): RTA has no static reach */ ? "NetworkBattle" : currentScene.ToString());
|
||||
AccumulateTraceLogLocked("ResourcesManager ParallelAssetListExec Error in " + text + " : " + errorFlag);
|
||||
}
|
||||
}
|
||||
@@ -284,25 +261,6 @@ public class LocalLog
|
||||
}
|
||||
}
|
||||
|
||||
public static void RecordFreezeLogIfLoadErrorOccured()
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
if (ExistResourceLoadErrorInNetWorkBattleLocked())
|
||||
{
|
||||
AccumulateTraceLogLocked("ResourceLoadFreeze in NetworkBattleScene");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ExistResourceLoadErrorInNetWorkBattle()
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
return ExistResourceLoadErrorInNetWorkBattleLocked();
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ExistResourceLoadErrorInNetWorkBattleLocked()
|
||||
{
|
||||
return ReadLogFile(AccumulateLogPath).Contains("ResourcesManager ParallelAssetListExec Error in NetworkBattle");
|
||||
@@ -328,7 +286,7 @@ public class LocalLog
|
||||
private static string GetShapedLog(string log)
|
||||
{
|
||||
log = log.Replace("\n", "&&").Replace("\r", "");
|
||||
string text = "ID:" + PlayerStaticData.UserViewerID + " {\n" + log + " \n}";
|
||||
string text = "ID:" + 0 + " {\n" + log + " \n}";
|
||||
text.Replace("\n", "\\n");
|
||||
return text;
|
||||
}
|
||||
@@ -392,7 +350,7 @@ public class LocalLog
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
if (!(ToolboxGame.RealTimeNetworkAgent == null))
|
||||
if (false) // Pre-Phase-5 (chunk 38): RTA has no static reach
|
||||
{
|
||||
string battleAndViewIdText = GetBattleAndViewIdText();
|
||||
string text = (PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.SHOW_BATTLE_EFFECT) ? "1" : "0");
|
||||
@@ -408,10 +366,10 @@ public class LocalLog
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
if (ToolboxGame.RealTimeNetworkAgent != null)
|
||||
if (false) // Pre-Phase-5 (chunk 38): RTA has no static reach; log skips battle-id/socket-id
|
||||
{
|
||||
DateTime dateTime = DateTime.Now.ToUniversalTime();
|
||||
log = dateTime.Day + "/" + dateTime.Hour + ":" + dateTime.Minute + ":" + dateTime.Second + ":" + dateTime.Millisecond.ToString("000") + ":[" + ToolboxGame.RealTimeNetworkAgent.NowSocketID + "]" + log + "\n";
|
||||
log = dateTime.Day + "/" + dateTime.Hour + ":" + dateTime.Minute + ":" + dateTime.Second + ":" + dateTime.Millisecond.ToString("000") + ":[0]" + log + "\n"; /* Pre-Phase-5 chunk 38: dead branch (RTA static removed) */
|
||||
_gungnirLog += log;
|
||||
}
|
||||
}
|
||||
@@ -422,74 +380,27 @@ public class LocalLog
|
||||
lock (_gate)
|
||||
{
|
||||
_gungnirLog = "";
|
||||
if (ToolboxGame.RealTimeNetworkAgent != null && _isSendGungnirLog)
|
||||
if (false) // Pre-Phase-5 (chunk 38): RTA has no static reach
|
||||
{
|
||||
ToolboxGame.RealTimeNetworkAgent.NetworkLogger.LogInfo("OffGungnirLog");
|
||||
/* Pre-Phase-5 chunk 38: dead branch (RTA static removed) */
|
||||
}
|
||||
_isSendGungnirLog = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddSocketFrameLog(string log)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
if (ToolboxGame.RealTimeNetworkAgent != null)
|
||||
{
|
||||
DateTime dateTime = DateTime.Now.ToUniversalTime();
|
||||
log = dateTime.Day + "/" + dateTime.Hour + ":" + dateTime.Minute + ":" + dateTime.Second + ":" + dateTime.Millisecond.ToString("000") + ":[" + ToolboxGame.RealTimeNetworkAgent.NowSocketID + "]" + log + "\n";
|
||||
_socketFrameLog += log;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void InitSocketFrameLog()
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
_socketFrameLog = "";
|
||||
if (ToolboxGame.RealTimeNetworkAgent != null && _isSendSocketFrameLog)
|
||||
if (false) // Pre-Phase-5 (chunk 38): RTA has no static reach
|
||||
{
|
||||
ToolboxGame.RealTimeNetworkAgent.NetworkLogger.LogInfo("OffSocketFrameLog");
|
||||
/* Pre-Phase-5 chunk 38: dead branch (RTA static removed) */
|
||||
}
|
||||
_isSendSocketFrameLog = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void AccumulateTraceLogAddRoomCreateLog()
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
if (!_isRoomCreateLogEnd)
|
||||
{
|
||||
_isRoomCreateLogEnd = true;
|
||||
AccumulateTraceLogLocked("#696951 " + _roomCreateLog);
|
||||
_roomCreateLog = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddRoomCreateLog(string log)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
if (!_isRoomCreateLogEnd)
|
||||
{
|
||||
DateTime dateTime = DateTime.Now.ToUniversalTime();
|
||||
log = dateTime.Day + "/" + dateTime.Hour + ":" + dateTime.Minute + ":" + dateTime.Second + ":" + dateTime.Millisecond.ToString("000") + log + "\n";
|
||||
_roomCreateLog += log;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void InitRoomCreateLog()
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
_roomCreateLog = "";
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateLoadResourceLog(string log)
|
||||
{
|
||||
lock (_gate)
|
||||
@@ -498,14 +409,6 @@ public class LocalLog
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetLoadResourceLog()
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
return _loadResourceLog;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetDisconnectLog(string log)
|
||||
{
|
||||
lock (_gate)
|
||||
@@ -513,7 +416,7 @@ public class LocalLog
|
||||
if (_disconnectLog == "")
|
||||
{
|
||||
DateTime dateTime = DateTime.Now.ToUniversalTime();
|
||||
log = dateTime.Day + "/" + dateTime.Hour + ":" + dateTime.Minute + ":" + dateTime.Second + ":" + dateTime.Millisecond.ToString("000") + ":[" + ToolboxGame.RealTimeNetworkAgent.NowSocketID + "]" + log + "\n";
|
||||
log = dateTime.Day + "/" + dateTime.Hour + ":" + dateTime.Minute + ":" + dateTime.Second + ":" + dateTime.Millisecond.ToString("000") + ":[0]" + log + "\n"; /* Pre-Phase-5 chunk 38: dead branch (RTA static removed) */
|
||||
_disconnectLog = log;
|
||||
}
|
||||
}
|
||||
@@ -770,28 +673,12 @@ public class LocalLog
|
||||
}
|
||||
}
|
||||
|
||||
public static void ClearTraceLog()
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
ClearTraceLogLocked();
|
||||
}
|
||||
}
|
||||
|
||||
private static void ClearTraceLogLocked()
|
||||
{
|
||||
ClearLog("TraceLog");
|
||||
ClearLog("TraceSettingLog");
|
||||
}
|
||||
|
||||
public static void ClearLastTraceLog(string key)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
ClearLog(key);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ClearInquiryLogKey()
|
||||
{
|
||||
ClearLog("TraceInquiryLog");
|
||||
@@ -837,14 +724,6 @@ public class LocalLog
|
||||
}
|
||||
}
|
||||
|
||||
public static void ClearLastLogKey()
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
ClearLastLogKeyLocked();
|
||||
}
|
||||
}
|
||||
|
||||
private static void ClearLastLogKeyLocked()
|
||||
{
|
||||
ClearLog("LastTraceLog1");
|
||||
@@ -852,73 +731,6 @@ public class LocalLog
|
||||
currentTurn = -1;
|
||||
}
|
||||
|
||||
public static void ClearAllLog()
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
ClearTraceLogLocked();
|
||||
ClearLastLogKeyLocked();
|
||||
ClearInquiryLogKey();
|
||||
}
|
||||
}
|
||||
|
||||
public static void RecordCheckLog(RecordType type, bool isWin)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
RecordCheckLogLocked(type, isWin);
|
||||
}
|
||||
}
|
||||
|
||||
private static void RecordCheckLogLocked(RecordType type, bool isWin)
|
||||
{
|
||||
if (BattleManagerBase.GetIns() == null || !isWin)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case RecordType.CERBERUS:
|
||||
if (BattleManagerBase.GetIns().BattlePlayer.Turn <= 1)
|
||||
{
|
||||
AccumulateLastTraceLog("CERBERUS AWAKEN");
|
||||
}
|
||||
break;
|
||||
case RecordType.HADES:
|
||||
{
|
||||
NetworkBattleManagerBase networkBattleManagerBase = (NetworkBattleManagerBase)BattleManagerBase.GetIns();
|
||||
if (networkBattleManagerBase.JudgeResultReceiveCode == NetworkBattleReceiver.RESULT_CODE.RetireWin || networkBattleManagerBase.JudgeResultReceiveCode == NetworkBattleReceiver.RESULT_CODE.DisconnectWin || networkBattleManagerBase.JudgeResultReceiveCode == NetworkBattleReceiver.RESULT_CODE.FirstcardWin || networkBattleManagerBase.BattlePlayer.PlayCardTouchCount != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
long num = ((ToolboxGame.RealTimeNetworkAgent != null) ? ToolboxGame.RealTimeNetworkAgent.GetBattleId() : 0);
|
||||
if (num <= 0 && Data.DoMatchingDetail.data != null)
|
||||
{
|
||||
num = Data.DoMatchingDetail.data.GetBattleId();
|
||||
}
|
||||
if (num <= 0)
|
||||
{
|
||||
RoomConnectController connectController = RoomBase.ConnectController;
|
||||
if (connectController != null && connectController.OwnCtrl is PlayerControllerForOwn playerControllerForOwn)
|
||||
{
|
||||
num = playerControllerForOwn.GetBattleId();
|
||||
}
|
||||
}
|
||||
AccumulateTraceLog("HADES AWAKEN BattleID:" + num);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void RecordMemoryOnLastTurnLog()
|
||||
{
|
||||
}
|
||||
|
||||
private static float ConvertByteToMegaByte(float _byte)
|
||||
{
|
||||
return _byte / 1024f / 1024f;
|
||||
}
|
||||
|
||||
private static string GetBattleAndViewIdText()
|
||||
{
|
||||
string battleIdText = GetBattleIdText();
|
||||
@@ -932,9 +744,9 @@ public class LocalLog
|
||||
|
||||
private static string GetBattleIdText()
|
||||
{
|
||||
if (ToolboxGame.RealTimeNetworkAgent != null)
|
||||
if (false) // Pre-Phase-5 (chunk 38): RTA has no static reach; log skips battle-id/socket-id
|
||||
{
|
||||
long battleId = ToolboxGame.RealTimeNetworkAgent.GetBattleId();
|
||||
long battleId = 0; /* Pre-Phase-5 chunk 38: dead branch (RTA static removed) */
|
||||
if (battleId == -1)
|
||||
{
|
||||
return string.Empty;
|
||||
@@ -946,9 +758,9 @@ public class LocalLog
|
||||
|
||||
private static string GetViewIdText()
|
||||
{
|
||||
if (ToolboxGame.RealTimeNetworkAgent != null)
|
||||
if (false) // Pre-Phase-5 (chunk 38): RTA has no static reach; log skips battle-id/socket-id
|
||||
{
|
||||
int viewId = ToolboxGame.RealTimeNetworkAgent.GetViewId();
|
||||
int viewId = 0; /* Pre-Phase-5 chunk 38: dead branch (RTA static removed) */
|
||||
if (viewId == 0)
|
||||
{
|
||||
return string.Empty;
|
||||
|
||||
Reference in New Issue
Block a user