public static void HandlePrivate(Player p, byte[] Data) { using (CustomReader r = new CustomReader(Data)) { if (Data[0] == 0) { r.BaseStream.Position += 2; } else { r.ReadString(); } string Content = r.ReadString(); string Target = r.ReadString(); // TODO /* if (Target == Bot.Name) * { * Target = p.Username; * return; * } */ Global.FindPlayerByName(Target) ?.AddQueue(Packets.Packets.IrcMessage(Content, p.Username, Target, p.Id)); } }
public static void Handle(Player p, byte[] Data) { using (CustomReader r = new CustomReader(Data)) { if (Data[0] == 0) { r.BaseStream.Position += 2; } else { r.ReadString(); } string Content = r.ReadString(); string Target = r.ReadString(); /*if (Content.StartsWith(CommandManager.Prefix)) * { * if (CommandManager.HandleCommands(p, msg.Content, msg.Target)) return; * }*/ if (Target == "#spectator") { if (p.Spectating == null && p.Spectators.Count > 0) { p.MessageSpectators(p, Content); } else if (p.Spectating != null) { p.Spectating.MessageSpectators(p, Content); } return; } if (Target == "#multiplayer") { if (p.Match == null) { return; } if (!p.Match.Players.Contains(p)) { return; } Packet pack = Packets.Packets.IrcMessage(Content, p.Username, Target, p.Id); for (int i = 0; i < p.Match.Players.Count; i++) { if (p.Match.Players[i] != p) { p.Match.Players[i].AddQueue(pack); } } return; } Global.FindChannel(Target).Message(p, Content); } }
public static void Handle(Player p, byte[] Data) { if (p.Match.Host != p.Id) { return; } using (CustomReader r = new CustomReader(Data)) { (r.BaseStream).Position = 8; r.ReadString(); string newPassword = r.ReadString(); p.Match.Broadcast(Packets.Packets.SingleStringPacket(91, newPassword)); } }
public static void Handle(Player p, byte[] Data) { using (CustomReader r = new CustomReader(Data)) { p.Action = (ActionType)r.ReadByte(); p.ActionText = r.ReadString(); p.ActionMd5 = r.ReadString(); p.ActionMods = r.ReadInt32(); p.SetRelax((p.ActionMods & 128) != 0); p.Gamemode = r.ReadByte(); p.ActionBeatmap = r.ReadInt32(); if (p.Action == ActionType.Playing && p.ActionMods != 0) { p.ActionText += " +" + Tools.ModConvert.ToString(p.ActionMods); } Player.Broadcast(Packets.Packets.StatsPacket(p)); } }
public void ReadMatch(CustomReader r) { if (!(r.BaseStream is MemoryStream)) { return; // We do not support Reading here } (r.BaseStream).Position += 2; MatchRunning = r.ReadBoolean(); byte oldMatchType = MatchType; MatchType = r.ReadByte(); if (oldMatchType != MatchType) { if (MatchType == 2 || MatchType == 3) { for (int i = 0; i < Slots.Length; i++) { if (Slots[i].User != null) { Slots[i].Team = (byte)(i % 2 == 0 ? 1 : 2); } } } else { for (int i = 0; i < Slots.Length; i++) { if (Slots[i].User != null) { Slots[i].Team = 0; } } } } Mods = r.ReadInt32(); Name = r.ReadString(); Password = r.ReadString(); BeatmapName = r.ReadString(); BeatmapId = r.ReadInt32(); BeatmapMd5 = r.ReadString(); for (int i = 0; i < 16; i++) { Slots[i].Status = r.ReadByte(); } for (int i = 0; i < 16; i++) { Slots[i].Team = r.ReadByte(); } for (int i = 0; i < 16; i++) { if ((Slots[i].Status & 124) != 0) { Slots[i].User = Global.FindPlayerById(r.ReadInt32()); } } (r.BaseStream).Position += 4; Gamemode = r.ReadByte(); ScoreType = r.ReadByte(); TeamType = r.ReadByte(); bool freeMod = r.ReadBoolean(); if (freeMod != FreeMod) //freemod changed { if (freeMod) { for (int i = 0; i < 16; i++) { if (Slots[i].User != null) { Slots[i].Mods = Mods; } } Mods = 0; } else { Mods = 0; for (int i = 0; i < 16; i++) { Slots[i].Mods = 0; } } } FreeMod = freeMod; Seed = r.ReadInt32(); }