feat(battle-engine): full Unity/VFX/god-object shims + expanded copy closure (2570 files)
Authored Unity primitive/object-model shim, VFX layer (control-flow-preserving, InstantVfx never invokes its action -- headless suppression), god-object stubs (GameMgr/EffectMgr/UIManager with faithfully-extracted nested enums), View/UI/Touch tree, LitJson+BetterList+Tuple copied, third-party stubs. Discovered Roslyn header-error masking: fixing class-header type errors unmasks body references, so the true copy closure is ~2570 files (was 782 under masking). Errors: masked-25720 -> 268; our shim files compile clean. Remaining: ~50 residual shim/external types, 24 NGUI UI-base overrides, static-type fixes, plus likely 1-2 more unmask waves.
This commit is contained in:
828
SVSim.BattleEngine/Engine/Wizard/LocalLog.cs
Normal file
828
SVSim.BattleEngine/Engine/Wizard/LocalLog.cs
Normal file
@@ -0,0 +1,828 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Cute;
|
||||
using UnityEngine;
|
||||
using Wizard.RoomMatch;
|
||||
|
||||
namespace Wizard;
|
||||
|
||||
public class LocalLog
|
||||
{
|
||||
public enum TRACELOG_TYPE
|
||||
{
|
||||
TRACE_ALL_LOG,
|
||||
TRACE_LOG,
|
||||
TRACE_LAST_LOG,
|
||||
TRACE_INQUIRY_LOG
|
||||
}
|
||||
|
||||
public enum RecordType
|
||||
{
|
||||
CERBERUS,
|
||||
HADES
|
||||
}
|
||||
|
||||
private static string AccumulateLogPath = Application.persistentDataPath + "/accumulate_log";
|
||||
|
||||
private static string AccumulateSettingLogPath = Application.persistentDataPath + "/setting_info_log";
|
||||
|
||||
private static string LastAccumulate1LogPath = Application.persistentDataPath + "/last_accumulate_log1";
|
||||
|
||||
private static string LastAccumulate2LogPath = Application.persistentDataPath + "/last_accumulate_log2";
|
||||
|
||||
private static string InquiryLogPath = Application.persistentDataPath + "/inquiry_log";
|
||||
|
||||
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 = "";
|
||||
|
||||
private static string _socketFrameLog = "";
|
||||
|
||||
private static string _disconnectLog = "";
|
||||
|
||||
public static bool _isSendGungnirLog = false;
|
||||
|
||||
public static bool _isSendSocketFrameLog = false;
|
||||
|
||||
private static bool _isLastTraceLogTimeAdd = false;
|
||||
|
||||
private const string _resourceLoadErrorText = "ResourcesManager ParallelAssetListExec Error";
|
||||
|
||||
private static StringBuilder _lastTraceLogStringBuilder = null;
|
||||
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
public static void CreateLogFile()
|
||||
{
|
||||
CreateLocalLogFile(AccumulateLogPath);
|
||||
CreateLocalLogFile(AccumulateSettingLogPath);
|
||||
CreateLocalLogFile(LastAccumulate1LogPath);
|
||||
CreateLocalLogFile(LastAccumulate2LogPath);
|
||||
CreateLocalLogFile(InquiryLogPath);
|
||||
}
|
||||
|
||||
public static void CreateLocalLogFile(string filePath)
|
||||
{
|
||||
FileStream fileStream = null;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
using (fileStream = File.Create(filePath))
|
||||
{
|
||||
fileStream.Close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
string text = "FailedToCreateFile:" + filePath;
|
||||
fileStream?.Dispose();
|
||||
_failureWriteClientLog = _failureWriteClientLog + text + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
public static void SendAllClientTraceLog(Action onSended)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
private static void MakeTreceLogToSend(TRACELOG_TYPE logType, Action onSended)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Certification.Udid) || Certification.ViewerId == 0)
|
||||
{
|
||||
onSended.Call();
|
||||
return;
|
||||
}
|
||||
string log = string.Empty;
|
||||
string text = string.Empty;
|
||||
string log2 = string.Empty;
|
||||
string log3 = string.Empty;
|
||||
bool flag = false;
|
||||
string text2 = string.Empty;
|
||||
string text3 = string.Empty;
|
||||
string text4 = string.Empty;
|
||||
string text5 = string.Empty;
|
||||
string text6 = string.Empty;
|
||||
switch (logType)
|
||||
{
|
||||
case TRACELOG_TYPE.TRACE_ALL_LOG:
|
||||
text2 = ReadLogFile(AccumulateLogPath);
|
||||
text2 += _failureWriteClientLog;
|
||||
text3 = ReadLogFile(LastAccumulate1LogPath);
|
||||
text4 = ReadLogFile(LastAccumulate2LogPath);
|
||||
text5 = ReadLogFile(AccumulateSettingLogPath);
|
||||
text6 = ReadLogFile(InquiryLogPath);
|
||||
break;
|
||||
case TRACELOG_TYPE.TRACE_LOG:
|
||||
text2 = ReadLogFile(AccumulateLogPath);
|
||||
text2 += _failureWriteClientLog;
|
||||
text5 = ReadLogFile(AccumulateSettingLogPath);
|
||||
break;
|
||||
case TRACELOG_TYPE.TRACE_LAST_LOG:
|
||||
text3 = ReadLogFile(LastAccumulate1LogPath);
|
||||
text4 = ReadLogFile(LastAccumulate2LogPath);
|
||||
break;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(text2) || !string.IsNullOrEmpty(text3) || !string.IsNullOrEmpty(text4) || !string.IsNullOrEmpty(text5) || !string.IsNullOrEmpty(text6))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
if (GetBattleAndViewIdText() != string.Empty)
|
||||
{
|
||||
log = GetBattleAndViewIdText() + "\n";
|
||||
}
|
||||
switch (logType)
|
||||
{
|
||||
case TRACELOG_TYPE.TRACE_ALL_LOG:
|
||||
log = text2;
|
||||
if (ToolboxGame.RealTimeNetworkAgent != null)
|
||||
{
|
||||
text = text + "bId" + ToolboxGame.RealTimeNetworkAgent.GetBattleId() + "\n";
|
||||
}
|
||||
text += AppendLastLog(text3, text4);
|
||||
log2 = text5;
|
||||
log3 = "InquiryLog:" + text6;
|
||||
break;
|
||||
case TRACELOG_TYPE.TRACE_LOG:
|
||||
log = text2;
|
||||
log2 = text5;
|
||||
break;
|
||||
case TRACELOG_TYPE.TRACE_LAST_LOG:
|
||||
text += AppendLastLog(text3, text4);
|
||||
if (_isSendGungnirLog)
|
||||
{
|
||||
text = text + "\nGungnirLog:==================\n" + _gungnirLog;
|
||||
InitGungnirLog();
|
||||
}
|
||||
if (_isSendSocketFrameLog)
|
||||
{
|
||||
text = text + "\nSocketFrameLog:==================\n" + _socketFrameLog;
|
||||
InitSocketFrameLog();
|
||||
}
|
||||
if (!string.IsNullOrEmpty(_disconnectLog))
|
||||
{
|
||||
text = text + "\nDisconnectLog:==================\n" + _disconnectLog;
|
||||
InitDisconnectLog();
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (logType)
|
||||
{
|
||||
case TRACELOG_TYPE.TRACE_LAST_LOG:
|
||||
if (IsLogNullOrEmpty(text))
|
||||
{
|
||||
onSended.Call();
|
||||
}
|
||||
else
|
||||
{
|
||||
SendTraceLog(logType, string.Empty, GetShapedLog(text), string.Empty, string.Empty, onSended);
|
||||
}
|
||||
break;
|
||||
case TRACELOG_TYPE.TRACE_LOG:
|
||||
if (IsLogNullOrEmpty(log) && IsLogNullOrEmpty(log2))
|
||||
{
|
||||
onSended.Call();
|
||||
}
|
||||
else
|
||||
{
|
||||
SendTraceLog(logType, GetShapedLog(log), string.Empty, GetShapedLog(log2), string.Empty, onSended);
|
||||
}
|
||||
break;
|
||||
case TRACELOG_TYPE.TRACE_ALL_LOG:
|
||||
if (IsLogNullOrEmpty(log) && IsLogNullOrEmpty(text) && IsLogNullOrEmpty(log2) && IsLogNullOrEmpty(log3))
|
||||
{
|
||||
onSended.Call();
|
||||
}
|
||||
else
|
||||
{
|
||||
SendTraceLog(logType, GetShapedLog(log), GetShapedLog(text), GetShapedLog(log2), GetShapedLog(log3), onSended);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
onSended.Call();
|
||||
}
|
||||
}
|
||||
|
||||
public static void RecordResouseLoadError(int errorFlag)
|
||||
{
|
||||
UIManager.ViewScene currentScene = UIManager.GetInstance().GetCurrentScene();
|
||||
string text = ((currentScene == UIManager.ViewScene.Battle && ToolboxGame.RealTimeNetworkAgent != null) ? "NetworkBattle" : currentScene.ToString());
|
||||
AccumulateTraceLog("ResourcesManager ParallelAssetListExec Error in " + text + " : " + errorFlag);
|
||||
}
|
||||
|
||||
public static void RecordTurnEndIfLoadErrorOccured()
|
||||
{
|
||||
if (ExistResourceLoadErrorInNetWorkBattle())
|
||||
{
|
||||
AccumulateTraceLog("TurnEnd After LoadError");
|
||||
}
|
||||
}
|
||||
|
||||
public static void RecordFreezeLogIfLoadErrorOccured()
|
||||
{
|
||||
if (ExistResourceLoadErrorInNetWorkBattle())
|
||||
{
|
||||
AccumulateTraceLog("ResourceLoadFreeze in NetworkBattleScene");
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ExistResourceLoadErrorInNetWorkBattle()
|
||||
{
|
||||
return ReadLogFile(AccumulateLogPath).Contains("ResourcesManager ParallelAssetListExec Error in NetworkBattle");
|
||||
}
|
||||
|
||||
private static string AppendLastLog(string append_log1, string append_log2)
|
||||
{
|
||||
string text = "";
|
||||
if (nowTraceTurn != 0)
|
||||
{
|
||||
text += append_log1;
|
||||
return text + append_log2;
|
||||
}
|
||||
text += append_log2;
|
||||
return text + append_log1;
|
||||
}
|
||||
|
||||
private static bool IsLogNullOrEmpty(string log)
|
||||
{
|
||||
return string.IsNullOrEmpty(log.Replace("\n", "").Replace("\r", ""));
|
||||
}
|
||||
|
||||
private static string GetShapedLog(string log)
|
||||
{
|
||||
log = log.Replace("\n", "&&").Replace("\r", "");
|
||||
string text = "ID:" + PlayerStaticData.UserViewerID + " {\n" + log + " \n}";
|
||||
text.Replace("\n", "\\n");
|
||||
return text;
|
||||
}
|
||||
|
||||
private static void SendTraceLog(TRACELOG_TYPE logType, string log, string last_log, string setting_log, string inquiry_log, Action onSended)
|
||||
{
|
||||
bool showLoadingIcon = false;
|
||||
SendTraceLogTask sendTraceLogTask = new SendTraceLogTask(logType);
|
||||
if (logType == TRACELOG_TYPE.TRACE_LAST_LOG)
|
||||
{
|
||||
sendTraceLogTask.SetParameter(last_log);
|
||||
}
|
||||
else if (logType == TRACELOG_TYPE.TRACE_LOG)
|
||||
{
|
||||
sendTraceLogTask.SetParameter(log, setting_log);
|
||||
}
|
||||
else
|
||||
{
|
||||
showLoadingIcon = true;
|
||||
sendTraceLogTask.SetParameter(log + inquiry_log, last_log, setting_log);
|
||||
}
|
||||
sendTraceLogTask.SkipCuteHttpStatusErrorPopup();
|
||||
sendTraceLogTask.SkipCuteTimeOutPopup();
|
||||
sendTraceLogTask.SkipAllCuteResultCodeCheckErrorPopup();
|
||||
UIManager.GetInstance().StartCoroutine(Toolbox.NetworkManager.Connect(sendTraceLogTask, delegate
|
||||
{
|
||||
ClearLogByType(logType);
|
||||
onSended.Call();
|
||||
}, delegate
|
||||
{
|
||||
onSended.Call();
|
||||
}, delegate
|
||||
{
|
||||
onSended.Call();
|
||||
}, encrypt: true, useJson: false, showLoadingIcon));
|
||||
}
|
||||
|
||||
public static void AccumulateTraceLog(string log)
|
||||
{
|
||||
AccumulateLog(GetBattleAndViewIdText() + log, "TraceLog");
|
||||
}
|
||||
|
||||
public static void AccumulateTraceInquiryLog(string log)
|
||||
{
|
||||
AccumulateLog(log, "TraceInquiryLog");
|
||||
OrganizeInquiryLog();
|
||||
}
|
||||
|
||||
public static void AccumulateSettingLog()
|
||||
{
|
||||
if (!(ToolboxGame.RealTimeNetworkAgent == null))
|
||||
{
|
||||
string battleAndViewIdText = GetBattleAndViewIdText();
|
||||
string text = (PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.SHOW_BATTLE_EFFECT) ? "1" : "0");
|
||||
string text2 = (PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.CONFIRM_TURN_END) ? "1" : "0");
|
||||
string text3 = (PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.CONFIRM_EVOLVE) ? "1" : "0");
|
||||
string text4 = (PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.IS_SELECT_WSS) ? "1" : "0");
|
||||
AccumulateLog(battleAndViewIdText + "BattleSetting:" + text + text2 + text3 + text4, "TraceSettingLog");
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddGungnirLog(string log)
|
||||
{
|
||||
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";
|
||||
_gungnirLog += log;
|
||||
}
|
||||
}
|
||||
|
||||
public static void InitGungnirLog()
|
||||
{
|
||||
_gungnirLog = "";
|
||||
if (ToolboxGame.RealTimeNetworkAgent != null && _isSendGungnirLog)
|
||||
{
|
||||
ToolboxGame.RealTimeNetworkAgent.NetworkLogger.LogInfo("OffGungnirLog");
|
||||
}
|
||||
_isSendGungnirLog = false;
|
||||
}
|
||||
|
||||
public static void AddSocketFrameLog(string log)
|
||||
{
|
||||
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()
|
||||
{
|
||||
_socketFrameLog = "";
|
||||
if (ToolboxGame.RealTimeNetworkAgent != null && _isSendSocketFrameLog)
|
||||
{
|
||||
ToolboxGame.RealTimeNetworkAgent.NetworkLogger.LogInfo("OffSocketFrameLog");
|
||||
}
|
||||
_isSendSocketFrameLog = false;
|
||||
}
|
||||
|
||||
public static void AccumulateTraceLogAddRoomCreateLog()
|
||||
{
|
||||
if (!_isRoomCreateLogEnd)
|
||||
{
|
||||
_isRoomCreateLogEnd = true;
|
||||
AccumulateTraceLog("#696951 " + _roomCreateLog);
|
||||
InitRoomCreateLog();
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddRoomCreateLog(string log)
|
||||
{
|
||||
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()
|
||||
{
|
||||
_roomCreateLog = "";
|
||||
}
|
||||
|
||||
public static void UpdateLoadResourceLog(string log)
|
||||
{
|
||||
_loadResourceLog = log;
|
||||
}
|
||||
|
||||
public static string GetLoadResourceLog()
|
||||
{
|
||||
return _loadResourceLog;
|
||||
}
|
||||
|
||||
public static void SetDisconnectLog(string log)
|
||||
{
|
||||
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";
|
||||
_disconnectLog = log;
|
||||
}
|
||||
}
|
||||
|
||||
public static void InitDisconnectLog()
|
||||
{
|
||||
_disconnectLog = "";
|
||||
}
|
||||
|
||||
public static void AccumulateLastTraceLog(string log)
|
||||
{
|
||||
if (_lastTraceLogStringBuilder == null)
|
||||
{
|
||||
_lastTraceLogStringBuilder = new StringBuilder();
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastTraceLogStringBuilder.Append("\n");
|
||||
}
|
||||
float num = 0f;
|
||||
if (num != 0f && num / (float)SystemInfo.systemMemorySize > 0.8f)
|
||||
{
|
||||
string text = "";
|
||||
log += text;
|
||||
}
|
||||
if (!_isLastTraceLogTimeAdd)
|
||||
{
|
||||
DateTime dateTime = DateTime.Now.ToUniversalTime();
|
||||
_lastTraceLogStringBuilder.AppendFormat("{0}/{1}:{2}:{3}:{4:000}:{5}", dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second, dateTime.Millisecond.ToString("000"), "\n" + log);
|
||||
_isLastTraceLogTimeAdd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastTraceLogStringBuilder.Append(log);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SubmitAccumulateLastTraceLog()
|
||||
{
|
||||
if (_lastTraceLogStringBuilder != null)
|
||||
{
|
||||
string key = "";
|
||||
if (nowTraceTurn == 0)
|
||||
{
|
||||
key = "LastTraceLog1";
|
||||
}
|
||||
else if (nowTraceTurn == 1)
|
||||
{
|
||||
key = "LastTraceLog2";
|
||||
}
|
||||
AccumulateLog(_lastTraceLogStringBuilder.ToString(), key, isTimeEnable: false);
|
||||
_isLastTraceLogTimeAdd = false;
|
||||
_lastTraceLogStringBuilder = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetLastTraceLogTurn(int turn)
|
||||
{
|
||||
if (currentTurn != turn)
|
||||
{
|
||||
string log = "Turn" + turn + " " + GetBattleAndViewIdText() + "====\n";
|
||||
string text = "";
|
||||
if (turn % 2 == 0)
|
||||
{
|
||||
text = "LastTraceLog1";
|
||||
nowTraceTurn = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "LastTraceLog2";
|
||||
nowTraceTurn = 1;
|
||||
}
|
||||
if (turn != 0)
|
||||
{
|
||||
ClearLastTraceLog(text);
|
||||
}
|
||||
WriteAccumulateTraceLog(text, log);
|
||||
currentTurn = turn;
|
||||
}
|
||||
}
|
||||
|
||||
private static string ReadLogFile(string filePath)
|
||||
{
|
||||
SubmitAccumulateLastTraceLog();
|
||||
string result = "";
|
||||
StreamReader streamReader = null;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
CreateLogFile();
|
||||
}
|
||||
using (streamReader = new StreamReader(filePath))
|
||||
{
|
||||
result = streamReader.ReadToEnd();
|
||||
streamReader.Close();
|
||||
streamReader.Dispose();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
streamReader?.Dispose();
|
||||
string text = "FailedToReadFile:" + filePath + "(" + ex?.ToString() + ")";
|
||||
Debug.LogError(text);
|
||||
_failureWriteClientLog = _failureWriteClientLog + text + "\n";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void WriteAccumulateTraceLog(string key, string log)
|
||||
{
|
||||
string text = "";
|
||||
switch (key)
|
||||
{
|
||||
default:
|
||||
return;
|
||||
case "TraceLog":
|
||||
text = AccumulateLogPath;
|
||||
break;
|
||||
case "LastTraceLog1":
|
||||
text = LastAccumulate1LogPath;
|
||||
break;
|
||||
case "LastTraceLog2":
|
||||
text = LastAccumulate2LogPath;
|
||||
break;
|
||||
case "TraceSettingLog":
|
||||
text = AccumulateSettingLogPath;
|
||||
break;
|
||||
case "TraceInquiryLog":
|
||||
text = InquiryLogPath;
|
||||
break;
|
||||
}
|
||||
try
|
||||
{
|
||||
if ((float)new FileInfo(text).Length / 1024f > 500f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
StreamWriter streamWriter = null;
|
||||
try
|
||||
{
|
||||
using (streamWriter = new StreamWriter(text, append: true))
|
||||
{
|
||||
streamWriter.WriteLine(log);
|
||||
streamWriter.Flush();
|
||||
streamWriter.Close();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string text2 = "FailedToWriteFile" + ex.ToString();
|
||||
Debug.LogError(text2);
|
||||
streamWriter?.Dispose();
|
||||
if (key == "TraceLog")
|
||||
{
|
||||
_failureWriteClientLog = _failureWriteClientLog + text2 + " " + log + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void OrganizeInquiryLog()
|
||||
{
|
||||
try
|
||||
{
|
||||
FileInfo fileInfo = new FileInfo(InquiryLogPath);
|
||||
if (fileInfo != null && (float)fileInfo.Length / 1024f > 5f)
|
||||
{
|
||||
string text = ReadLogFile(InquiryLogPath);
|
||||
string log = text.Substring((int)((float)text.Length - 2560f));
|
||||
ClearInquiryLogKey();
|
||||
AccumulateTraceInquiryLog(log);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private static void AccumulateLog(string log, string key, bool isTimeEnable = true)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Environment.UserName) && log.IndexOf("Users") >= 0)
|
||||
{
|
||||
if (log.IndexOf(Environment.UserName) >= 0)
|
||||
{
|
||||
log = log.Replace(Environment.UserName, "Environment_UserName");
|
||||
}
|
||||
if (log.IndexOf(Environment.UserName.ToLower()) >= 0)
|
||||
{
|
||||
log = log.Replace(Environment.UserName.ToLower(), "Environment_UserName");
|
||||
}
|
||||
if (log.IndexOf(Environment.UserName.ToUpper()) >= 0)
|
||||
{
|
||||
log = log.Replace(Environment.UserName.ToUpper(), "Environment_UserName");
|
||||
}
|
||||
}
|
||||
_ = Toolbox.DebugManager != null;
|
||||
if (isTimeEnable)
|
||||
{
|
||||
DateTime dateTime = DateTime.Now.ToUniversalTime();
|
||||
log = dateTime.Day + "/" + dateTime.Hour + ":" + dateTime.Minute + ":" + dateTime.Second + ":" + dateTime.Millisecond.ToString("000") + ":" + log;
|
||||
}
|
||||
try
|
||||
{
|
||||
WriteAccumulateTraceLog(key, log);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private static void ClearLogByType(TRACELOG_TYPE logType)
|
||||
{
|
||||
switch (logType)
|
||||
{
|
||||
case TRACELOG_TYPE.TRACE_ALL_LOG:
|
||||
_failureWriteClientLog = "";
|
||||
ClearTraceLog();
|
||||
ClearLastLogKey();
|
||||
ClearInquiryLogKey();
|
||||
break;
|
||||
case TRACELOG_TYPE.TRACE_LOG:
|
||||
_failureWriteClientLog = "";
|
||||
ClearTraceLog();
|
||||
break;
|
||||
case TRACELOG_TYPE.TRACE_LAST_LOG:
|
||||
ClearLastLogKey();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ClearTraceLog()
|
||||
{
|
||||
ClearLog("TraceLog");
|
||||
ClearLog("TraceSettingLog");
|
||||
}
|
||||
|
||||
public static void ClearLastTraceLog(string key)
|
||||
{
|
||||
ClearLog(key);
|
||||
}
|
||||
|
||||
private static void ClearInquiryLogKey()
|
||||
{
|
||||
ClearLog("TraceInquiryLog");
|
||||
}
|
||||
|
||||
private static void ClearLog(string key)
|
||||
{
|
||||
string text = "";
|
||||
switch (key)
|
||||
{
|
||||
default:
|
||||
return;
|
||||
case "TraceLog":
|
||||
text = AccumulateLogPath;
|
||||
break;
|
||||
case "LastTraceLog1":
|
||||
text = LastAccumulate1LogPath;
|
||||
break;
|
||||
case "LastTraceLog2":
|
||||
text = LastAccumulate2LogPath;
|
||||
break;
|
||||
case "TraceSettingLog":
|
||||
text = AccumulateSettingLogPath;
|
||||
break;
|
||||
case "TraceInquiryLog":
|
||||
text = InquiryLogPath;
|
||||
break;
|
||||
}
|
||||
StreamWriter streamWriter = null;
|
||||
try
|
||||
{
|
||||
using (streamWriter = new StreamWriter(text))
|
||||
{
|
||||
streamWriter.WriteLine("");
|
||||
streamWriter.Flush();
|
||||
streamWriter.Close();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.LogError("Failed to clear log");
|
||||
streamWriter?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public static void ClearLastLogKey()
|
||||
{
|
||||
ClearLastTraceLog("LastTraceLog1");
|
||||
ClearLastTraceLog("LastTraceLog2");
|
||||
currentTurn = -1;
|
||||
}
|
||||
|
||||
public static void ClearAllLog()
|
||||
{
|
||||
ClearTraceLog();
|
||||
ClearLastLogKey();
|
||||
ClearInquiryLogKey();
|
||||
}
|
||||
|
||||
public static void RecordCheckLog(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();
|
||||
string viewIdText = GetViewIdText();
|
||||
if (battleIdText.IsNotNullOrEmpty() || viewIdText.IsNotNullOrEmpty())
|
||||
{
|
||||
return "[bid " + battleIdText + " vid " + viewIdText + "]";
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private static string GetBattleIdText()
|
||||
{
|
||||
if (ToolboxGame.RealTimeNetworkAgent != null)
|
||||
{
|
||||
long battleId = ToolboxGame.RealTimeNetworkAgent.GetBattleId();
|
||||
if (battleId == -1)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
return battleId.ToString();
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private static string GetViewIdText()
|
||||
{
|
||||
if (ToolboxGame.RealTimeNetworkAgent != null)
|
||||
{
|
||||
int viewId = ToolboxGame.RealTimeNetworkAgent.GetViewId();
|
||||
if (viewId == 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
return viewId.ToString();
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user