修复bug

This commit is contained in:
ALIENJACK\alien 2024-11-11 20:09:54 +08:00
parent 5e94eb4d16
commit 9324e185ef
2 changed files with 39 additions and 8 deletions

View File

@ -12,6 +12,10 @@ namespace AxiReplay
/// 服务器远端当前帧
/// </summary>
public int mRemoteFrameIdx { get; private set; } = int.MinValue;
/// <summary>
/// Remote 2 Client Frame Gap
/// </summary>
public int mDiffFrameCount => mRemoteFrameIdx - mCurrClientFrameIdx;
/// <summary>
/// 网络数据队列
/// </summary>

View File

@ -56,14 +56,9 @@ namespace AxibugEmuOnline.Client
if (NesCore != null)
{
Supporter.SampleInput();
var controlState = Supporter.GetControllerState();
//如果未收到Input数据,核心帧不推进
if (!controlState.valid) return;
NesCore.pad.Sync(controlState);
NesCore.EmulateFrame(true);
PushEmulatorFrame();
if (InGameUI.Instance.IsNetPlay)
FixEmulatorFrame();
var screenBuffer = NesCore.ppu.GetScreenPtr();
var lineColorMode = NesCore.ppu.GetLineColorMode();
@ -71,6 +66,38 @@ namespace AxibugEmuOnline.Client
}
}
private void FixEmulatorFrame()
{
int skipFrameCount = 0;
var frameGap = App.roomMgr.netReplay.mDiffFrameCount;
if (frameGap > 10000) return;
if (frameGap > 3 && frameGap < 6) skipFrameCount = 1;
else if (frameGap > 7 && frameGap < 12) skipFrameCount = 2;
else if (frameGap > 13 && frameGap < 20) skipFrameCount = 3;
else skipFrameCount = frameGap - 3;
if (skipFrameCount > 0) App.log.Debug($"SKIP FRAME : {skipFrameCount}");
for (int i = 0; i < skipFrameCount; i++)
{
if (!PushEmulatorFrame()) break;
}
}
private bool PushEmulatorFrame()
{
Supporter.SampleInput();
var controlState = Supporter.GetControllerState();
//如果未收到Input数据,核心帧不推进
if (!controlState.valid) return false;
NesCore.pad.Sync(controlState);
NesCore.EmulateFrame(true);
return true;
}
public void Pause()
{
m_bPause = true;