示例#1
0
        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));
            }
        }
示例#2
0
        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();
        }