public override bool SendMsg(MsgPacker msg, MsgFlags flags, int clientId) { if (msg == null) { return(false); } var packet = new Chunk() { ClientId = clientId, DataSize = msg.Size(), Data = msg.Data(), Flags = SendFlags.None, }; if (flags.HasFlag(MsgFlags.Vital)) { packet.Flags |= SendFlags.Vital; } if (flags.HasFlag(MsgFlags.Flush)) { packet.Flags |= SendFlags.Flush; } if (!flags.HasFlag(MsgFlags.NoRecord)) { // TODO demo record } if (flags.HasFlag(MsgFlags.NoSend)) { return(true); } if (clientId == -1) { for (var i = 0; i < Clients.Length; i++) { if (Clients[i].State == ServerClientState.InGame && Clients[i].Quitting == false) { packet.ClientId = i; NetworkServer.Send(packet); } } } else { NetworkServer.Send(packet); } return(true); }
public override bool SendMsgEx(MsgPacker msg, MsgFlags flags, int clientId, bool system) { if (msg == null) { return(false); } var packet = new NetworkChunk() { ClientId = clientId, DataSize = msg.Size(), Data = msg.Data(), }; packet.Data[0] <<= 1; if (system) { packet.Data[0] |= 1; } if (flags.HasFlag(MsgFlags.VITAL)) { packet.Flags |= SendFlags.VITAL; } if (flags.HasFlag(MsgFlags.FLUSH)) { packet.Flags |= SendFlags.FLUSH; } if (!flags.HasFlag(MsgFlags.NOSEND)) { if (clientId == -1) { for (var i = 0; i < Clients.Length; i++) { if (Clients[i].State != ServerClientState.IN_GAME) { continue; } packet.ClientId = i; NetworkServer.Send(packet); } } else { NetworkServer.Send(packet); } } return(true); }