forked from sin365/AxibugEmuOnline
netreplay
This commit is contained in:
parent
ea2e63cb58
commit
a4f8a382ac
@ -7,7 +7,8 @@ namespace AxiReplay
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 客户端当前帧
|
/// 客户端当前帧
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int mCurrClientFrameIdx { get; private set; } = -1;
|
public int mCurrClientFrameIdx => mCurrReplay.FrameStartID;
|
||||||
|
//public int mCurrClientFrameIdx
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 服务器远端当前帧
|
/// 服务器远端当前帧
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -20,6 +21,10 @@ namespace AxiReplay
|
|||||||
/// 当前数据
|
/// 当前数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ReplayStep mCurrReplay;
|
ReplayStep mCurrReplay;
|
||||||
|
/// <summary>
|
||||||
|
/// 下一个数据数据
|
||||||
|
/// </summary>
|
||||||
|
ReplayStep mNextReplay;
|
||||||
public NetReplay()
|
public NetReplay()
|
||||||
{
|
{
|
||||||
ResetData();
|
ResetData();
|
||||||
@ -29,6 +34,9 @@ namespace AxiReplay
|
|||||||
mNetReplayQueue.Clear();
|
mNetReplayQueue.Clear();
|
||||||
mRemoteFrameIdx = 0;
|
mRemoteFrameIdx = 0;
|
||||||
mCurrReplay = default(ReplayStep);
|
mCurrReplay = default(ReplayStep);
|
||||||
|
mCurrReplay.FrameStartID = 0;
|
||||||
|
mNextReplay = default(ReplayStep);
|
||||||
|
mNextReplay.FrameStartID = -1;
|
||||||
}
|
}
|
||||||
public void InData(ReplayStep inputData, int ServerFrameIdx)
|
public void InData(ReplayStep inputData, int ServerFrameIdx)
|
||||||
{
|
{
|
||||||
@ -43,15 +51,16 @@ namespace AxiReplay
|
|||||||
void TakeFrame(int addFrame, out ReplayStep data, out int bFrameDiff, out bool inputDiff)
|
void TakeFrame(int addFrame, out ReplayStep data, out int bFrameDiff, out bool inputDiff)
|
||||||
{
|
{
|
||||||
inputDiff = false;
|
inputDiff = false;
|
||||||
int targetFrame = mCurrClientFrameIdx += addFrame;
|
int targetFrame = mCurrClientFrameIdx + addFrame;
|
||||||
if (targetFrame <= mRemoteFrameIdx && mNetReplayQueue.Count > 0)
|
if (targetFrame >= mNextReplay.FrameStartID && targetFrame <= mRemoteFrameIdx && mNetReplayQueue.Count > 0)
|
||||||
{
|
{
|
||||||
//当前帧追加
|
//当前帧追加
|
||||||
mCurrClientFrameIdx = targetFrame;
|
//mCurrClientFrameIdx = targetFrame;
|
||||||
ulong oldInput = mCurrReplay.InPut;
|
ulong oldInput = mCurrReplay.InPut;
|
||||||
mCurrReplay = mNetReplayQueue.Dequeue();
|
mCurrReplay = mNextReplay;
|
||||||
if (oldInput != mCurrReplay.InPut)
|
if (oldInput != mCurrReplay.InPut)
|
||||||
inputDiff = true;
|
inputDiff = true;
|
||||||
|
mNextReplay = mNetReplayQueue.Dequeue();
|
||||||
}
|
}
|
||||||
bFrameDiff = mRemoteFrameIdx - mCurrClientFrameIdx;
|
bFrameDiff = mRemoteFrameIdx - mCurrClientFrameIdx;
|
||||||
data = mCurrReplay;
|
data = mCurrReplay;
|
||||||
|
@ -407,6 +407,7 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
void RecvHostSyn_RoomFrameAllInputData(byte[] reqData)
|
void RecvHostSyn_RoomFrameAllInputData(byte[] reqData)
|
||||||
{
|
{
|
||||||
Protobuf_Room_Syn_RoomFrameAllInputData msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_Syn_RoomFrameAllInputData>(reqData);
|
Protobuf_Room_Syn_RoomFrameAllInputData msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_Syn_RoomFrameAllInputData>(reqData);
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user