public void SendPacket(AbstractPacketOut packet) { try { if (Alive) { byte id = (byte)packet.ID; byte[] data = packet.Data; byte[] fdata = new byte[data.Length + 5]; Utilities.IntToBytes(data.Length).CopyTo(fdata, 0); fdata[4] = id; data.CopyTo(fdata, 5); PrimarySocket.Send(fdata); if (PE != null) { PE.UsagesTotal[(int)packet.UsageType] += fdata.Length; } } } catch (Exception ex) { SysConsole.Output(OutputType.WARNING, "Disconnected " + PE + " -> " + ex.GetType().Name + ": " + ex.Message); if (TheServer.CVars.s_debug.ValueB) { SysConsole.Output(ex); } PE.Kick("Internal exception."); } }
public void SendToVisible(Location pos, AbstractPacketOut packet) { Vector3i cpos = ChunkLocFor(pos); foreach (PlayerEntity pe in Players) { if (pe.CanSeeChunk(cpos)) { pe.Network.SendPacket(packet); } } }
public void SendToAll(AbstractPacketOut packet) { for (int i = 0; i < Players.Count; i++) { Players[i].Network.SendPacket(packet); } }
public void ChunkSendToAll(AbstractPacketOut packet, Vector3i cpos) { for (int i = 0; i < Players.Count; i++) { if (Players[i].CanSeeChunk(cpos)) { Players[i].Network.SendPacket(packet); } } }