|
@@ -1,5 +1,6 @@
|
|
|
using System;
|
|
|
using System.Drawing;
|
|
|
+using System.Linq;
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
namespace ET.Server
|
|
@@ -70,19 +71,20 @@ namespace ET.Server
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 加入玩家
|
|
|
- room.Add(player);
|
|
|
+ // 是否已经在房间
|
|
|
+ if (!room.GetAllPlayers().ContainsKey(player.Id))
|
|
|
+ {
|
|
|
+ // 加入玩家
|
|
|
+ room.Add(player);
|
|
|
|
|
|
- // 绑定玩家房间
|
|
|
- player.RoomId = room.RoomId;
|
|
|
+ // 绑定玩家房间
|
|
|
+ player.RoomId = room.RoomId;
|
|
|
+ }
|
|
|
|
|
|
// 广播玩家加入房间
|
|
|
- foreach (Player p in room.GetAllPlayers().Values)
|
|
|
+ foreach (Player p in room.GetAllPlayers().Values.Where(p => p != null))
|
|
|
{
|
|
|
- if (p != null)
|
|
|
- {
|
|
|
- MessageHelper.SendToClient(p, new G2C_JoinRoomPush(){info = ProtoHelper.RoomToProto(room, p, null)});
|
|
|
- }
|
|
|
+ MessageHelper.SendToClient(p, new G2C_JoinRoomPush(){info = ProtoHelper.RoomToProto(room, p, null)});
|
|
|
}
|
|
|
|
|
|
reply();
|