From c6e71ac282d37b4bfafd4c56fa3f00c76a510e35 Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Mon, 11 Nov 2024 16:12:54 +0800 Subject: [PATCH 1/3] log --- AxibugEmuOnline.Client/Assets/Script/App.cs | 18 ++++++++++++++++-- .../Assets/Script/Manager/AppRoom.cs | 2 +- .../Assets/Script/NesEmulator/CoreSupporter.cs | 4 ++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Script/App.cs b/AxibugEmuOnline.Client/Assets/Script/App.cs index aaeb8c66..9f0994f3 100644 --- a/AxibugEmuOnline.Client/Assets/Script/App.cs +++ b/AxibugEmuOnline.Client/Assets/Script/App.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using UnityEngine; using UnityEngine.Networking; using static AxibugEmuOnline.Client.HttpAPI; +using static AxibugEmuOnline.Client.Manager.LogManager; namespace AxibugEmuOnline.Client.ClientCore { @@ -157,8 +158,21 @@ namespace AxibugEmuOnline.Client.ClientCore App.log.Info("停止"); } static void OnNoSugarNetLog(int LogLevel, string msg) - { - Debug.Log("[AxibugEmuOnline]:" + msg); + { + E_LogType logType =(E_LogType)LogLevel; + switch (logType) + { + case E_LogType.Debug: + case E_LogType.Info: + Debug.Log("[AxiEmu]:" + msg); + break; + case E_LogType.Warning: + Debug.LogWarning("[AxiEmu]:" + msg); + break; + case E_LogType.Error: + Debug.LogError("[AxiEmu]:" + msg); + break; + } } } diff --git a/AxibugEmuOnline.Client/Assets/Script/Manager/AppRoom.cs b/AxibugEmuOnline.Client/Assets/Script/Manager/AppRoom.cs index 5be46262..d9639a47 100644 --- a/AxibugEmuOnline.Client/Assets/Script/Manager/AppRoom.cs +++ b/AxibugEmuOnline.Client/Assets/Script/Manager/AppRoom.cs @@ -407,7 +407,7 @@ namespace AxibugEmuOnline.Client.Manager void RecvHostSyn_RoomFrameAllInputData(byte[] reqData) { Protobuf_Room_Syn_RoomFrameAllInputData msg = ProtoBufHelper.DeSerizlize(reqData); - App.log.Debug($"ServerFrameID->{msg.ServerFrameID} FrameID->{msg.FrameID} ClientFrame->{netReplay.mCurrClientFrameIdx} InputData->{msg.InputData}"); + //App.log.Debug($"ServerFrameID->{msg.ServerFrameID} FrameID->{msg.FrameID} ClientFrame->{netReplay.mCurrClientFrameIdx} InputData->{msg.InputData}"); netReplay.InData(new ReplayStep() { FrameStartID = (int)msg.FrameID, InPut = msg.InputData }, (int)msg.ServerFrameID); } diff --git a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/CoreSupporter.cs b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/CoreSupporter.cs index 6ef8c4bb..b13440e7 100644 --- a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/CoreSupporter.cs +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/CoreSupporter.cs @@ -104,6 +104,8 @@ namespace AxibugEmuOnline.Client { if (App.roomMgr.netReplay.TryGetNextFrame(out var replayData, out int frameDiff, out bool inputDiff)) { + App.log.Debug($"TryGetNextFrame remoteFrame->{App.roomMgr.netReplay.mRemoteFrameIdx} diff->{frameDiff} " + + $"frame=>{replayData.FrameStartID} InPut=>{replayData.InPut}"); m_sampledState = FromNet(replayData); var localState = NesControllerMapper.Get().CreateState(); var rawData = ToNet(localState); @@ -111,6 +113,8 @@ namespace AxibugEmuOnline.Client } else { + App.log.Error($"Server Lag remoteFrame->{App.roomMgr.netReplay.mRemoteFrameIdx} diff->{frameDiff} " + + $"frame=>{replayData.FrameStartID} InPut=>{replayData.InPut}"); m_sampledState = default; } } From 6ab27375acf90403b8d68a52161e5205b881adfc Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Mon, 11 Nov 2024 16:31:19 +0800 Subject: [PATCH 2/3] fix --- .../Assets/Plugins/AxiReplay/NetReplay.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs b/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs index fba24893..f9dc374f 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs @@ -8,11 +8,10 @@ namespace AxiReplay /// 客户端当前帧 /// public int mCurrClientFrameIdx => mCurrReplay.FrameStartID; - //public int mCurrClientFrameIdx /// /// 服务器远端当前帧 /// - public int mRemoteFrameIdx { get; private set; } = -1; + public int mRemoteFrameIdx { get; private set; } = int.MinValue; /// /// 网络数据队列 /// @@ -36,7 +35,7 @@ namespace AxiReplay mCurrReplay = default(ReplayStep); mCurrReplay.FrameStartID = 0; mNextReplay = default(ReplayStep); - mNextReplay.FrameStartID = -1; + mNextReplay.FrameStartID = 0; } public void InData(ReplayStep inputData, int ServerFrameIdx) { @@ -52,10 +51,9 @@ namespace AxiReplay { inputDiff = false; int targetFrame = mCurrClientFrameIdx + addFrame; - if (targetFrame >= mNextReplay.FrameStartID && targetFrame <= mRemoteFrameIdx && mNetReplayQueue.Count > 0) + if (targetFrame <= mNextReplay.FrameStartID && targetFrame <= mRemoteFrameIdx && mNetReplayQueue.Count > 0) { //当前帧追加 - //mCurrClientFrameIdx = targetFrame; ulong oldInput = mCurrReplay.InPut; mCurrReplay = mNextReplay; if (oldInput != mCurrReplay.InPut) From 2dfbf983409a36060b374231421b700d234ef732 Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Mon, 11 Nov 2024 16:39:41 +0800 Subject: [PATCH 3/3] frame test --- AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs b/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs index f9dc374f..3a97a6e0 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs @@ -33,7 +33,7 @@ namespace AxiReplay mNetReplayQueue.Clear(); mRemoteFrameIdx = 0; mCurrReplay = default(ReplayStep); - mCurrReplay.FrameStartID = 0; + mCurrReplay.FrameStartID = int.MinValue; mNextReplay = default(ReplayStep); mNextReplay.FrameStartID = 0; } @@ -51,7 +51,7 @@ namespace AxiReplay { inputDiff = false; int targetFrame = mCurrClientFrameIdx + addFrame; - if (targetFrame <= mNextReplay.FrameStartID && targetFrame <= mRemoteFrameIdx && mNetReplayQueue.Count > 0) + if (targetFrame <= mNextReplay.FrameStartID + 1 && targetFrame <= mRemoteFrameIdx && mNetReplayQueue.Count > 0) { //当前帧追加 ulong oldInput = mCurrReplay.InPut;