Compare commits

..

No commits in common. "6b30c73c30b8f3bf15e99bb49f0004335127b405" and "e0e756b67cb06a611bbbce5347123e6b1f46d763" have entirely different histories.

11 changed files with 177 additions and 165 deletions

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace AxiReplay
{
@ -111,7 +110,7 @@ namespace AxiReplay
public int GetSkipFrameCount()
{
var frameGap = mDiffFrameCount;
if (frameGap <= 0) return 0;
if (frameGap > 10000) return 0;
int skip = 0;

View File

@ -5,7 +5,6 @@ using UnityEngine;
namespace AxibugEmuOnline.Client
{
/// <summary> 颜色设置 </summary>
public class BgColorSettings
{
public delegate void OnColorChangedHandle(XMBColor color);

View File

@ -112,17 +112,21 @@ namespace AxibugEmuOnline.Client
}
m_sampledState = FromNet(replayData);
var localState = NesControllerMapper.Get().CreateState();
var rawData = ToNet(localState);
if (LastTestInput != rawData)
{
LastTestInput = rawData;
App.log.Debug($"{DateTime.Now.ToString("hh:mm:ss.fff")} Input F:{App.roomMgr.netReplay.mCurrClientFrameIdx} | I:{rawData}");
}
App.roomMgr.SendRoomSingelPlayerInput(frameIndex, rawData);
}
else m_sampledState = default;
var localState = NesControllerMapper.Get().CreateState();
var rawData = ToNet(localState);
if (LastTestInput != rawData)
else
{
LastTestInput = rawData;
App.log.Debug($"{DateTime.Now.ToString("hh:mm:ss.fff")} Input F:{App.roomMgr.netReplay.mCurrClientFrameIdx} | I:{rawData}");
//App.log.Error($"Server Lag remoteFrame->{App.roomMgr.netReplay.mRemoteFrameIdx} diff->{frameDiff} " +
// $"frame=>{replayData.FrameStartID} InPut=>{replayData.InPut}");
m_sampledState = default;
}
App.roomMgr.SendRoomSingelPlayerInput(frameIndex, rawData);
}
else
{

View File

@ -62,7 +62,8 @@ namespace AxibugEmuOnline.Client
FixEmulatorFrame();
var screenBuffer = NesCore.ppu.GetScreenPtr();
VideoProvider.SetDrawData(screenBuffer);
var lineColorMode = NesCore.ppu.GetLineColorMode();
VideoProvider.SetDrawData(screenBuffer, lineColorMode, 277, 240);
}
}

View File

@ -1,7 +1,5 @@
using AxibugEmuOnline.Client.Common;
using System;
using System.Runtime.InteropServices;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
@ -25,10 +23,11 @@ namespace AxibugEmuOnline.Client
DrawCanvas.worldCamera = Camera.main;
}
public unsafe void SetDrawData(uint* screenData)
public unsafe void SetDrawData(uint* screenData, byte[] lineColorMode, int screenWidth, int screenHeight)
{
if (wrapTex == null)
{
//wrapTex = new Texture2D(272, 240, TextureFormat.BGRA32, false);
wrapTex = new Texture2D(272, 240, TextureFormat.RGBA32, false);
wrapTex.filterMode = FilterMode.Point;
@ -37,7 +36,7 @@ namespace AxibugEmuOnline.Client
Image.texture = wrapTex;
Image.material.SetTexture("_MainTex", wrapTex);
TexBufferSize = wrapTex.width * wrapTex.height * 4;
TexBufferSize = screenWidth * screenHeight * 4;
var palRaw = PaletteDefine.m_cnPalette[0];
pPal = new Texture2D(palRaw.Length, 1, TextureFormat.RGBA32, false);

View File

@ -41,34 +41,6 @@ namespace VirtualNes.Core
}
}
public unsafe static void memset(byte* ptr, int offset, byte value, int length)
{
var offsetptr = ptr + offset;
for (int i = 0; i < length; i++)
{
offsetptr[i] = value;
}
}
public unsafe static void memset(byte* ptr, byte value, int length)
{
memset(ptr, 0, value, length);
}
public unsafe static void memset(uint* ptr, int offset, uint value, int length)
{
var offsetptr = ptr + offset;
for (int i = 0; i < length; i++)
{
offsetptr[i] = value;
}
}
public unsafe static void memset(uint* ptr, uint value, int length)
{
memset(ptr, 0, value, length);
}
public static void memcpy(Array dst, Array src, int length)
{
Array.Copy(src, dst, length);

View File

@ -221,7 +221,10 @@ namespace VirtualNes.Core
Debuger.Log("Allocating PPU...");
ppu = new PPU(this);
ppu.InitBuffer();
var screenBuffer = new uint[PPU.SCREEN_WIDTH * PPU.SCREEN_HEIGHT];
var colormode = new byte[PPU.SCREEN_HEIGHT];
ppu.SetScreenPtr(screenBuffer, colormode);
Debuger.Log("Allocating APU...");
apu = new APU(this);
@ -763,9 +766,71 @@ namespace VirtualNes.Core
}
}
if (bDraw)
{
DrawPad();
}
FrameCount++;
}
private void DrawPad()
{
if (m_bMoviePlay)
{
int offset_h = 12;
int offset_v = Supporter.Config.graphics.bAllLine ? (240 - 18) : (240 - 22);
if (Supporter.Config.movie.bPadDisplay)
{
uint dwData = pad.GetSyncData();
for (int i = 0; i < 4; i++)
{
byte Data = (byte)(dwData >> (i * 8));
if ((m_MovieControl & (1 << i)) != 0)
{
DrawBitmap(offset_h, offset_v, m_PadImg);
// KEY
if ((Data & (1 << 4)) != 0) DrawBitmap(offset_h + 3, offset_v + 1, m_KeyImg0); // U
if ((Data & (1 << 5)) != 0) DrawBitmap(offset_h + 3, offset_v + 5, m_KeyImg0); // D
if ((Data & (1 << 6)) != 0) DrawBitmap(offset_h + 1, offset_v + 3, m_KeyImg0); // L
if ((Data & (1 << 7)) != 0) DrawBitmap(offset_h + 5, offset_v + 3, m_KeyImg0); // R
// START,SELECT
if ((Data & (1 << 2)) != 0) DrawBitmap(offset_h + 9, offset_v + 5, m_KeyImg1); // SELECT
if ((Data & (1 << 3)) != 0) DrawBitmap(offset_h + 13, offset_v + 5, m_KeyImg1); // START
// A,B
if ((Data & (1 << 0)) != 0) DrawBitmap(offset_h + 23, offset_v + 3, m_KeyImg2); // A
if ((Data & (1 << 1)) != 0) DrawBitmap(offset_h + 18, offset_v + 3, m_KeyImg2); // B
offset_h += 30;
}
}
}
if (Supporter.Config.movie.bTimeDisplay)
{
// Time display
int t = m_MovieStep;
int h = t / 216000;
t -= h * 216000;
int m = t / 3600;
t -= m * 3600;
int s = t / 60;
t -= s * 60;
string szTemp = $"{h:00}:{m:00}:{s:00}.{t * 100 / 60:00}";
DrawString(256 - 80 + 0, offset_v - 1, szTemp, 0x1F);
DrawString(256 - 80 + 0, offset_v + 1, szTemp, 0x1F);
DrawString(256 - 80 - 1, offset_v + 0, szTemp, 0x1F);
DrawString(256 - 80 + 1, offset_v + 0, szTemp, 0x1F);
DrawString(256 - 80, offset_v, szTemp, 0x30);
}
}
}
internal void DrawString(int x, int y, string str, byte col)
{
foreach (var @char in str)
@ -801,6 +866,33 @@ namespace VirtualNes.Core
}
}
private unsafe void DrawBitmap(int x, int y, byte[] bitMap)
{
int i, j;
int h, v;
var Scn = ppu.GetScreenPtr();
int pScn = 8 + (256 + 16) * y + x;
int pPtr;
int lpBitmap = 0;
h = bitMap[lpBitmap++];
v = bitMap[lpBitmap++];
for (j = 0; j < v; j++)
{
pPtr = pScn;
for (i = 0; i < h; i++)
{
if (bitMap[lpBitmap] != 0xFF)
{
Scn[pPtr] = bitMap[lpBitmap];
}
lpBitmap++;
pPtr++;
}
pScn += 256 + 16;
}
}
int CPU_CALL_COUNT = 0;
internal void EmulationCPU(int basecycles)

View File

@ -386,7 +386,7 @@ namespace VirtualNes.Core
loopy_shift = 0;
if (lpScreen != null)
MemoryUtility.memset(lpScreen, 0, 0, SCREEN_WIDTH * SCREEN_HEIGHT);
Unsafe.InitBlockUnaligned(lpScreen, 0, SCREEN_WIDTH * SCREEN_HEIGHT);
if (lpColormode != null)
MemoryUtility.memset(lpColormode, 0, SCREEN_HEIGHT);
}
@ -402,7 +402,7 @@ namespace VirtualNes.Core
if (lpScreen != null)
{
MemoryUtility.memset(lpScreen, 0, 0x3f, SCREEN_WIDTH);
Unsafe.InitBlockUnaligned(lpScreen, 0x3F, SCREEN_WIDTH);
}
if (lpColormode != null)
{
@ -457,8 +457,8 @@ namespace VirtualNes.Core
{
byte chr_h = 0, chr_l = 0, attr = 0;
MemoryUtility.memset(BGwrite, 0, 34);
MemoryUtility.memset(BGmono, 0, 34);
Unsafe.InitBlockUnaligned(BGwrite, 0, 34);
Unsafe.InitBlockUnaligned(BGmono, 0, 34);
// Linecolor mode
lpColormode[scanline] = (byte)(((MMU.PPUREG[1] & PPU_BGCOLOR_BIT) >> 5) | ((MMU.PPUREG[1] & PPU_COLORMODE_BIT) << 7));
@ -466,7 +466,7 @@ namespace VirtualNes.Core
// Render BG
if ((MMU.PPUREG[1] & PPU_BGDISP_BIT) == 0)
{
MemoryUtility.memset(lpScanline, MMU.BGPAL[0], SCREEN_WIDTH);
Unsafe.InitBlockUnaligned(lpScanline, MMU.BGPAL[0], SCREEN_WIDTH);
if (nes.GetRenderMethod() == EnumRenderMethod.TILE_RENDER)
{
nes.EmulationCPU(NES.FETCH_CYCLES * 4 * 32);
@ -869,7 +869,7 @@ namespace VirtualNes.Core
{
byte* pBGw = BGwrite;
byte* pSPw = SPwrite;
MemoryUtility.memset(pSPw, 0, 34);
Unsafe.InitBlockUnaligned(pSPw, 0, 34);
spmax = 0;
Sprite sp = new Sprite(MMU.SPRAM, 0);
@ -1092,11 +1092,8 @@ namespace VirtualNes.Core
return lpColormode;
}
internal void InitBuffer()
internal void SetScreenPtr(uint[] screenBuffer, byte[] colormode)
{
var screenBuffer = new uint[SCREEN_WIDTH * SCREEN_HEIGHT];
var colormode = new byte[SCREEN_HEIGHT];
lpScreenGCH = GCHandle.Alloc(screenBuffer, GCHandleType.Pinned);
lpScreen = (uint*)lpScreenGCH.AddrOfPinnedObject();
lpColormode = colormode;
@ -1183,16 +1180,11 @@ namespace VirtualNes.Core
}
}
[StructLayout(LayoutKind.Explicit, Size = 16)]
public struct UInt128
{
[FieldOffset(0)]
public UInt32 a;
[FieldOffset(4)]
public UInt32 b;
[FieldOffset(8)]
public UInt32 c;
[FieldOffset(12)]
public UInt32 d;
}
}

View File

@ -7,10 +7,6 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MySql.Data" Version="9.1.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="Google.Protobuf">
<HintPath>..\Lib\Google.Protobuf.dll</HintPath>

View File

@ -28,17 +28,18 @@ namespace AxibugEmuOnline.Server
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdRoomPlayerReady, OnRoomPlayerReady);
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdRoomSingelPlayerInput, OnSingelPlayerInput);
NetMsg.Instance.RegNetMsgEvent((int)CommandID.CmdScreen, OnCmdScreen);
roomTickARE = AppSrv.g_Tick.AddNewARE(TickManager.TickType.Interval_16MS);
threadRoomTick = new Thread(UpdateLoopTick);
threadRoomTick.Start();
//roomTickARE = AppSrv.g_Tick.AddNewARE(TickManager.TickType.Interval_16MS);
//threadRoomTick = new Thread(UpdateLoopTick);
//threadRoomTick.Start();
//System.Timers.Timer mTimer16ms = new System.Timers.Timer(16);//实例化Timer类
//mTimer16ms.Elapsed += new System.Timers.ElapsedEventHandler((source, e) => { UpdateAllRoomLogic(); });//到达时间的时候执行事件;
//mTimer16ms.AutoReset = true;//设置是执行一次false还是一直执行(true)
//mTimer16ms.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件
//mTimer16ms.Start();
System.Timers.Timer mTimer16ms = new System.Timers.Timer(16);//实例化Timer类
mTimer16ms.Elapsed += new System.Timers.ElapsedEventHandler((source, e) => { UpdateAllRoomLogic(); });//到达时间的时候执行事件;
mTimer16ms.AutoReset = true;//设置是执行一次false还是一直执行(true)
mTimer16ms.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件
mTimer16ms.Start();
}
#region
@ -152,7 +153,7 @@ namespace AxibugEmuOnline.Server
Errcode = ErrorCode.ErrorRoomNotFound;
else
{
resp.FrameID = (int)room.mCurrServerFrameId;
resp.FrameID = (int)room.mCurrFrameId;
resp.RoomID = room.RoomID;
resp.RawBitmap = room.ScreenRaw;
}
@ -200,7 +201,7 @@ namespace AxibugEmuOnline.Server
AppSrv.g_ClientMgr.ClientSend(_c, (int)CommandID.CmdRoomCreate, (int)joinErrcode, ProtoBufHelper.Serizlize(resp));
if (joinErrcode == ErrorCode.ErrorOk && bHadRoomStateChange)
SendRoomStepChange(newRoom);
SendRoomStateChange(newRoom);
SendRoomUpdateToAll(newRoom.RoomID, 0);
}
@ -234,7 +235,7 @@ namespace AxibugEmuOnline.Server
Protobuf_Room_MyRoom_State_Change(msg.RoomID);
if (joinErrcode == ErrorCode.ErrorOk && bHadRoomStateChange)
SendRoomStepChange(room);
SendRoomStateChange(room);
if (room != null)
{
@ -265,7 +266,7 @@ namespace AxibugEmuOnline.Server
//Protobuf_Room_MyRoom_State_Change(msg.RoomID);
//if (errcode == ErrorCode.ErrorOk && bHadRoomStateChange)
// SendRoomStepChange(room);
// SendRoomStateChange(room);
//SendRoomUpdateToAll(room.RoomID, 1);
//if (room.GetPlayerCount() < 1)
@ -282,7 +283,7 @@ namespace AxibugEmuOnline.Server
Data_RoomData room = GetRoomData(_c.RoomState.RoomID);
bool bHadRoomStateChange = false;
if (room == null)
{
{
errcode = ErrorCode.ErrorRoomNotFound;
AppSrv.g_ClientMgr.ClientSend(_c, (int)CommandID.CmdRoomLeave, (int)errcode, ProtoBufHelper.Serizlize(resp));
return;
@ -296,7 +297,7 @@ namespace AxibugEmuOnline.Server
Protobuf_Room_MyRoom_State_Change(RoomID);
if (errcode == ErrorCode.ErrorOk && bHadRoomStateChange)
SendRoomStepChange(room);
SendRoomStateChange(room);
if (room.GetPlayerCount() < 1)
{
@ -326,7 +327,7 @@ namespace AxibugEmuOnline.Server
{
room.SetLoadRaw(msg.LoadStateRaw, out bool bHadRoomStateChange);
if (bHadRoomStateChange)
SendRoomStepChange(room);
SendRoomStateChange(room);
}
}
@ -345,15 +346,17 @@ namespace AxibugEmuOnline.Server
room.SetRePlayerReady(_c.RoomState.PlayerIdx, out errcode, out bool bHadRoomStateChange);
if (bHadRoomStateChange)
{
SendRoomStepChange(room);
SendRoomStateChange(room);
}
}
}
ulong LastTestRecv = 0;
public void OnSingelPlayerInput(Socket sk, byte[] reqData)
{
ClientInfo _c = AppSrv.g_ClientMgr.GetClientForSocket(sk);
Protobuf_Room_SinglePlayerInputData msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_SinglePlayerInputData>(reqData);
Data_RoomData room = GetRoomData(_c.RoomState.RoomID);
if (room == null)
return;
@ -361,37 +364,14 @@ namespace AxibugEmuOnline.Server
//取玩家操作数据中的第一个
ServerInputSnapShot temp = new ServerInputSnapShot();
temp.all = msg.InputData;
//room.SetPlayerInput(_c.RoomState.PlayerIdx, msg.FrameID, temp);
room.SetPlayerInput(_c.RoomState.PlayerIdx, msg.FrameID, temp);
//是否需要推帧
if (room.GetNeedForwardTick(msg.FrameID, out long forwaFrame))
if (LastTestRecv != room.mCurrInputData.all)
{
for (int i = 0; i < forwaFrame; i++)
{
if (i + 1 == forwaFrame)//最后一帧
{
//写入操作前、将网络波动堆积可能造成瞬时多个连续推帧结果最后一帧除外立即广播不等16msTick
if (forwaFrame > 1)
room.SynInputData();
//推帧过程中,最后一帧才写入操作
room.SetPlayerInput(_c.RoomState.PlayerIdx, msg.FrameID, temp);
}
//推帧
room.TakeFrame();
}
}
else//不需要推帧
{
//虽然不推帧但是存入Input
room.SetPlayerInput(_c.RoomState.PlayerIdx, msg.FrameID, temp);
LastTestRecv = room.mCurrInputData.all;
AppSrv.g_Log.Debug($" {DateTime.Now.ToString("hh:mm:ss.fff")} SynTestRecv=> UID->{_c.UID} roomId->{room.mCurrFrameId} input->{msg.InputData}");
}
if (room.LastTestRecv != room.mCurrInputData.all)
{
room.LastTestRecv = room.mCurrInputData.all;
AppSrv.g_Log.Debug($" {DateTime.Now.ToString("hh:mm:ss.fff")} SynTestRecv=> UID->{_c.UID} roomId->{room.mCurrServerFrameId} input->{msg.InputData}");
}
}
public void OnCmdScreen(Socket sk, byte[] reqData)
@ -426,11 +406,7 @@ namespace AxibugEmuOnline.Server
}
}
/// <summary>
/// 广播联机Step
/// </summary>
/// <param name="room"></param>
public void SendRoomStepChange(Data_RoomData room)
public void SendRoomStateChange(Data_RoomData room)
{
List<ClientInfo> roomClient = room.GetAllPlayerClientList();
switch (room.GameState)
@ -441,7 +417,7 @@ namespace AxibugEmuOnline.Server
{
WaitStep = 0
};
AppSrv.g_Log.DebugCmd($"Step:0 WaitRawUpdate 广播等待主机上报即时存档");
AppSrv.g_Log.Debug($"Step=>{0} WaitRawUpdate 广播等待主机上报即时存档");
AppSrv.g_ClientMgr.ClientSend(roomClient, (int)CommandID.CmdRoomWaitStep, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(resp));
}
break;
@ -452,7 +428,8 @@ namespace AxibugEmuOnline.Server
WaitStep = 1,
LoadStateRaw = room.NextStateRaw
};
AppSrv.g_Log.DebugCmd($"Step:1 WaitReady 广播即时存档");
AppSrv.g_Log.Debug($"Step=>{1} WaitReady 广播即时存档");
AppSrv.g_ClientMgr.ClientSend(roomClient, (int)CommandID.CmdRoomWaitStep, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(resp));
}
break;
@ -462,13 +439,16 @@ namespace AxibugEmuOnline.Server
{
WaitStep = 2,
};
AppSrv.g_Log.DebugCmd($"Step:2 InOnlineGame 广播开始游戏");
AppSrv.g_Log.Debug($"Step=>{2} 广播开始游戏");
AppSrv.g_ClientMgr.ClientSend(roomClient, (int)CommandID.CmdRoomWaitStep, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(resp));
}
break;
}
}
#region
void UpdateLoopTick()
{
@ -488,7 +468,7 @@ namespace AxibugEmuOnline.Server
if (!mDictRoom.TryGetValue(roomid, out Data_RoomData room) || room.GameState < RoomGameState.InOnlineGame)
continue;
//更新帧
//room.TakeFrame();
room.TakeFrame();
//广播
room.SynInputData();
}
@ -514,10 +494,9 @@ namespace AxibugEmuOnline.Server
public List<long> SynUIDs;
//public RoomPlayerState PlayerState => getPlayerState();
private RoomGameState mGameState;
public uint mCurrServerFrameId = 0;
public uint mCurrFrameId = 0;
public ServerInputSnapShot mCurrInputData;
public Queue<(uint, ServerInputSnapShot)> mInputQueue;
object synInputLock = new object();
//TODO
public Dictionary<int, Queue<byte[]>> mDictPlayerIdx2SendQueue;
public RoomGameState GameState
@ -541,12 +520,6 @@ namespace AxibugEmuOnline.Server
}
}
/// <summary>
/// 服务器提前帧数
/// </summary>
public int SrvForwardFrames { get; set; }
bool IsAllReady()
{
bool Ready = true;
@ -679,9 +652,9 @@ namespace AxibugEmuOnline.Server
switch (PlayerIdx)
{
case 0: mCurrInputData.p1_byte = allinput.p1_byte; break;
case 1: mCurrInputData.p2_byte = allinput.p1_byte; break;
case 2: mCurrInputData.p3_byte = allinput.p1_byte; break;
case 3: mCurrInputData.p4_byte = allinput.p1_byte; break;
case 1: mCurrInputData.p2_byte = allinput.p2_byte; break;
case 2: mCurrInputData.p3_byte = allinput.p3_byte; break;
case 3: mCurrInputData.p4_byte = allinput.p4_byte; break;
}
}
@ -719,52 +692,47 @@ namespace AxibugEmuOnline.Server
maxNetDelay = Math.Max(maxNetDelay, player.AveNetDelay);
}
mCurrServerFrameId = 0;
mCurrFrameId = 0;
mCurrInputData.all = 1;
float MustTaskFrame = 3;
int TaskFrameCount = (int)((maxNetDelay / 0.016f) + 5f);
SrvForwardFrames = (int)((maxNetDelay / 0.016f) + MustTaskFrame);
AppSrv.g_Log.Debug($"服务器提前跑帧数:({maxNetDelay} / {0.016f}) + {MustTaskFrame} = {SrvForwardFrames}");
//服务器提前跑帧数
for (int i = 0; i < SrvForwardFrames; i++)
AppSrv.g_Log.Debug($"服务器提前跑帧数:({maxNetDelay} / {0.016f}) + {5f} = {TaskFrameCount}");
TaskFrameCount = 0;
for (int i = 0; i < TaskFrameCount; i++)
{
TakeFrame();
}
}
public void TakeFrame()
{
mInputQueue.Enqueue((mCurrServerFrameId, mCurrInputData));
mCurrServerFrameId++;
mInputQueue.Enqueue((mCurrFrameId, mCurrInputData));
mCurrFrameId++;
}
ulong LastTestSend = 0;
internal ulong LastTestRecv;
/// <summary>
/// 广播数据
/// </summary>
public void SynInputData()
{
lock (synInputLock)
while (mInputQueue.Count > 0)
{
while (mInputQueue.Count > 0)
(uint frameId, ServerInputSnapShot inputdata) data = mInputQueue.Dequeue();
Protobuf_Room_Syn_RoomFrameAllInputData resp = new Protobuf_Room_Syn_RoomFrameAllInputData()
{
(uint frameId, ServerInputSnapShot inputdata) data = mInputQueue.Dequeue();
Protobuf_Room_Syn_RoomFrameAllInputData resp = new Protobuf_Room_Syn_RoomFrameAllInputData()
{
FrameID = data.frameId,
InputData = data.inputdata.all,
ServerFrameID = mCurrServerFrameId
};
//if (LastTestSend != data.inputdata.all)
//{
// LastTestSend = data.inputdata.all;
// AppSrv.g_Log.Debug($" {DateTime.Now.ToString("hh:mm:ss.fff")} SynInput=> RoomID->{RoomID} ServerFrameID->{mCurrServerFrameId} SynUIDs=>{string.Join(",", SynUIDs)} ");
//}
AppSrv.g_ClientMgr.ClientSend(SynUIDs, (int)CommandID.CmdRoomSynPlayerInput, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(resp));
//AppSrv.g_Log.Debug($" {DateTime.Now.ToString("hh:mm:ss.fff")} SynInput=> RoomID->{RoomID} ServerFrameID->{mCurrServerFrameId} SynUIDs=>{string.Join(",", SynUIDs)} ");
FrameID = data.frameId,
InputData = data.inputdata.all,
ServerFrameID = mCurrFrameId
};
if (LastTestSend != data.inputdata.all)
{
LastTestSend = data.inputdata.all;
AppSrv.g_Log.Debug($" {DateTime.Now.ToString("hh:mm:ss.fff")} SynInput=> RoomID->{RoomID} ServerFrameID->{mCurrFrameId} SynUIDs=>{string.Join(",", SynUIDs)} ");
}
AppSrv.g_ClientMgr.ClientSend(SynUIDs, (int)CommandID.CmdRoomSynPlayerInput, (int)ErrorCode.ErrorOk, ProtoBufHelper.Serizlize(resp));
}
}
@ -910,16 +878,6 @@ namespace AxibugEmuOnline.Server
{
this.ScreenRaw = NextStateRaw;
}
public bool GetNeedForwardTick(uint clientFrame,out long forwaFrame)
{
forwaFrame = 0;
//目标帧,客户端+服务器提前量
long targetFrame = clientFrame + SrvForwardFrames;
if (targetFrame > mCurrServerFrameId)//更靠前
forwaFrame = targetFrame - mCurrServerFrameId;
return forwaFrame > 0;
}
}
[StructLayout(LayoutKind.Explicit, Size = 8)]

View File

@ -29,7 +29,7 @@ namespace AxibugEmuOnline.Server
AppSrv.g_Log.Info($"GameRomID:{room.GameRomID}");
AppSrv.g_Log.Info($"GameState:{room.GameState}");
AppSrv.g_Log.Info($"HostUID:{room.HostUID}");
AppSrv.g_Log.Info($"mCurrFrameId:{room.mCurrServerFrameId}");
AppSrv.g_Log.Info($"mCurrFrameId:{room.mCurrFrameId}");
AppSrv.g_Log.Info($"input all:{room.mCurrInputData.all}");
AppSrv.g_Log.Info($"input p1:{room.mCurrInputData.p1_byte}");
AppSrv.g_Log.Info($"input p2:{room.mCurrInputData.p2_byte}");