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:
@@ -1,18 +1,18 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
using Steamworks;
|
||||
using UnityEngine;
|
||||
using Wizard;
|
||||
using Wizard.Title;
|
||||
// TODO(engine-cleanup-pass2): 43 of 45 methods unrun in baseline
|
||||
// Type: Cute.Certification
|
||||
// See data_dumps/reports/engine-cleanup/live-methods.baseline.txt
|
||||
|
||||
|
||||
namespace Cute;
|
||||
|
||||
public class Certification : MonoBehaviour
|
||||
{
|
||||
public static bool CheckUrlScheme;
|
||||
|
||||
private const int ERROR_CODE_ACCOUNT_REMOVED = 5607;
|
||||
|
||||
private static string udid;
|
||||
|
||||
@@ -20,10 +20,6 @@ public class Certification : MonoBehaviour
|
||||
|
||||
private static string sessionId;
|
||||
|
||||
private const float DELAY_TIME = 0.02f;
|
||||
|
||||
protected Callback<GetAuthSessionTicketResponse_t> m_GetAuthSessionTicketResponse;
|
||||
|
||||
public static string Udid
|
||||
{
|
||||
get
|
||||
@@ -38,13 +34,11 @@ public class Certification : MonoBehaviour
|
||||
|
||||
public static int ViewerId
|
||||
{
|
||||
// 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 */ }
|
||||
// Instance-backed via BattleManagerBase.InstanceViewerId (Phase 5, chunk 40 — ambient
|
||||
// fallback dropped; all consumers routed through mgr in chunks 38-39). Default 1001 matches
|
||||
// EngineGlobalInit.ThisViewerId. Setter no-op preserved from Phase-4 semantics.
|
||||
get => BattleManagerBase.GetIns()?.InstanceViewerId ?? 1001;
|
||||
set { /* no-op; SavedataManager path dead headless */ }
|
||||
}
|
||||
|
||||
public static int ShortUdid
|
||||
@@ -80,23 +74,10 @@ public class Certification : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public static string dmmViewerId { get; private set; }
|
||||
|
||||
public static string dmmOnetimeToken { get; private set; }
|
||||
|
||||
public static ulong SteamID { get; private set; }
|
||||
|
||||
public static string SteamSessionTicket { get; private set; }
|
||||
|
||||
public static bool IsExistsViewerId()
|
||||
{
|
||||
if (ViewerId != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string GetEncodedViewerId()
|
||||
{
|
||||
string s = CryptAES.encrypt(ViewerId.ToString());
|
||||
@@ -122,244 +103,4 @@ public class Certification : MonoBehaviour
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void SetKeyChainViewerId(string viewerId)
|
||||
{
|
||||
}
|
||||
|
||||
public static void DeleteKeyChainViewerId()
|
||||
{
|
||||
}
|
||||
|
||||
public static void InitializeFileds()
|
||||
{
|
||||
sessionId = null;
|
||||
udid = null;
|
||||
short_udid = 0;
|
||||
Toolbox.SavedataManager.SetInt("VIEWER_ID", 0);
|
||||
Toolbox.SavedataManager.SetInt("SHORT_UDID", 0);
|
||||
Toolbox.SavedataManager.SetString("UDID", "");
|
||||
}
|
||||
|
||||
public IEnumerator Login()
|
||||
{
|
||||
if (ViewerId == 0)
|
||||
{
|
||||
GenerateUdid();
|
||||
SignUpTask signUpTask = new SignUpTask();
|
||||
signUpTask.SetParameter();
|
||||
yield return StartCoroutine(Toolbox.NetworkManager.Connect(signUpTask, delegate
|
||||
{
|
||||
StartCoroutine(GameStartCheckTaskExec());
|
||||
}, delegate
|
||||
{
|
||||
if (Toolbox.BootNetwork != null)
|
||||
{
|
||||
Toolbox.BootNetwork.IsDoneGameStartCheck = false;
|
||||
}
|
||||
OutOfService.ShowServiceEndedDialogIfNeeded();
|
||||
}, delegate
|
||||
{
|
||||
if (Toolbox.BootNetwork != null)
|
||||
{
|
||||
Toolbox.BootNetwork.IsDoneGameStartCheck = false;
|
||||
}
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return StartCoroutine(GameStartCheckTaskExec());
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsiCloudAvailable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void SetiCloudUser()
|
||||
{
|
||||
}
|
||||
|
||||
public static void EraseiCloudUser()
|
||||
{
|
||||
}
|
||||
|
||||
public static string GetiCloudUser()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public void CheckiCloudUserData(Action<NetworkTask.ResultCode> callback)
|
||||
{
|
||||
GetiCloudUserDataTask.VerifiediCloudUserData.Reset();
|
||||
string text = GetiCloudUser();
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
callback(NetworkTask.ResultCode.Success);
|
||||
return;
|
||||
}
|
||||
GenerateUdid();
|
||||
GetiCloudUserDataTask getiCloudUserDataTask = new GetiCloudUserDataTask();
|
||||
getiCloudUserDataTask.SetParameter(text);
|
||||
StartCoroutine(Toolbox.NetworkManager.Connect(getiCloudUserDataTask, callback));
|
||||
}
|
||||
|
||||
public void MigrateiCloudUserData(Action<NetworkTask.ResultCode> callback)
|
||||
{
|
||||
string parameter = GetiCloudUser();
|
||||
UpdateiCloudUserDataTask updateiCloudUserDataTask = new UpdateiCloudUserDataTask();
|
||||
updateiCloudUserDataTask.SetParameter(parameter);
|
||||
StartCoroutine(Toolbox.NetworkManager.Connect(updateiCloudUserDataTask, callback));
|
||||
}
|
||||
|
||||
public void FirstTimeSaveiCloudUserData()
|
||||
{
|
||||
if (IsiCloudAvailable() && string.IsNullOrEmpty(GetiCloudUser()))
|
||||
{
|
||||
SetiCloudUser();
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator GameStartCheckTaskExec()
|
||||
{
|
||||
GameStartCheckTask gameStartCheckTask = new GameStartCheckTask();
|
||||
gameStartCheckTask.AddSkipCuteCheckResultCode(5607);
|
||||
gameStartCheckTask.SetParameter();
|
||||
bool isRemoveAccount = false;
|
||||
yield return StartCoroutine(Toolbox.NetworkManager.Connect(gameStartCheckTask, delegate
|
||||
{
|
||||
if (Toolbox.BootNetwork != null)
|
||||
{
|
||||
Toolbox.BootNetwork.IsDoneGameStartCheck = true;
|
||||
}
|
||||
URLScheme.ClearCampaignData();
|
||||
}, delegate
|
||||
{
|
||||
if (Toolbox.BootNetwork != null)
|
||||
{
|
||||
Toolbox.BootNetwork.IsDoneGameStartCheck = false;
|
||||
}
|
||||
OutOfService.ShowServiceEndedDialogIfNeeded();
|
||||
}, delegate(int resultCode)
|
||||
{
|
||||
if (Toolbox.BootNetwork != null)
|
||||
{
|
||||
Toolbox.BootNetwork.IsDoneGameStartCheck = false;
|
||||
}
|
||||
URLScheme.ClearCampaignData();
|
||||
if (resultCode == 5607)
|
||||
{
|
||||
isRemoveAccount = true;
|
||||
OnRemoveAccount();
|
||||
}
|
||||
}));
|
||||
if (isRemoveAccount)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRemoveAccount()
|
||||
{
|
||||
DialogBase dialogBase = UIManager.GetInstance().CreateConfirmationDialog(Data.SystemText.Get("MyPage_0097"));
|
||||
dialogBase.SetTitleLabel(Data.SystemText.Get("ErrorHeader_0001"));
|
||||
dialogBase.SetSize(DialogBase.Size.M);
|
||||
dialogBase.OnClose = delegate
|
||||
{
|
||||
UserInfoRequest.DeleteUserData();
|
||||
};
|
||||
}
|
||||
|
||||
public void GenerateUdid()
|
||||
{
|
||||
udid = Cryptographer.decode(Toolbox.SavedataManager.GetString("UDID"));
|
||||
if (string.IsNullOrEmpty(udid))
|
||||
{
|
||||
Toolbox.SavedataManager.SetString("UDID", Cryptographer.encode(Guid.NewGuid().ToString()));
|
||||
Toolbox.SavedataManager.Save();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsLogined()
|
||||
{
|
||||
return !string.IsNullOrEmpty(sessionId);
|
||||
}
|
||||
|
||||
private IEnumerator Start()
|
||||
{
|
||||
while (Toolbox.BootSystem == null)
|
||||
{
|
||||
yield return 0;
|
||||
}
|
||||
SessionId = "";
|
||||
setDmmPlatformData();
|
||||
setSTEAMPlatformData();
|
||||
URLSchemeStart();
|
||||
}
|
||||
|
||||
private void OnApplicationFocus(bool focus)
|
||||
{
|
||||
if (focus)
|
||||
{
|
||||
URLSchemeStart();
|
||||
}
|
||||
}
|
||||
|
||||
private void URLSchemeStart()
|
||||
{
|
||||
if (CheckUrlScheme)
|
||||
{
|
||||
StartCoroutine(Delay(0.02f, delegate
|
||||
{
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator Delay(float waitTime, Action action)
|
||||
{
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
action();
|
||||
}
|
||||
|
||||
private void setSTEAMPlatformData()
|
||||
{
|
||||
try
|
||||
{
|
||||
SteamID = SteamUser.GetSteamID().m_SteamID;
|
||||
m_GetAuthSessionTicketResponse = Callback<GetAuthSessionTicketResponse_t>.Create(OnGetAuthSessionTicketResponse);
|
||||
byte[] array = new byte[1024];
|
||||
SteamNetworkingIdentity pSteamNetworkingIdentity = default(SteamNetworkingIdentity);
|
||||
SteamUser.GetAuthSessionTicket(array, array.Length, out var pcbTicket, ref pSteamNetworkingIdentity);
|
||||
Array.Resize(ref array, (int)pcbTicket);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int i = 0; i < pcbTicket; i++)
|
||||
{
|
||||
stringBuilder.AppendFormat("{0:x2}", array[i]);
|
||||
}
|
||||
SteamSessionTicket = stringBuilder.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError("<color=aqua>steam client が起動していない。steamの機能を使えません。</color>");
|
||||
Debug.LogError(ex.Message);
|
||||
Debug.LogError(ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGetAuthSessionTicketResponse(GetAuthSessionTicketResponse_t pCallback)
|
||||
{
|
||||
}
|
||||
|
||||
private void setDmmPlatformData()
|
||||
{
|
||||
}
|
||||
|
||||
public void URLSchemeStartiOS(string message)
|
||||
{
|
||||
URLScheme.URLSchemeStartiOS(message);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user