public void SendCommand(CommandType cmd, int factionId, int mapId, byte[] data, ServerPlayer sourcePlayer = null) { if (sourcePlayer != null && cmd == CommandType.Sync) { int syncId = BitConverter.ToInt32(data, 0); if (!MpVersion.IsDebug && debugOnlySyncCmds.Contains(syncId)) { return; } } byte[] toSave = new ScheduledCommand(cmd, gameTimer, factionId, mapId, data).Serialize(); // todo cull target players if not global mapCmds.GetOrAddNew(mapId).Add(toSave); tmpMapCmds?.GetOrAddNew(mapId).Add(toSave); byte[] toSend = toSave.Append(new byte[] { 0 }); byte[] toSendSource = toSave.Append(new byte[] { 1 }); foreach (var player in PlayingPlayers) { player.conn.Send( Packets.Server_Command, sourcePlayer == player ? toSendSource : toSend ); } }
public void SendCommand(CommandType cmd, int factionId, int mapId, byte[] data, ServerPlayer sourcePlayer = null) { if (sourcePlayer != null) { bool debugCmd = cmd == CommandType.DebugTools || cmd == CommandType.Sync && debugOnlySyncCmds.Contains(BitConverter.ToInt32(data, 0)); if (!debugMode && debugCmd) { return; } bool hostOnly = cmd == CommandType.Sync && hostOnlySyncCmds.Contains(BitConverter.ToInt32(data, 0)); if (!sourcePlayer.IsHost && hostOnly) { return; } } byte[] toSave = new ScheduledCommand(cmd, gameTimer, factionId, mapId, data).Serialize(); // todo cull target players if not global mapCmds.GetOrAddNew(mapId).Add(toSave); tmpMapCmds?.GetOrAddNew(mapId).Add(toSave); byte[] toSend = toSave.Append(new byte[] { 0 }); byte[] toSendSource = toSave.Append(new byte[] { 1 }); foreach (var player in PlayingPlayers) { player.conn.Send( Packets.Server_Command, sourcePlayer == player ? toSendSource : toSend ); } cmdId++; }