完善 服务器 玩家更换slotidx

This commit is contained in:
sin365 2024-12-25 20:25:55 +08:00
parent 3bbc24fc91
commit 51a4419d25

View File

@ -373,10 +373,12 @@ namespace AxibugEmuOnline.Server
ErrorCode errcode = ErrorCode.ErrorOk;
Data_RoomData room = GetRoomData(_c.RoomState.RoomID);
if (room == null)
errcode = ErrorCode.ErrorRoomNotFound;
if (errcode == ErrorCode.ErrorOk)
{
errcode = ErrorCode.ErrorRoomNotFound;
AppSrv.g_ClientMgr.ClientSend(_c, (int)CommandID.CmdRoomChangePlayerWithJoy, (int)errcode, ProtoBufHelper.Serizlize(resp));
return;
}
Dictionary<uint, uint> newSlotIdx2JoyIdx = new Dictionary<uint, uint>();
foreach (var slotinfo in msg.SlotWithJoy)
{
@ -384,16 +386,20 @@ namespace AxibugEmuOnline.Server
if (room.GetPlayerUIDByIdx((uint)slotinfo.PlayerSlotIdx, out long UID))
{
//且人不是自己,则不允许换位
if(UID != _c.UID)
errcode = ErrorCode.ErrorRoomSlotAlreadlyHadPlayer; break;
if (UID != _c.UID)
{
errcode = ErrorCode.ErrorRoomSlotAlreadlyHadPlayer;
AppSrv.g_ClientMgr.ClientSend(_c, (int)CommandID.CmdRoomChangePlayerWithJoy, (int)errcode, ProtoBufHelper.Serizlize(resp));
return;
}
}
newSlotIdx2JoyIdx[(uint)slotinfo.PlayerSlotIdx] = (uint)slotinfo.PlayerLocalJoyIdx;
}
room.SetPlayerSlotData(_c, ref newSlotIdx2JoyIdx);
room.SetPlayerSlotData(_c,ref newSlotIdx2JoyIdx);
}
AppSrv.g_ClientMgr.ClientSend(_c, (int)CommandID.CmdRoomMyRoomStateChanged, (int)errcode, ProtoBufHelper.Serizlize(resp));
AppSrv.g_ClientMgr.ClientSend(_c, (int)CommandID.CmdRoomChangePlayerWithJoy, (int)errcode, ProtoBufHelper.Serizlize(resp));
Protobuf_Room_MyRoom_State_Change(room.RoomID);
}
public void OnHostPlayerUpdateStateRaw(Socket sk, byte[] reqData)