Пример #1
0
        public CharacterInfo(BinaryReader reader)
        {
            Index = reader.ReadInt32();
            Name  = reader.ReadString();

            if (Envir.LoadVersion < 62)
            {
                Level = (ushort)reader.ReadByte();
            }
            else
            {
                Level = reader.ReadUInt16();
            }

            Class  = (MirClass)reader.ReadByte();
            Gender = (MirGender)reader.ReadByte();
            Hair   = reader.ReadByte();

            CreationIP   = reader.ReadString();
            CreationDate = DateTime.FromBinary(reader.ReadInt64());

            Banned     = reader.ReadBoolean();
            BanReason  = reader.ReadString();
            ExpiryDate = DateTime.FromBinary(reader.ReadInt64());

            LastIP         = reader.ReadString();
            LastLogoutDate = DateTime.FromBinary(reader.ReadInt64());

            if (Envir.LoadVersion > 81)
            {
                LastLoginDate = DateTime.FromBinary(reader.ReadInt64());
            }

            Deleted    = reader.ReadBoolean();
            DeleteDate = DateTime.FromBinary(reader.ReadInt64());

            CurrentMapIndex = reader.ReadInt32();
            CurrentLocation = new Point(reader.ReadInt32(), reader.ReadInt32());
            Direction       = (MirDirection)reader.ReadByte();
            BindMapIndex    = reader.ReadInt32();
            BindLocation    = new Point(reader.ReadInt32(), reader.ReadInt32());

            if (Envir.LoadVersion <= 84)
            {
                HP = reader.ReadUInt16();
                MP = reader.ReadUInt16();
            }
            else
            {
                HP = reader.ReadInt32();
                MP = reader.ReadInt32();
            }

            Experience = reader.ReadInt64();

            AMode = (AttackMode)reader.ReadByte();
            PMode = (PetMode)reader.ReadByte();

            if (Envir.LoadVersion > 34)
            {
                PKPoints = reader.ReadInt32();
            }

            int count = reader.ReadInt32();

            Array.Resize(ref Inventory, count);

            for (int i = 0; i < count; i++)
            {
                if (!reader.ReadBoolean())
                {
                    continue;
                }
                UserItem item = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion);
                if (Envir.BindItem(item) && i < Inventory.Length)
                {
                    Inventory[i] = item;
                }
            }

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                if (!reader.ReadBoolean())
                {
                    continue;
                }
                UserItem item = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion);
                if (Envir.BindItem(item) && i < Equipment.Length)
                {
                    Equipment[i] = item;
                }
            }

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                if (!reader.ReadBoolean())
                {
                    continue;
                }
                UserItem item = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion);
                if (Envir.BindItem(item) && i < QuestInventory.Length)
                {
                    QuestInventory[i] = item;
                }
            }

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                UserMagic magic = new UserMagic(reader);
                if (magic.Info == null)
                {
                    continue;
                }
                Magics.Add(magic);
            }

            //reset all magic cooldowns on char loading < stops ppl from having none working skills after a server crash
            for (int i = 0; i < Magics.Count; i++)
            {
                Magics[i].CastTime = int.MinValue;
            }

            Thrusting     = reader.ReadBoolean();
            HalfMoon      = reader.ReadBoolean();
            CrossHalfMoon = reader.ReadBoolean();
            DoubleSlash   = reader.ReadBoolean();

            MentalState = reader.ReadByte();

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                Pets.Add(new PetInfo(reader));
            }

            AllowGroup = reader.ReadBoolean();

            for (int i = 0; i < Globals.FlagIndexCount; i++)
            {
                Flags[i] = reader.ReadBoolean();
            }

            GuildIndex = reader.ReadInt32();

            AllowTrade = reader.ReadBoolean();

            count = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                QuestProgressInfo quest = new QuestProgressInfo(reader);
                if (Envir.BindQuest(quest))
                {
                    CurrentQuests.Add(quest);
                }
            }

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                Buff buff = new Buff(reader);

                Buffs.Add(buff);
            }

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                Mail.Add(new MailInfo(reader, Envir.LoadVersion, Envir.LoadCustomVersion));
            }

            //IntelligentCreature
            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                UserIntelligentCreature creature = new UserIntelligentCreature(reader);
                if (creature.Info == null)
                {
                    continue;
                }
                IntelligentCreatures.Add(creature);
            }

            if (Envir.LoadVersion == 45)
            {
                var old1 = (IntelligentCreatureType)reader.ReadByte();
                var old2 = reader.ReadBoolean();
            }

            PearlCount = reader.ReadInt32();

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                CompletedQuests.Add(reader.ReadInt32());
            }

            if (reader.ReadBoolean())
            {
                CurrentRefine = new UserItem(reader, Envir.LoadVersion, Envir.LoadCustomVersion);
            }
            if (CurrentRefine != null)
            {
                Envir.BindItem(CurrentRefine);
            }

            CollectTime  = reader.ReadInt64();
            CollectTime += Envir.Time;

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                Friends.Add(new FriendInfo(reader));
            }

            if (Envir.LoadVersion > 75)
            {
                count = reader.ReadInt32();
                for (var i = 0; i < count; i++)
                {
                    RentedItems.Add(new ItemRentalInformation(reader));
                }

                HasRentedItem = reader.ReadBoolean();
            }

            Married     = reader.ReadInt32();
            MarriedDate = DateTime.FromBinary(reader.ReadInt64());
            Mentor      = reader.ReadInt32();
            MentorDate  = DateTime.FromBinary(reader.ReadInt64());
            isMentor    = reader.ReadBoolean();
            MentorExp   = reader.ReadInt64();

            if (Envir.LoadVersion >= 63)
            {
                int logCount = reader.ReadInt32();

                for (int i = 0; i < logCount; i++)
                {
                    GSpurchases.Add(reader.ReadInt32(), reader.ReadInt32());
                }
            }
        }
Пример #2
0
        public CharacterInfo(BinaryReader reader)
        {
            Index = reader.ReadInt32();
            Name  = reader.ReadString();

            Level  = reader.ReadByte();
            Class  = (MirClass)reader.ReadByte();
            Gender = (MirGender)reader.ReadByte();
            Hair   = reader.ReadByte();

            CreationIP   = reader.ReadString();
            CreationDate = DateTime.FromBinary(reader.ReadInt64());

            Banned     = reader.ReadBoolean();
            BanReason  = reader.ReadString();
            ExpiryDate = DateTime.FromBinary(reader.ReadInt64());

            LastIP   = reader.ReadString();
            LastDate = DateTime.FromBinary(reader.ReadInt64());

            Deleted    = reader.ReadBoolean();
            DeleteDate = DateTime.FromBinary(reader.ReadInt64());

            CurrentMapIndex = reader.ReadInt32();
            CurrentLocation = new Point(reader.ReadInt32(), reader.ReadInt32());
            Direction       = (MirDirection)reader.ReadByte();
            BindMapIndex    = reader.ReadInt32();
            BindLocation    = new Point(reader.ReadInt32(), reader.ReadInt32());

            HP         = reader.ReadUInt16();
            MP         = reader.ReadUInt16();
            Experience = reader.ReadInt64();

            AMode = (AttackMode)reader.ReadByte();
            PMode = (PetMode)reader.ReadByte();

            if (Envir.LoadVersion > 34)
            {
                PKPoints = reader.ReadInt32();
            }

            int count = reader.ReadInt32();

            Array.Resize(ref Inventory, count);

            for (int i = 0; i < count; i++)
            {
                if (!reader.ReadBoolean())
                {
                    continue;
                }
                UserItem item = new UserItem(reader, Envir.LoadVersion);
                if (SMain.Envir.BindItem(item) && i < Inventory.Length)
                {
                    Inventory[i] = item;
                }
            }

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                if (!reader.ReadBoolean())
                {
                    continue;
                }
                UserItem item = new UserItem(reader, Envir.LoadVersion);
                if (SMain.Envir.BindItem(item) && i < Equipment.Length)
                {
                    Equipment[i] = item;
                }
            }

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                if (!reader.ReadBoolean())
                {
                    continue;
                }
                UserItem item = new UserItem(reader, Envir.LoadVersion);
                if (SMain.Envir.BindItem(item) && i < QuestInventory.Length)
                {
                    QuestInventory[i] = item;
                }
            }

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                UserMagic magic = new UserMagic(reader);
                if (magic.Info == null)
                {
                    continue;
                }
                Magics.Add(magic);
            }


            if (Envir.LoadVersion < 2)
            {
                return;
            }

            Thrusting     = reader.ReadBoolean();
            HalfMoon      = reader.ReadBoolean();
            CrossHalfMoon = reader.ReadBoolean();
            DoubleSlash   = reader.ReadBoolean();

            if (Envir.LoadVersion > 46)
            {
                MentalState = reader.ReadByte();
            }

            if (Envir.LoadVersion < 4)
            {
                return;
            }

            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                Pets.Add(new PetInfo(reader));
            }


            if (Envir.LoadVersion < 5)
            {
                return;
            }

            AllowGroup = reader.ReadBoolean();

            if (Envir.LoadVersion < 12)
            {
                return;
            }

            if (Envir.LoadVersion == 12)
            {
                count = reader.ReadInt32();
            }

            for (int i = 0; i < Globals.FlagIndexCount; i++)
            {
                Flags[i] = reader.ReadBoolean();
            }

            if (Envir.LoadVersion > 27)
            {
                GuildIndex = reader.ReadInt32();
            }

            if (Envir.LoadVersion > 30)
            {
                AllowTrade = reader.ReadBoolean();
            }

            if (Envir.LoadVersion > 33)
            {
                count = reader.ReadInt32();

                for (int i = 0; i < count; i++)
                {
                    QuestProgressInfo quest = new QuestProgressInfo(reader);
                    if (SMain.Envir.BindQuest(quest))
                    {
                        CurrentQuests.Add(quest);
                    }
                }
            }

            if (Envir.LoadVersion > 42)
            {
                count = reader.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    Buff buff = new Buff(reader);

                    if (Envir.LoadVersion == 51)
                    {
                        buff.Caster = SMain.Envir.GetObject(reader.ReadUInt32());
                    }

                    Buffs.Add(buff);
                }
            }

            if (Envir.LoadVersion > 43)
            {
                count = reader.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    Mail.Add(new MailInfo(reader));
                }
            }

            //IntelligentCreature
            if (Envir.LoadVersion > 44)
            {
                count = reader.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    UserIntelligentCreature creature = new UserIntelligentCreature(reader);
                    if (creature.Info == null)
                    {
                        continue;
                    }
                    IntelligentCreatures.Add(creature);
                }

                if (Envir.LoadVersion == 45)
                {
                    var old1 = (IntelligentCreatureType)reader.ReadByte();
                    var old2 = reader.ReadBoolean();
                }

                PearlCount = reader.ReadInt32();
            }

            if (Envir.LoadVersion > 49)
            {
                count = reader.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    CompletedQuests.Add(reader.ReadInt32());
                }
            }

            if (Envir.LoadVersion > 50)
            {
                count = reader.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    Poison poison = new Poison(reader);

                    if (Envir.LoadVersion == 51)
                    {
                        poison.Owner = SMain.Envir.GetObject(reader.ReadUInt32());
                    }

                    Poisons.Add(poison);
                }
            }
        }