服务器重构玩家位置管理,使其可以一对多手柄位联机,以及切换位置等协议

This commit is contained in:
sin365 2024-12-20 01:04:40 +08:00
parent 417390227c
commit abddf3c0b5
4 changed files with 1214 additions and 1038 deletions

View File

@ -34,20 +34,17 @@ namespace AxibugEmuOnline.Server.Manager
public class UserRoomState public class UserRoomState
{ {
public int RoomID { get; private set; } public int RoomID { get; private set; }
public int PlayerIdx { get; private set; }
public UserRoomState() public UserRoomState()
{ {
ClearRoomData(); ClearRoomData();
} }
public void SetRoomData(int roomID, int playerIdx) public void SetRoomData(int roomID)
{ {
RoomID = roomID; RoomID = roomID;
PlayerIdx = playerIdx;
} }
public void ClearRoomData() public void ClearRoomData()
{ {
RoomID = -1; RoomID = -1;
PlayerIdx = -1;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -38,15 +38,17 @@ namespace AxibugEmuOnline.Server
AppSrv.g_Log.Info($"input p3:{room.mCurrInputData.p3_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($"input p4:{room.mCurrInputData.p4_byte}");
AppSrv.g_Log.Info($"GetPlayerCount:{room.GetPlayerCount()}"); AppSrv.g_Log.Info($"GetPlayerCount:{room.GetPlayerCount()}");
for (int i = 0; i < 4; i++) for (int i = 0; i < room.PlayerSlot.Length; i++)
{ {
AppSrv.g_Log.Info($" P{i}"); AppSrv.g_Log.Info($" P{i}");
if (room.GetPlayerClientByIdx(i, out ClientInfo _c))
if (AppSrv.g_ClientMgr.GetClientByUID(room.PlayerSlot[i].UID, out ClientInfo _c))
{ {
AppSrv.g_Log.Info($" UID->{_c.UID}"); AppSrv.g_Log.Info($" UID->{room.PlayerSlot[i].UID}");
AppSrv.g_Log.Info($" NickName->{_c.NickName}"); AppSrv.g_Log.Info($" NickName->{_c.NickName}");
AppSrv.g_Log.Info($" AveNetDelay->{_c.AveNetDelay}"); AppSrv.g_Log.Info($" AveNetDelay->{_c.AveNetDelay}");
} AppSrv.g_Log.Info($" LocalJoyIdx->{room.PlayerSlot[i].LocalJoyIdx}");
}
else else
{ {
AppSrv.g_Log.Info($" None"); AppSrv.g_Log.Info($" None");

View File

@ -33,6 +33,7 @@ enum CommandID
CMD_Room_Join = 5105; // Protobuf_Room_Join | Protobuf_Room_Join_RESP //Join之前按照房间信息Rom CMD_Room_Join = 5105; // Protobuf_Room_Join | Protobuf_Room_Join_RESP //Join之前按照房间信息Rom
CMD_Room_Leave = 5106; // Protobuf_Room_Leave | Protobuf_Room_Leave_RESP CMD_Room_Leave = 5106; // Protobuf_Room_Leave | Protobuf_Room_Leave_RESP
CMD_Room_MyRoom_State_Changed = 5110; // Protobuf_Room_MyRoom_State_Change CMD_Room_MyRoom_State_Changed = 5110; // Protobuf_Room_MyRoom_State_Change
CMD_Room_ChangePlayerWithJoy = 5130; // Protobuf_Room_Change_PlaySlotWithJoy | Protobuf_Room_Change_PlaySlotWithJoy_RESP
//5201 ~ 5204 ~ 5208 //5201 ~ 5204 ~ 5208
// //
@ -257,15 +258,15 @@ message Protobuf_Room_MiniInfo
int64 HostPlayerUID = 4;//ID int64 HostPlayerUID = 4;//ID
RoomGameState GameState = 5;// RoomGameState GameState = 5;//
int32 ObsUserCount = 6;// int32 ObsUserCount = 6;//
int64 Player1_UID = 7;//1 UID int64 ScreenProviderUID = 7;//
string Player1_NickName = 8;//1 repeated Protobuf_Room_GamePlaySlot GamePlaySlotList = 8;//P1~P4 4
int64 Player2_UID = 9;//2 UID }
string Player2_NickName = 10;//2
int64 Player3_UID = 11;//3 UID message Protobuf_Room_GamePlaySlot
string Player3_NickName = 12;//3 {
int64 Player4_UID = 13;//4 UID int64 Player_UID = 1;// UID
string Player4_NickName = 14;//4 string Player_NickName = 2;//
int64 ScreenProviderUID = 15;// int32 PlayerLocalJoyIdx = 3;//JoyIdx
} }
message Protobuf_Room_Update_RESP message Protobuf_Room_Update_RESP
@ -299,7 +300,8 @@ message Protobuf_Room_Create
{ {
int32 GameRomID = 1; int32 GameRomID = 1;
string GameRomHash = 2; string GameRomHash = 2;
int32 JoinPlayerIdx = 3;//P1~P4[0~3] int32 PlayerSlotIdx = 3;//P1~P4编号
int32 PlayerLocalJoyIdx = 4;//Joy编号
} }
message Protobuf_Room_Create_RESP message Protobuf_Room_Create_RESP
@ -310,7 +312,8 @@ message Protobuf_Room_Create_RESP
message Protobuf_Room_Join message Protobuf_Room_Join
{ {
int32 RoomID = 1;//ID int32 RoomID = 1;//ID
int32 PlayerNum = 2;// [0]1 [1]2 int32 PlayerSlotIdx = 2;//P1~P4编号
int32 PlayerLocalJoyIdx = 3;//Joy编号
} }
message Protobuf_Room_Join_RESP message Protobuf_Room_Join_RESP
@ -333,6 +336,21 @@ message Protobuf_Room_MyRoom_State_Change
Protobuf_Room_MiniInfo RoomMiniInfo = 1;// Protobuf_Room_MiniInfo RoomMiniInfo = 1;//
} }
message Protobuf_Room_Change_PlaySlotWithJoy
{
repeated Protobuf_PlaySlotIdxWithJoyIdx SlotWithJoy = 1;//P1~P4编号
}
message Protobuf_PlaySlotIdxWithJoyIdx
{
int32 PlayerSlotIdx = 1;//P1~P4编号
int32 PlayerLocalJoyIdx = 2;//Joy编号
}
message Protobuf_Room_Change_PlaySlotWithJoy_RESP
{
}
message Protobuf_Room_WaitStep_RESP message Protobuf_Room_WaitStep_RESP
{ {
int32 WaitStep = 1;// [0] [1] [2] int32 WaitStep = 1;// [0] [1] [2]
@ -352,6 +370,10 @@ message Protobuf_Room_HostPlayer_UpdateStateRaw_RESP
message Protobuf_Room_Player_Ready message Protobuf_Room_Player_Ready
{ {
float PushFrameNeedTimeUs = 1;//push帧所需平均时间
float LoadStateNeedTimeUs = 2;//
float VideoFrameShowNeedTimeUs = 3;//
float AudioFramePlayNeedTimeUs = 4;//
} }
message Protobuf_Room_Get_Screen message Protobuf_Room_Get_Screen