public static void RemovePlayer(Blaze.Packet p, PlayerInfo pi, NetworkStream ns) { List <Blaze.Tdf> input = Blaze.ReadPacketContent(p); Blaze.TdfInteger CNTX = (Blaze.TdfInteger)input[1]; Blaze.TdfInteger PID = (Blaze.TdfInteger)input[3]; Blaze.TdfInteger REAS = (Blaze.TdfInteger)input[4]; pi.game.removePlayer((int)PID.Value); GC.Collect(); byte[] buff = Blaze.CreatePacket(p.Component, p.Command, 0, 0x1000, p.ID, new List <Blaze.Tdf>()); ns.Write(buff, 0, buff.Length); ns.Flush(); foreach (PlayerInfo player in BlazeServer.allClients) { if (player != null && player.userId == PID.Value) { player.cntx = CNTX.Value; } } foreach (PlayerInfo player in pi.game.players) { if (player != null && player.userId != PID.Value) { try { AsyncGameManager.NotifyPlayerRemoved(player, p, player, player.ns, PID.Value, CNTX.Value, REAS.Value); } catch { BlazeServer.Log("[CLNT] #" + pi.userId + " : 'RemovePlayer' peer crashed!", System.Drawing.Color.Red); } } } }
public static void SetGameAttributes(Blaze.Packet p, PlayerInfo pi, NetworkStream ns) { List <Blaze.Tdf> input = Blaze.ReadPacketContent(p); pi.game.ATTR = (Blaze.TdfDoubleList)input[0]; List <Blaze.Tdf> result = new List <Blaze.Tdf>(); byte[] buff = Blaze.CreatePacket(p.Component, p.Command, 0, 0x1000, p.ID, result); ns.Write(buff, 0, buff.Length); ns.Flush(); foreach (PlayerInfo peer in pi.game.players) { if (peer != null) { try { AsyncGameManager.NotifyGameSettingsChange(peer, p, pi, peer.ns); } catch { pi.game.removePlayer((int)peer.userId); BlazeServer.Log("[CLNT] #" + pi.userId + " : 'SetGameAttributes' peer crashed!", System.Drawing.Color.Red); } } } }
public static void FinalizeGameCreation(Blaze.Packet p, PlayerInfo pi, NetworkStream ns) { List <Blaze.Tdf> result = new List <Blaze.Tdf>(); byte[] buff = Blaze.CreatePacket(p.Component, p.Command, 0, 0x1000, p.ID, result); ns.Write(buff, 0, buff.Length); ns.Flush(); if (pi.isServer) { AsyncGameManager.NotifyPlatformHostInitialized(pi, p, pi, ns); } }
public static void ReplayGame(Blaze.Packet p, PlayerInfo pi, NetworkStream ns) { byte[] buff = Blaze.CreatePacket(p.Component, p.Command, 0, 0x1000, p.ID, new List <Blaze.Tdf>()); ns.Write(buff, 0, buff.Length); ns.Flush(); pi.game.GSTA = 130; pi.timeout.Restart(); foreach (PlayerInfo peer in pi.game.players) { if (peer != null) { AsyncGameManager.NotifyGameStateChange(peer, p, pi, peer.ns); } } }
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); }
public static void AdvanceGameState(Blaze.Packet p, PlayerInfo pi, NetworkStream ns) { List <Blaze.Tdf> input = Blaze.ReadPacketContent(p); pi.game.GSTA = (uint)((Blaze.TdfInteger)input[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(); foreach (PlayerInfo peer in pi.game.players) { if (peer != null) { AsyncGameManager.NotifyGameStateChange(peer, p, pi, peer.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); } } }
public static void CreateGame(Blaze.Packet p, PlayerInfo pi, NetworkStream ns) { pi.stat = 4; pi.slot = pi.game.getNextSlot(); pi.game.setNextSlot((int)pi.userId); pi.game.id = 1; pi.game.isRunning = true; pi.game.GSTA = 7; pi.game.players[0] = pi; List <Blaze.Tdf> result = new List <Blaze.Tdf>(); result.Add(Blaze.TdfInteger.Create("GID\0", pi.game.id)); result.Add(Blaze.TdfInteger.Create("GSTA", pi.game.GSTA)); byte[] buff = Blaze.CreatePacket(p.Component, p.Command, 0, 0x1000, p.ID, result); ns.Write(buff, 0, buff.Length); ns.Flush(); AsyncGameManager.NotifyGameStateChange(pi, p, pi, ns); AsyncGameManager.NotifyServerGameSetup(pi, p, pi, ns); }