forked from sin365/AxibugEmuOnline
netinput
This commit is contained in:
parent
e0d6e0542d
commit
bb93b43ba8
@ -4,7 +4,6 @@ namespace AxiReplay
|
|||||||
{
|
{
|
||||||
public class NetReplay
|
public class NetReplay
|
||||||
{
|
{
|
||||||
int MaxInFrame = 0;
|
|
||||||
int mCurrPlayFrame = -1;
|
int mCurrPlayFrame = -1;
|
||||||
Queue<ReplayStep> mQueueReplay;
|
Queue<ReplayStep> mQueueReplay;
|
||||||
ReplayStep mNextReplay;
|
ReplayStep mNextReplay;
|
||||||
@ -13,20 +12,28 @@ namespace AxiReplay
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 服务器远端当前帧
|
/// 服务器远端当前帧
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int remoteFrameIdx { get; private set; }
|
public int mRemoteFrameIdx { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前帧和服务器帧相差数量
|
/// 当前帧和服务器帧相差数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int remoteFrameDiff => remoteFrameIdx - mCurrPlayFrame;
|
public int remoteFrameDiff => mRemoteFrameIdx - mCurrPlayFrame;
|
||||||
public NetReplay()
|
public NetReplay()
|
||||||
{
|
{
|
||||||
mQueueReplay = new Queue<ReplayStep>();
|
mQueueReplay = new Queue<ReplayStep>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetData()
|
||||||
|
{
|
||||||
|
mQueueReplay.Clear();
|
||||||
|
mRemoteFrameIdx = 0;
|
||||||
|
byFrameIdx = 0;
|
||||||
|
mNextReplay = default(ReplayStep);
|
||||||
|
mCurrReplay = default(ReplayStep);
|
||||||
|
}
|
||||||
public void InData(ReplayStep inputData,int ServerFrameIdx)
|
public void InData(ReplayStep inputData,int ServerFrameIdx)
|
||||||
{
|
{
|
||||||
mQueueReplay.Enqueue(inputData);
|
mQueueReplay.Enqueue(inputData);
|
||||||
MaxInFrame = inputData.FrameStartID;
|
mRemoteFrameIdx = inputData.FrameStartID;
|
||||||
remoteFrameIdx = ServerFrameIdx;
|
|
||||||
}
|
}
|
||||||
public bool NextFrame(out ReplayStep data, out int FrameDiff)
|
public bool NextFrame(out ReplayStep data, out int FrameDiff)
|
||||||
{
|
{
|
||||||
@ -55,17 +62,17 @@ namespace AxiReplay
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
data = mCurrReplay;
|
data = mCurrReplay;
|
||||||
FrameDiff = MaxInFrame - mCurrPlayFrame;
|
FrameDiff = mRemoteFrameIdx - mCurrPlayFrame;
|
||||||
}
|
}
|
||||||
return Changed;
|
return Changed;
|
||||||
}
|
}
|
||||||
void UpdateNextFrame(int targetFrame,out int FrameDiff)
|
void UpdateNextFrame(int targetFrame,out int FrameDiff)
|
||||||
{
|
{
|
||||||
FrameDiff = MaxInFrame - targetFrame;
|
FrameDiff = mRemoteFrameIdx - targetFrame;
|
||||||
//如果已经超过
|
//如果已经超过
|
||||||
while (targetFrame > mNextReplay.FrameStartID)
|
while (targetFrame > mNextReplay.FrameStartID)
|
||||||
{
|
{
|
||||||
if (mNextReplay.FrameStartID >= MaxInFrame)
|
if (mNextReplay.FrameStartID >= mRemoteFrameIdx)
|
||||||
{
|
{
|
||||||
//TODO
|
//TODO
|
||||||
//bEnd = true;
|
//bEnd = true;
|
||||||
|
@ -3,9 +3,6 @@ using AxibugEmuOnline.Client.Common;
|
|||||||
using AxibugEmuOnline.Client.Network;
|
using AxibugEmuOnline.Client.Network;
|
||||||
using AxibugProtobuf;
|
using AxibugProtobuf;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client.Manager
|
namespace AxibugEmuOnline.Client.Manager
|
||||||
{
|
{
|
||||||
@ -40,6 +37,9 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
{
|
{
|
||||||
App.log.Info("登录成功");
|
App.log.Info("登录成功");
|
||||||
App.user.InitMainUserData(App.user.userdata.Account, msg.UID);
|
App.user.InitMainUserData(App.user.userdata.Account, msg.UID);
|
||||||
|
|
||||||
|
App.log.Info("获取服务器列表");
|
||||||
|
App.roomMgr.SendGetRoomList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,6 @@ using AxiReplay;
|
|||||||
using Google.Protobuf;
|
using Google.Protobuf;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client.Manager
|
namespace AxibugEmuOnline.Client.Manager
|
||||||
{
|
{
|
||||||
@ -96,10 +95,11 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
public void InitRePlay()
|
public void InitRePlay()
|
||||||
{
|
{
|
||||||
netReplay = new NetReplay();
|
netReplay = new NetReplay();
|
||||||
|
netReplay.ResetData();
|
||||||
}
|
}
|
||||||
public void ReleaseRePlay()
|
public void ReleaseRePlay()
|
||||||
{
|
{
|
||||||
|
netReplay.ResetData();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
/// 上报即时存档
|
/// 上报即时存档
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="RoomID"></param>
|
/// <param name="RoomID"></param>
|
||||||
public void SendLeavnRoom(byte[] RawData)
|
public void SendHostRaw(byte[] RawData)
|
||||||
{
|
{
|
||||||
//压缩
|
//压缩
|
||||||
byte[] compressRawData = Helper.CompressByteArray(RawData);
|
byte[] compressRawData = Helper.CompressByteArray(RawData);
|
||||||
@ -355,7 +355,6 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
App.network.SendToServer((int)CommandID.CmdRoomSingelPlayerInput, ProtoBufHelper.Serizlize(_Protobuf_Room_SinglePlayerInputData));
|
App.network.SendToServer((int)CommandID.CmdRoomSingelPlayerInput, ProtoBufHelper.Serizlize(_Protobuf_Room_SinglePlayerInputData));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
|
@ -16,7 +16,6 @@ namespace AxibugEmuOnline.Server.Manager
|
|||||||
public DateTime LogOutDT { get; set; }
|
public DateTime LogOutDT { get; set; }
|
||||||
public DateTime LogInDT { get; set; }
|
public DateTime LogInDT { get; set; }
|
||||||
public UserRoomState RoomState { get; set; } = new UserRoomState();
|
public UserRoomState RoomState { get; set; } = new UserRoomState();
|
||||||
|
|
||||||
public TimeSpan LastStartPingTime { get; set; }
|
public TimeSpan LastStartPingTime { get; set; }
|
||||||
public int LastPingSeed { get; set; }
|
public int LastPingSeed { get; set; }
|
||||||
public double AveNetDelay { get; set; }
|
public double AveNetDelay { get; set; }
|
||||||
@ -34,13 +33,11 @@ namespace AxibugEmuOnline.Server.Manager
|
|||||||
{
|
{
|
||||||
ClearRoomData();
|
ClearRoomData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetRoomData(int roomID, int playerIdx)
|
public void SetRoomData(int roomID, int playerIdx)
|
||||||
{
|
{
|
||||||
RoomID = roomID;
|
RoomID = roomID;
|
||||||
PlayerIdx = playerIdx;
|
PlayerIdx = playerIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearRoomData()
|
public void ClearRoomData()
|
||||||
{
|
{
|
||||||
RoomID = -1;
|
RoomID = -1;
|
||||||
|
@ -270,7 +270,12 @@ namespace AxibugEmuOnline.Server
|
|||||||
Data_RoomData room = GetRoomData(_c.RoomState.RoomID);
|
Data_RoomData room = GetRoomData(_c.RoomState.RoomID);
|
||||||
if (room == null)
|
if (room == null)
|
||||||
return;
|
return;
|
||||||
room.SetPlayerInput(_c.RoomState.PlayerIdx, msg.FrameID, (ushort)msg.InputData);
|
|
||||||
|
//取玩家操作数据中的第一个
|
||||||
|
ServerInputSnapShot temp = new ServerInputSnapShot();
|
||||||
|
temp.all = msg.InputData;
|
||||||
|
|
||||||
|
room.SetPlayerInput(_c.RoomState.PlayerIdx, msg.FrameID, temp.p1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnCmdScreen(Socket sk, byte[] reqData)
|
public void OnCmdScreen(Socket sk, byte[] reqData)
|
||||||
@ -540,14 +545,14 @@ namespace AxibugEmuOnline.Server
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPlayerInput(int PlayerIdx, long mFrameID, ushort input)
|
public void SetPlayerInput(int PlayerIdx, long mFrameID, byte input)
|
||||||
{
|
{
|
||||||
switch (PlayerIdx)
|
switch (PlayerIdx)
|
||||||
{
|
{
|
||||||
case 0: mCurrInputData.p1 = input; break;
|
case 0: mCurrInputData.p1_byte = input; break;
|
||||||
case 1: mCurrInputData.p2 = input; break;
|
case 1: mCurrInputData.p2_byte = input; break;
|
||||||
case 2: mCurrInputData.p3 = input; break;
|
case 2: mCurrInputData.p3_byte = input; break;
|
||||||
case 3: mCurrInputData.p4 = input; break;
|
case 3: mCurrInputData.p4_byte = input; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -753,18 +758,28 @@ namespace AxibugEmuOnline.Server
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[StructLayout(LayoutKind.Explicit, Size = 8)]
|
||||||
public struct ServerInputSnapShot
|
public struct ServerInputSnapShot
|
||||||
{
|
{
|
||||||
[FieldOffset(0)]
|
[FieldOffset(0)]
|
||||||
public UInt64 all;
|
public UInt64 all;
|
||||||
|
|
||||||
[FieldOffset(0)]
|
[FieldOffset(0)]
|
||||||
public ushort p1;
|
public byte p1_byte;
|
||||||
|
[FieldOffset(1)]
|
||||||
|
public byte p2_byte;
|
||||||
[FieldOffset(2)]
|
[FieldOffset(2)]
|
||||||
public ushort p2;
|
public byte p3_byte;
|
||||||
|
[FieldOffset(3)]
|
||||||
|
public byte p4_byte;
|
||||||
|
|
||||||
|
[FieldOffset(0)]
|
||||||
|
public ushort p1_ushort;
|
||||||
|
[FieldOffset(2)]
|
||||||
|
public ushort p2_ushort;
|
||||||
[FieldOffset(4)]
|
[FieldOffset(4)]
|
||||||
public ushort p3;
|
public ushort p3_ushort;
|
||||||
[FieldOffset(6)]
|
[FieldOffset(6)]
|
||||||
public ushort p4;
|
public ushort p4_ushort;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||||||
-->
|
-->
|
||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<History>True|2024-09-13T05:39:28.9591993Z||;True|2024-09-12T17:48:43.1521740+08:00||;True|2024-09-12T17:43:57.0504432+08:00||;True|2024-09-12T17:19:48.6392091+08:00||;True|2024-09-12T13:38:45.0141937+08:00||;False|2024-09-12T13:37:57.6131232+08:00||;True|2024-06-28T16:25:59.3159172+08:00||;True|2024-06-28T15:30:49.8257235+08:00||;</History>
|
<History>True|2024-09-14T08:39:29.4677979Z||;True|2024-09-14T16:38:22.2398996+08:00||;True|2024-09-13T13:39:28.9591993+08:00||;True|2024-09-12T17:48:43.1521740+08:00||;True|2024-09-12T17:43:57.0504432+08:00||;True|2024-09-12T17:19:48.6392091+08:00||;True|2024-09-12T13:38:45.0141937+08:00||;False|2024-09-12T13:37:57.6131232+08:00||;True|2024-06-28T16:25:59.3159172+08:00||;True|2024-06-28T15:30:49.8257235+08:00||;</History>
|
||||||
<LastFailureDetails />
|
<LastFailureDetails />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
6
AxibugEmuOnline.Web/AxibugEmuOnline.Web.csproj.user
Normal file
6
AxibugEmuOnline.Web/AxibugEmuOnline.Web.csproj.user
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<NameOfLastUsedPublishProfile>G:\Sin365\AxibugEmuOnline\AxibugEmuOnline.Web\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||||
|
-->
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<DeleteExistingFiles>false</DeleteExistingFiles>
|
||||||
|
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||||
|
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||||
|
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||||
|
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||||
|
<PublishProvider>FileSystem</PublishProvider>
|
||||||
|
<PublishUrl>bin\Release\net8.0\publish\</PublishUrl>
|
||||||
|
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||||
|
<_TargetId>Folder</_TargetId>
|
||||||
|
<SiteUrlToLaunchAfterPublish />
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
<ProjectGuid>52a13383-be2d-4945-83b6-bbc54cf39f83</ProjectGuid>
|
||||||
|
<SelfContained>false</SelfContained>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||||
|
-->
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<_PublishTargetUrl>G:\Sin365\AxibugEmuOnline\AxibugEmuOnline.Web\bin\Release\net8.0\publish\</_PublishTargetUrl>
|
||||||
|
<History>True|2024-09-12T06:18:38.6992653Z||;True|2024-09-12T14:08:58.4526827+08:00||;True|2024-08-22T14:13:06.3067002+08:00||;True|2024-08-14T10:33:10.9180984+08:00||;True|2024-08-13T18:28:27.5050523+08:00||;True|2024-08-13T18:25:47.6591234+08:00||;True|2024-08-13T18:25:17.5344107+08:00||;True|2024-08-13T17:46:23.4523329+08:00||;</History>
|
||||||
|
<LastFailureDetails />
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
@ -3,7 +3,25 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.8.34511.84
|
VisualStudioVersion = 17.8.34511.84
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AxibugEmuOnline.Web", "AxibugEmuOnline.Web\AxibugEmuOnline.Web.csproj", "{52A13383-BE2D-4945-83B6-BBC54CF39F83}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AxibugEmuOnline.Server", "AxibugEmuOnline.Server\AxibugEmuOnline.Server.csproj", "{9F509DB4-CDB4-4CDB-9C10-805C5E644EEF}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{52A13383-BE2D-4945-83B6-BBC54CF39F83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{52A13383-BE2D-4945-83B6-BBC54CF39F83}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{52A13383-BE2D-4945-83B6-BBC54CF39F83}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{52A13383-BE2D-4945-83B6-BBC54CF39F83}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{9F509DB4-CDB4-4CDB-9C10-805C5E644EEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{9F509DB4-CDB4-4CDB-9C10-805C5E644EEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{9F509DB4-CDB4-4CDB-9C10-805C5E644EEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{9F509DB4-CDB4-4CDB-9C10-805C5E644EEF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
Loading…
Reference in New Issue
Block a user