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) { Logger.Error("[CLNT] #" + pi.userId + " : cant find game to join!"); return; } pi.game = srv.game; pi.slot = srv.game.getNextSlot(); BlazeServer.Log("[CLNT] #" + pi.userId + " : assigned Slot Id " + pi.slot); if (pi.slot == 255) { Logger.Warn("[CLNT] #" + pi.userId + " : server full!"); 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); }
public static void UpdateNetworkInfo(Blaze.Packet p, PlayerInfo pi, NetworkStream ns) { List <Blaze.Tdf> input = Blaze.ReadPacketContent(p); Blaze.TdfUnion addr = (Blaze.TdfUnion)input[0]; Blaze.TdfStruct valu = (Blaze.TdfStruct)addr.UnionContent; Blaze.TdfStruct exip = (Blaze.TdfStruct)valu.Values[0]; Blaze.TdfStruct inip = (Blaze.TdfStruct)valu.Values[1]; pi.inIp = ((Blaze.TdfInteger)inip.Values[0]).Value; pi.exIp = ((Blaze.TdfInteger)exip.Values[0]).Value; pi.exPort = pi.inPort = (uint)((Blaze.TdfInteger)inip.Values[1]).Value; Blaze.TdfStruct nqos = (Blaze.TdfStruct)input[2]; pi.nat = ((Blaze.TdfInteger)nqos.Values[1]).Value; byte[] buff = Blaze.CreatePacket(p.Component, p.Command, 0, 0x1000, p.ID, new List <Blaze.Tdf>()); ns.Write(buff, 0, buff.Length); ns.Flush(); AsyncUserSessions.UserSessionExtendedDataUpdateNotification(pi, p, pi, ns); }
public static void UpdateMeshConnection(Blaze.Packet p, PlayerInfo pi, NetworkStream ns) { List <Blaze.Tdf> input = Blaze.ReadPacketContent(p); List <Blaze.TdfStruct> entries = (List <Blaze.TdfStruct>)((Blaze.TdfList)input[1]).List; Blaze.TdfInteger pid = (Blaze.TdfInteger)entries[0].Values[1]; Blaze.TdfInteger stat = (Blaze.TdfInteger)entries[0].Values[2]; byte[] buff = Blaze.CreatePacket(p.Component, p.Command, 0, 0x1000, p.ID, new List <Blaze.Tdf>()); ns.Write(buff, 0, buff.Length); ns.Flush(); PlayerInfo target = null; foreach (PlayerInfo info in BlazeServer.allClients) { if (info.userId == pid.Value) { target = info; break; } } if (target != null) { if (stat.Value == 2) { if (pi.isServer) { AsyncUserSessions.UserSessionExtendedDataUpdateNotification(pi, p, target, ns); AsyncGameManager.NotifyGamePlayerStateChange(pi, p, target, ns, 4); AsyncGameManager.NotifyPlayerJoinCompleted(pi, p, target, ns); } else { AsyncGameManager.NotifyGamePlayerStateChange(pi, p, pi, ns, 4); AsyncGameManager.NotifyPlayerJoinCompleted(pi, p, pi, ns); } } else { AsyncUserSessions.NotifyUserRemoved(pi, p, pid.Value, ns); } } }