Ejemplo n.º 1
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();
        }