diff --git a/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs b/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs
index 29894d8a..6076318f 100644
--- a/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs
+++ b/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/NetReplay.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using UnityEngine;
namespace AxiReplay
{
@@ -23,7 +24,7 @@ namespace AxiReplay
///
/// 网络数据队列
///
- Queue mNetReplayQueue = new Queue();
+ public Queue mNetReplayQueue { get; private set; } = new Queue();
///
/// 当前数据
///
@@ -45,9 +46,11 @@ namespace AxiReplay
mCurrReplay.FrameStartID = int.MinValue;
bNetInit = false;
}
- public void InData(ReplayStep inputData, int ServerFrameIdx)
+ public void InData(ReplayStep inputData, int ServerFrameIdx, uint ServerForwardCount)
{
+ mRemoteForwardCount = (int)ServerForwardCount;
mNetReplayQueue.Enqueue(inputData);
+ Debug.Log($"InData=>{inputData.FrameStartID} QCount = >{mNetReplayQueue.Count}");
mRemoteFrameIdx = inputData.FrameStartID;
if (!bNetInit)
{
@@ -89,8 +92,9 @@ namespace AxiReplay
bool TakeFrameToTargetFrame(int targetFrame, out ReplayStep data, out int bFrameDiff, out bool inputDiff)
{
bool result;
- inputDiff = false;
- if (targetFrame == mNextReplay.FrameStartID && targetFrame <= mRemoteFrameIdx && mNetReplayQueue.Count > 0)
+ inputDiff = false;
+ //if (targetFrame == mNextReplay.FrameStartID && targetFrame <= mRemoteFrameIdx && mNetReplayQueue.Count > 0)
+ if (targetFrame == mNextReplay.FrameStartID && targetFrame <= mRemoteFrameIdx && mNetReplayQueue.Count >= mRemoteForwardCount)
{
//当前帧追加
mCurrClientFrameIdx = targetFrame;
@@ -112,7 +116,7 @@ namespace AxiReplay
public int GetSkipFrameCount()
{
- if(!bNetInit)
+ if (!bNetInit)
return 0;
//本地队列差异高于服务器提前量的值
int moreNum = mDiffFrameCount - mRemoteForwardCount;
@@ -125,13 +129,23 @@ namespace AxiReplay
int skip = 0;
if (mDiffFrameCount > short.MaxValue) skip = 0;
- else if (moreNum <= 1) skip = 0;
- else if (moreNum <= 3) skip = 2;
- else if (moreNum <= 6) skip = 2;
- else if (moreNum <= 20) skip = moreNum / 2; //20帧以内,平滑跳帧数
+ else if (moreNum <= mRemoteForwardCount) skip = 0;
+ else if (moreNum <= mRemoteForwardCount + 2) skip = 0;
+ else if (moreNum <= mRemoteForwardCount + 5) skip = 1;
+ else if (moreNum <= mRemoteForwardCount + 6) skip = 2;
+ else if (moreNum <= mRemoteForwardCount + 20) skip = moreNum / 2; //20帧以内,平滑跳帧数
else skip = moreNum;//完全追上
return skip;
+ //int skip = 0;
+ //if (mDiffFrameCount > short.MaxValue) skip = 0;
+ //else if (moreNum <= 1) skip = 0;
+ //else if (moreNum <= 3) skip = 2;
+ //else if (moreNum <= 6) skip = 2;
+ //else if (moreNum <= 20) skip = moreNum / 2; //20帧以内,平滑跳帧数
+ //else skip = moreNum;//完全追上
+ //return skip;
+
//var frameGap = mDiffFrameCount;
//if (frameGap > 10000) return 0;
//if (frameGap <= 2) skip = 0;
diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/MAMEEmu.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/MAMEEmu.cs
index 29dc7b90..a6ac2419 100644
--- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/MAMEEmu.cs
+++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/MAMEEmu.cs
@@ -46,6 +46,7 @@ namespace MAME.Core
Thread.Sleep(20);
State.loadstate_callback.Invoke(sr);
Mame.postload();
+ mameMainMotion.ResetFreameIndex();
Thread.Sleep(20);
Mame.paused = false;
}
diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/Motion/MameMainMotion.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/Motion/MameMainMotion.cs
index a2988171..b11cea67 100644
--- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/Motion/MameMainMotion.cs
+++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/Motion/MameMainMotion.cs
@@ -289,6 +289,15 @@ namespace MAME.Core
}
}
+ public void ResetFreameIndex()
+ {
+ Mame.paused = true;
+ Thread.Sleep(20);
+ Video.screenstate.frame_number = 0;
+ Thread.Sleep(20);
+ Mame.paused = false;
+ }
+
private void itemSelect()
{
switch (Machine.sBoard)
diff --git a/AxibugEmuOnline.Client/Assets/Resources/MAME/UMAME.prefab b/AxibugEmuOnline.Client/Assets/Resources/MAME/UMAME.prefab
index 2155aea7..a048b1b0 100644
--- a/AxibugEmuOnline.Client/Assets/Resources/MAME/UMAME.prefab
+++ b/AxibugEmuOnline.Client/Assets/Resources/MAME/UMAME.prefab
@@ -262,9 +262,9 @@ RectTransform:
m_Father: {fileID: 3471319444171359701}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
- m_AnchorMax: {x: 0, y: 1}
- m_AnchoredPosition: {x: 454.963, y: -46.19702}
- m_SizeDelta: {x: 871.1646, y: 70.007}
+ m_AnchorMax: {x: 1, y: 1}
+ m_AnchoredPosition: {x: 2.8257446, y: -46.19702}
+ m_SizeDelta: {x: -33.109863, y: 70.007}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3471319444327146580
CanvasRenderer:
@@ -296,10 +296,10 @@ MonoBehaviour:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
- m_FontSize: 41
+ m_FontSize: 18
m_FontStyle: 0
m_BestFit: 0
- m_MinSize: 10
+ m_MinSize: 1
m_MaxSize: 107
m_Alignment: 0
m_AlignByGeometry: 0
diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/MameEmulator/UMAME.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/MameEmulator/UMAME.cs
index b885f896..480a383f 100644
--- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/MameEmulator/UMAME.cs
+++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/MameEmulator/UMAME.cs
@@ -163,8 +163,6 @@ public class UMAME : MonoBehaviour, IEmuCore
}
void Update()
{
- mFPS.text = ($"fpsv {mUniVideoPlayer.videoFPS.ToString("F2")} fpsa {mUniSoundPlayer.audioFPS.ToString("F2")}");
-
if (!bInGame)
return;
@@ -176,13 +174,15 @@ public class UMAME : MonoBehaviour, IEmuCore
}
mUniVideoPlayer.ApplyFilterEffect();
mUniVideoPlayer.ApplyScreenScaler();
+
+ mFPS.text = ($"fpsv {mUniVideoPlayer.videoFPS.ToString("F2")} fpsa {mUniSoundPlayer.audioFPS.ToString("F2")} ,Idx:{App.roomMgr.netReplay?.mCurrClientFrameIdx},RIdx:{App.roomMgr.netReplay?.mRemoteFrameIdx},RForward:{App.roomMgr.netReplay?.mRemoteForwardCount} ,RD:{App.roomMgr.netReplay?.mRemoteForwardCount} ,D:{App.roomMgr.netReplay?.mDiffFrameCount} ,Q:{App.roomMgr.netReplay?.mNetReplayQueue.Count}");
}
//Ƿ֡Ч
void FixEmulatorFrame()
{
var skipFrameCount = App.roomMgr.netReplay.GetSkipFrameCount();
- if (skipFrameCount > 0) App.log.Debug($"SKIP FRAME : {skipFrameCount}");
+ if (skipFrameCount > 0) App.log.Debug($"SKIP FRAME : {skipFrameCount} ,CF:{App.roomMgr.netReplay.mCurrClientFrameIdx},RFIdx:{App.roomMgr.netReplay.mRemoteFrameIdx},RForward:{App.roomMgr.netReplay.mRemoteForwardCount} ,queue:{App.roomMgr.netReplay.mNetReplayQueue.Count}");
for (var i = 0; i < skipFrameCount; i++)
if (!PushEmulatorFrame())
break;
diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppRoom.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppRoom.cs
index 10c2f858..c06d86f6 100644
--- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppRoom.cs
+++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppRoom.cs
@@ -327,7 +327,7 @@ namespace AxibugEmuOnline.Client.Manager
{
UserDataBase newplayer = App.user.GetUserByUid(newJoin);
string newplayerName = newplayer != null ? newplayer.NickName : "Player";
- OverlayManager.PopTip($"[{newplayer}]进入房间");
+ OverlayManager.PopTip($"[{newplayer.NickName}]进入房间");
Eventer.Instance.PostEvent(EEvent.OnOtherPlayerJoinRoom, newJoin);
}
@@ -527,7 +527,7 @@ namespace AxibugEmuOnline.Client.Manager
TestAllData = 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);
+ netReplay.InData(new ReplayStep() { FrameStartID = (int)msg.FrameID, InPut = msg.InputData }, (int)msg.ServerFrameID, msg.ServerForwardCount);
}
public void SendScreen(byte[] RenderBuffer)
diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/NetworkHelper.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/NetworkHelper.cs
index 4a8babf2..9ea8343d 100644
--- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/NetworkHelper.cs
+++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/NetworkHelper.cs
@@ -83,7 +83,7 @@ namespace AxibugEmuOnline.Client.Network
{
//抛出网络数据
//网络线程直接抛
- if (CMDID == (int)CommandID.CmdPing || CMDID == (int)CommandID.CmdPong)
+ if (CMDID <= (int)CommandID.CmdPong)
NetMsg.Instance.PostNetMsgEvent(CMDID, ERRCODE, data);
else//加入队列,主线程来取
NetMsg.Instance.EnqueueNesMsg(CMDID, ERRCODE, data);