This commit is contained in:
ALIENJACK\alien 2024-09-18 10:02:35 +08:00
commit 181ce9a420
14 changed files with 117 additions and 47 deletions

View File

@ -4,7 +4,6 @@ namespace AxiReplay
{
public class NetReplay
{
int MaxInFrame = 0;
public int mCurrPlayFrame = -1;
Queue<ReplayStep> mQueueReplay;
ReplayStep mNextReplay;
@ -13,20 +12,28 @@ namespace AxiReplay
/// <summary>
/// 服务器远端当前帧
/// </summary>
public int remoteFrameIdx { get; private set; }
public int mRemoteFrameIdx { get; private set; }
/// <summary>
/// 当前帧和服务器帧相差数量
/// </summary>
public int remoteFrameDiff => remoteFrameIdx - mCurrPlayFrame;
public int remoteFrameDiff => mRemoteFrameIdx - mCurrPlayFrame;
public NetReplay()
{
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)
{
mQueueReplay.Enqueue(inputData);
MaxInFrame = inputData.FrameStartID;
remoteFrameIdx = ServerFrameIdx;
mRemoteFrameIdx = inputData.FrameStartID;
}
public bool NextFrame(out ReplayStep data, out int FrameDiff)
{
@ -55,17 +62,17 @@ namespace AxiReplay
else
{
data = mCurrReplay;
FrameDiff = MaxInFrame - mCurrPlayFrame;
FrameDiff = mRemoteFrameIdx - mCurrPlayFrame;
}
return Changed;
}
void UpdateNextFrame(int targetFrame,out int FrameDiff)
{
FrameDiff = MaxInFrame - targetFrame;
FrameDiff = mRemoteFrameIdx - targetFrame;
//如果已经超过
while (targetFrame > mNextReplay.FrameStartID)
{
if (mNextReplay.FrameStartID >= MaxInFrame)
if (mNextReplay.FrameStartID >= mRemoteFrameIdx)
{
//TODO
//bEnd = true;

View File

@ -32,10 +32,5 @@
/// 服务器等待Step更新
/// </summary>
OnRoomWaitStepChange,
/// <summary>
/// 要求加载即时存档
/// </summary>
OnRoomNeedLoadRawData,
}
}

View File

@ -3,9 +3,6 @@ using AxibugEmuOnline.Client.Common;
using AxibugEmuOnline.Client.Network;
using AxibugProtobuf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
namespace AxibugEmuOnline.Client.Manager
{
@ -40,6 +37,9 @@ namespace AxibugEmuOnline.Client.Manager
{
App.log.Info("登录成功");
App.user.InitMainUserData(App.user.userdata.Account, msg.UID);
App.log.Info("获取服务器列表");
App.roomMgr.SendGetRoomList();
}
else
{

View File

@ -96,10 +96,11 @@ namespace AxibugEmuOnline.Client.Manager
public void InitRePlay()
{
netReplay = new NetReplay();
netReplay.ResetData();
}
public void ReleaseRePlay()
{
netReplay.ResetData();
}
#endregion
@ -113,6 +114,10 @@ namespace AxibugEmuOnline.Client.Manager
return 0;
if (mineRoomMiniInfo.Player2UID == App.user.userdata.UID)
return 1;
if (mineRoomMiniInfo.Player3UID == App.user.userdata.UID)
return 2;
if (mineRoomMiniInfo.Player4UID == App.user.userdata.UID)
return 3;
return -1;
}
@ -304,7 +309,7 @@ namespace AxibugEmuOnline.Client.Manager
/// 上报即时存档
/// </summary>
/// <param name="RoomID"></param>
public void SendLeavnRoom(byte[] RawData)
public void SendHostRaw(byte[] RawData)
{
//压缩
byte[] compressRawData = Helper.CompressByteArray(RawData);
@ -357,7 +362,6 @@ namespace AxibugEmuOnline.Client.Manager
App.network.SendToServer((int)CommandID.CmdRoomSingelPlayerInput, ProtoBufHelper.Serizlize(_Protobuf_Room_SinglePlayerInputData));
}
void RecvHostSyn_RoomFrameAllInputData(byte[] reqData)
{
Protobuf_Room_Syn_RoomFrameAllInputData msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_Syn_RoomFrameAllInputData>(reqData);
@ -379,10 +383,5 @@ namespace AxibugEmuOnline.Client.Manager
//解压
byte[] data = Helper.DecompressByteArray(msg.RawBitmap.ToArray());
}
internal void SendHostRaw(byte[] stateRaw)
{
throw new NotImplementedException();
}
}
}

View File

@ -16,7 +16,6 @@ namespace AxibugEmuOnline.Server.Manager
public DateTime LogOutDT { get; set; }
public DateTime LogInDT { get; set; }
public UserRoomState RoomState { get; set; } = new UserRoomState();
public TimeSpan LastStartPingTime { get; set; }
public int LastPingSeed { get; set; }
public double AveNetDelay { get; set; }
@ -34,13 +33,11 @@ namespace AxibugEmuOnline.Server.Manager
{
ClearRoomData();
}
public void SetRoomData(int roomID, int playerIdx)
{
RoomID = roomID;
PlayerIdx = playerIdx;
}
public void ClearRoomData()
{
RoomID = -1;

View File

@ -270,7 +270,12 @@ namespace AxibugEmuOnline.Server
Data_RoomData room = GetRoomData(_c.RoomState.RoomID);
if (room == null)
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_byte);
}
public void OnCmdScreen(Socket sk, byte[] reqData)
@ -540,14 +545,14 @@ namespace AxibugEmuOnline.Server
return list;
}
public void SetPlayerInput(int PlayerIdx, long mFrameID, ushort input)
public void SetPlayerInput(int PlayerIdx, long mFrameID, byte input)
{
switch (PlayerIdx)
{
case 0: mCurrInputData.p1 = input; break;
case 1: mCurrInputData.p2 = input; break;
case 2: mCurrInputData.p3 = input; break;
case 3: mCurrInputData.p4 = input; break;
case 0: mCurrInputData.p1_byte = input; break;
case 1: mCurrInputData.p2_byte = input; break;
case 2: mCurrInputData.p3_byte = input; break;
case 3: mCurrInputData.p4_byte = input; break;
}
}
@ -555,10 +560,10 @@ namespace AxibugEmuOnline.Server
{
switch (PlayerIdx)
{
case 0: mCurrInputData.p1 = 0; break;
case 1: mCurrInputData.p2 = 0; break;
case 2: mCurrInputData.p3 = 0; break;
case 3: mCurrInputData.p4 = 0; break;
case 0: mCurrInputData.p1_byte = 0; break;
case 1: mCurrInputData.p2_byte = 0; break;
case 2: mCurrInputData.p3_byte = 0; break;
case 3: mCurrInputData.p4_byte = 0; break;
}
}
@ -753,18 +758,28 @@ namespace AxibugEmuOnline.Server
}
}
[StructLayout(LayoutKind.Explicit)]
[StructLayout(LayoutKind.Explicit, Size = 8)]
public struct ServerInputSnapShot
{
[FieldOffset(0)]
public UInt64 all;
[FieldOffset(0)]
public ushort p1;
public byte p1_byte;
[FieldOffset(1)]
public byte p2_byte;
[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)]
public ushort p3;
public ushort p3_ushort;
[FieldOffset(6)]
public ushort p4;
public ushort p4_ushort;
}
}

View File

@ -29,10 +29,10 @@ namespace AxibugEmuOnline.Server
AppSrv.g_Log.Info($"HostUID:{room.HostUID}");
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}");
AppSrv.g_Log.Info($"input p2:{room.mCurrInputData.p2}");
AppSrv.g_Log.Info($"input p3:{room.mCurrInputData.p3}");
AppSrv.g_Log.Info($"input p4:{room.mCurrInputData.p4}");
AppSrv.g_Log.Info($"input p1:{room.mCurrInputData.p1_byte}");
AppSrv.g_Log.Info($"input p2:{room.mCurrInputData.p2_byte}");
AppSrv.g_Log.Info($"input p3:{room.mCurrInputData.p3_byte}");
AppSrv.g_Log.Info($"input p4:{room.mCurrInputData.p4_byte}");
AppSrv.g_Log.Info($"GetPlayerCount:{room.GetPlayerCount()}");
for (int i = 0; i < 4; i++)
{

View File

@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<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 />
</PropertyGroup>
</Project>

View 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>

View File

@ -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>

View File

@ -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>

View File

@ -3,7 +3,25 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34511.84
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
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
HideSolutionNode = FALSE
EndGlobalSection