public static void JoinGame(Blaze.Packet p, PlayerInfo pi, NetworkStream ns) { PlayerInfo srv = null; foreach (PlayerInfo info in BlazeServer.allClients) { if (info.isServer) { srv = info; break; } } if (srv == null) { BlazeServer.Log("[CLNT] #" + pi.userId + " : cant find game to join!", System.Drawing.Color.Red); return; } pi.game = srv.game; pi.slot = srv.game.getNextSlot(); BlazeServer.Log("[CLNT] #" + pi.userId + " : assigned Slot Id " + pi.slot, System.Drawing.Color.Blue); if (pi.slot == 255) { BlazeServer.Log("[CLNT] #" + pi.userId + " : server full!", System.Drawing.Color.Red); return; } srv.game.setNextSlot((int)pi.userId); srv.game.players[pi.slot] = pi; List <Blaze.Tdf> result = new List <Blaze.Tdf>(); result.Add(Blaze.TdfInteger.Create("GID\0", srv.game.id)); result.Add(Blaze.TdfInteger.Create("JGS\0", 0)); byte[] buff = Blaze.CreatePacket(p.Component, p.Command, 0, 0x1000, p.ID, result); ns.Write(buff, 0, buff.Length); ns.Flush(); pi.stat = 2; AsyncUserSessions.NotifyUserAdded(pi, p, pi, ns); AsyncUserSessions.NotifyUserStatus(pi, p, pi, ns); AsyncGameManager.NotifyClientGameSetup(pi, p, pi, srv, ns); AsyncUserSessions.NotifyUserAdded(srv, p, pi, srv.ns); AsyncUserSessions.NotifyUserStatus(srv, p, pi, srv.ns); AsyncUserSessions.UserSessionExtendedDataUpdateNotification(srv, p, pi, srv.ns); AsyncGameManager.NotifyPlayerJoining(srv, p, pi, srv.ns); }