Пример #1
0
        public void Read(ByteArrayStreamReader reader)
        {
            OperatingSystem = (OperatingSystem)reader.ReadUShort();

            Version = reader.ReadUShort();

            TibiaDat = reader.ReadUInt();

            TibiaSpr = reader.ReadUInt();

            TibiaPic = reader.ReadUInt();

            reader.ReadByte();

            Keys = new uint[]
            {
                reader.ReadUInt(),

                    reader.ReadUInt(),

                    reader.ReadUInt(),

                    reader.ReadUInt()
            };

            Account = reader.ReadString();

            Password = reader.ReadString();
        }
Пример #2
0
        public void Read(ByteArrayStreamReader reader)
        {
            OperatingSystem = (OperatingSystem)reader.ReadUShort();

            Version = reader.ReadUShort();

            reader.ReadByte();

            Keys = new uint[]
            {
                reader.ReadUInt(),

                    reader.ReadUInt(),

                    reader.ReadUInt(),

                    reader.ReadUInt()
            };

            Gamemaster = reader.ReadBool();

            Account = reader.ReadString();

            Character = reader.ReadString();

            Password = reader.ReadString();
        }
Пример #3
0
        public void Read(ByteArrayStreamReader reader)
        {
            X = reader.ReadUShort();

            Y = reader.ReadUShort();

            Z = reader.ReadByte();
        }
Пример #4
0
        public static Waypoint Load(ByteArrayFileTreeStream stream, ByteArrayStreamReader reader)
        {
            Waypoint waypoint = new Waypoint();

            stream.Seek(Origin.Current, 1);

            waypoint.Name = reader.ReadString();

            waypoint.Position = new Position(reader.ReadUShort(), reader.ReadUShort(), reader.ReadByte());

            return(waypoint);
        }
Пример #5
0
        public static Town Load(ByteArrayFileTreeStream stream, ByteArrayStreamReader reader)
        {
            Town town = new Town();

            stream.Seek(Origin.Current, 1);

            town.Id = reader.ReadUInt();

            town.Name = reader.ReadString();

            town.Position = new Position(reader.ReadUShort(), reader.ReadUShort(), reader.ReadByte());

            return(town);
        }
Пример #6
0
        public void Read(ByteArrayStreamReader reader)
        {
            X = reader.ReadUShort();

            Y = reader.ReadUShort();

            Z = reader.ReadByte();

            ItemId = reader.ReadUShort();

            Index = reader.ReadByte();

            ContainerId = reader.ReadByte();
        }
        public void Read(ByteArrayStreamReader reader)
        {
            X = reader.ReadUShort();

            Y = reader.ReadUShort();

            Z = reader.ReadByte();

            ItemId = reader.ReadUShort();

            Index = reader.ReadByte();

            CreatureId = reader.ReadUInt();
        }
Пример #8
0
        public static PicFile Load(string path)
        {
            using (ByteArrayFileStream stream = new ByteArrayFileStream(path))
            {
                ByteArrayStreamReader reader = new ByteArrayStreamReader(stream);

                PicFile file = new PicFile();

                file.signature = reader.ReadUInt();

                ushort images = reader.ReadUShort();

                file.images = new List <Image>(images);

                for (ushort imageId = 0; imageId < images; imageId++)
                {
                    Image image = Image.Load(stream, reader);

                    image.Id = imageId;

                    file.images.Add(image);
                }

                return(file);
            }
        }
Пример #9
0
        public void Read(ByteArrayStreamReader reader)
        {
            TalkType = (TalkType)reader.ReadByte();

            switch (TalkType)
            {
            case TalkType.Private:

            case TalkType.PrivateRed:

            case TalkType.ReportRuleViolationAnswer:

                Name = reader.ReadString();

                break;

            case TalkType.ChannelYellow:

            case TalkType.ChannelWhite:

            case TalkType.ChannelRed:

            case TalkType.ChannelOrange:

            case TalkType.ChannelRedAnonymous:

                ChannelId = reader.ReadUShort();

                break;
            }

            Message = reader.ReadString();
        }
Пример #10
0
        public void Read(ByteArrayStreamReader reader)
        {
            OperatingSystem = (OperatingSystem)reader.ReadUShort();

            Version = reader.ReadUShort();

            TibiaDat = reader.ReadUInt();

            TibiaSpr = reader.ReadUInt();

            TibiaPic = reader.ReadUInt();

            reader.ReadByte();

            Keys = new uint[]
            {
                reader.ReadUInt(),

                    reader.ReadUInt(),

                    reader.ReadUInt(),

                    reader.ReadUInt()
            };

            Account = reader.ReadString();

            Password = reader.ReadString();

            LocaleId = reader.ReadByte();

            Locate = Encoding.Default.GetString(reader.ReadBytes(3));

            TotalRam = reader.ReadUShort();

            reader.ReadBytes(6);

            Cpu = Encoding.Default.GetString(reader.ReadBytes(9));

            reader.ReadBytes(2);

            CpuClock = reader.ReadUShort();

            CpuClock2 = reader.ReadUShort();

            reader.ReadBytes(4);

            Cpu = Encoding.Default.GetString(reader.ReadBytes(9));

            VideoRam = reader.ReadUShort();

            ResolutionHorizontal = reader.ReadUShort();

            ResolutionVertical = reader.ReadUShort();

            RefreshRate = reader.ReadByte();
        }
Пример #11
0
        public static OtbmInfo Load(ByteArrayFileTreeStream stream, ByteArrayStreamReader reader)
        {
            OtbmInfo otbmInfo = new OtbmInfo();

            stream.Seek(Origin.Current, 6);

            otbmInfo.OtbmVersion = (OtbmVersion)reader.ReadUInt();

            otbmInfo.Width = reader.ReadUShort();

            otbmInfo.Height = reader.ReadUShort();

            otbmInfo.MajorVersion = (OtbVersion)reader.ReadUInt();

            otbmInfo.MinorVersion = (TibiaVersion)reader.ReadUInt();

            return(otbmInfo);
        }
Пример #12
0
        public void Read(ByteArrayStreamReader reader)
        {
            ItemId = reader.ReadUShort();

            Type = reader.ReadByte();

            Count = reader.ReadByte();

            KeepEquipped = reader.ReadBool();
        }
Пример #13
0
        public void Read(ByteArrayStreamReader reader)
        {
            FromX = reader.ReadUShort();

            FromY = reader.ReadUShort();

            FromZ = reader.ReadByte();

            FromItemId = reader.ReadUShort();

            FromIndex = reader.ReadByte();

            ToX = reader.ReadUShort();

            ToY = reader.ReadUShort();

            ToZ = reader.ReadByte();

            Count = reader.ReadByte();
        }
Пример #14
0
        public void Read(ByteArrayStreamReader reader)
        {
            ItemId = reader.ReadUShort();

            Type = reader.ReadByte();

            Count = reader.ReadByte();

            IgnoreCapacity = reader.ReadBool();

            BuyWithBackpacks = reader.ReadBool();
        }
Пример #15
0
        public static Area Load(ByteArrayFileTreeStream stream, ByteArrayStreamReader reader)
        {
            Area area = new Area();

            area.Position = new Position(reader.ReadUShort(), reader.ReadUShort(), reader.ReadByte());

            if (stream.Child())
            {
                area.tiles = new List <Tile>(1);

                while (true)
                {
                    Tile tile = null;

                    switch ((OtbmType)reader.ReadByte())
                    {
                    case OtbmType.Tile:

                        tile = Tile.Load(stream, reader);

                        break;

                    case OtbmType.HouseTile:

                        tile = HouseTile.Load(stream, reader);

                        break;
                    }

                    area.tiles.Add(tile);

                    if (!stream.Next())
                    {
                        break;
                    }
                }
            }

            return(area);
        }
Пример #16
0
        public static HouseTile Load(ByteArrayFileTreeStream stream, ByteArrayStreamReader reader)
        {
            HouseTile houseTile = new HouseTile();

            houseTile.OffsetX = reader.ReadByte();

            houseTile.OffsetY = reader.ReadByte();

            houseTile.HouseId = reader.ReadUInt();

            while (true)
            {
                switch ((OtbmAttribute)reader.ReadByte())
                {
                case OtbmAttribute.Flags:

                    houseTile.Flags = (TileFlags)reader.ReadUInt();

                    break;

                case OtbmAttribute.ItemId:

                    houseTile.OpenTibiaItemId = reader.ReadUShort();

                    break;

                default:

                    stream.Seek(Origin.Current, -1);

                    if (stream.Child())
                    {
                        houseTile.items = new List <Item>();

                        while (true)
                        {
                            houseTile.items.Add(Item.Load(stream, reader));

                            if (!stream.Next())
                            {
                                break;
                            }
                        }
                    }
                    return(houseTile);
                }
            }
        }
Пример #17
0
        public static SprFile Load(string path)
        {
            using (ByteArrayFileStream stream = new ByteArrayFileStream(path))
            {
                ByteArrayStreamReader reader = new ByteArrayStreamReader(stream);

                SprFile file = new SprFile();

                file.signature = reader.ReadUInt();

                ushort sprites = reader.ReadUShort();

                file.sprites = new List <Sprite>(sprites);

                for (ushort spriteId = 1; spriteId <= sprites; spriteId++)
                {
                    int index = reader.ReadInt();

                    if (index > 0)
                    {
                        int returnIndex = stream.Position;

                        stream.Seek(Origin.Begin, index);

                        Sprite sprite = Sprite.Load(true, reader);

                        sprite.Id = spriteId;

                        file.sprites.Add(sprite);

                        stream.Seek(Origin.Begin, returnIndex);
                    }
                }

                return(file);
            }
        }
Пример #18
0
        public static DatFile Load(string path)
        {
            using (ByteArrayFileStream stream = new ByteArrayFileStream(path))
            {
                ByteArrayStreamReader reader = new ByteArrayStreamReader(stream);

                DatFile file = new DatFile();

                file.signature = reader.ReadUInt();

                ushort items = reader.ReadUShort();

                ushort outfits = reader.ReadUShort();

                ushort effects = reader.ReadUShort();

                ushort projectiles = reader.ReadUShort();

                file.items = new List <Item>(items);

                for (ushort itemId = 100; itemId <= items; itemId++)
                {
                    Item item = Item.Load(reader);

                    item.TibiaId = itemId;

                    file.items.Add(item);
                }

                file.outfits = new List <Item>(outfits);

                for (ushort outfitId = 0; outfitId < outfits; outfitId++)
                {
                    Item item = Item.Load(reader);

                    item.TibiaId = outfitId;

                    file.outfits.Add(item);
                }

                file.effects = new List <Item>(effects);

                for (ushort effectId = 0; effectId < effects; effectId++)
                {
                    Item item = Item.Load(reader);

                    item.TibiaId = effectId;

                    file.effects.Add(item);
                }

                file.projectiles = new List <Item>(projectiles);

                for (ushort projectileId = 0; projectileId < projectiles; projectileId++)
                {
                    Item item = Item.Load(reader);

                    item.TibiaId = projectileId;

                    file.projectiles.Add(item);
                }

                return(file);
            }
        }
Пример #19
0
        public static Item Load(ByteArrayFileTreeStream stream, ByteArrayStreamReader reader)
        {
            Item item = new Item();

            stream.Seek(Origin.Current, 1);

            item.OpenTibiaId = reader.ReadUShort();

            while (true)
            {
                switch ((OtbmAttribute)reader.ReadByte())
                {
                case OtbmAttribute.Count:

                    item.Count = reader.ReadByte();

                    break;

                case OtbmAttribute.ActionId:

                    item.ActionId = reader.ReadUShort();

                    break;

                case OtbmAttribute.UniqueId:

                    item.UniqueId = reader.ReadUShort();

                    break;

                case OtbmAttribute.Text:

                    item.Text = reader.ReadString();

                    break;

                case OtbmAttribute.WrittenDate:

                    item.WrittenDate = reader.ReadUInt();

                    break;

                case OtbmAttribute.WrittenBy:

                    item.WrittenBy = reader.ReadString();

                    break;

                case OtbmAttribute.SpecialDescription:

                    item.SpecialDescription = reader.ReadString();

                    break;

                case OtbmAttribute.RuneCharges:

                    item.RuneCharges = reader.ReadByte();

                    break;

                case OtbmAttribute.Charges:

                    item.Charges = reader.ReadUShort();

                    break;

                case OtbmAttribute.Duration:

                    item.Duration = reader.ReadUInt();

                    break;

                case OtbmAttribute.Decaying:

                    item.Decaying = reader.ReadByte();

                    break;

                case OtbmAttribute.DepotId:

                    item.DeportId = reader.ReadUShort();

                    break;

                case OtbmAttribute.HouseDoorId:

                    item.HouseDoorId = reader.ReadByte();

                    break;

                case OtbmAttribute.SleeperId:

                    item.SleeperId = reader.ReadUInt();

                    break;

                case OtbmAttribute.SleepStart:

                    item.SleepterStart = reader.ReadUInt();

                    break;

                case OtbmAttribute.TeleportDestination:

                    item.TeleportPosition = new Position(reader.ReadUShort(), reader.ReadUShort(), reader.ReadByte());

                    break;

                case OtbmAttribute.ContainerItems:

                    item.ContainerItems = reader.ReadUInt();

                    break;

                default:

                    stream.Seek(Origin.Current, -1);

                    if (stream.Child())
                    {
                        item.items = new List <Item>();

                        while (true)
                        {
                            item.items.Add(Item.Load(stream, reader));

                            if (!stream.Next())
                            {
                                break;
                            }
                        }
                    }
                    return(item);
                }
            }
        }
Пример #20
0
 public void Read(ByteArrayStreamReader reader)
 {
     QuestId = reader.ReadUShort();
 }
Пример #21
0
        public void Read(ByteArrayStreamReader reader)
        {
            ItemId = reader.ReadUShort();

            Type = reader.ReadByte();
        }
Пример #22
0
        public static Item Load(ByteArrayStreamReader reader)
        {
            Item item = new Item();

            while (true)
            {
                switch ((DatAttribute)reader.ReadByte())
                {
                case DatAttribute.IsGround:

                    item.Flags |= ItemFlags.IsGround;

                    item.Speed = reader.ReadUShort();

                    break;

                case DatAttribute.AlwaysOnTop1:

                    item.Flags |= ItemFlags.AlwaysOnTop1;

                    break;

                case DatAttribute.AlwaysOnTop2:

                    item.Flags |= ItemFlags.AlwaysOnTop2;

                    break;

                case DatAttribute.AlwaysOnTop3:

                    item.Flags |= ItemFlags.AlwaysOnTop3;

                    break;

                case DatAttribute.IsContainer:

                    item.Flags |= ItemFlags.IsContainer;

                    break;

                case DatAttribute.Stackable:

                    item.Flags |= ItemFlags.Stackable;

                    break;

                case DatAttribute.Useable:

                    item.Flags |= ItemFlags.Useable;

                    break;

                case DatAttribute.Writeable:

                    item.MaxReadWriteChars = reader.ReadUShort();

                    break;

                case DatAttribute.Readable:

                    item.MaxReadChars = reader.ReadUShort();

                    break;

                case DatAttribute.IsFluid:

                    item.Flags |= ItemFlags.IsFluid;

                    break;

                case DatAttribute.IsSplash:

                    item.Flags |= ItemFlags.IsSplash;

                    break;

                case DatAttribute.NotWalkable:

                    item.Flags |= ItemFlags.NotWalkable;

                    break;

                case DatAttribute.NotMoveable:

                    item.Flags |= ItemFlags.NotMoveable;

                    break;

                case DatAttribute.BlockProjectile:

                    item.Flags |= ItemFlags.BlockProjectile;

                    break;

                case DatAttribute.BlockPathFinding:

                    item.Flags |= ItemFlags.BlockPathFinding;

                    break;

                case DatAttribute.Pickupable:

                    item.Flags |= ItemFlags.Pickupable;

                    break;

                case DatAttribute.Hangable:

                    item.Flags |= ItemFlags.Hangable;

                    break;

                case DatAttribute.Horizontal:

                    item.Flags |= ItemFlags.Horizontal;

                    break;

                case DatAttribute.Vertical:

                    item.Flags |= ItemFlags.Vertical;

                    break;

                case DatAttribute.Rotatable:

                    item.Flags |= ItemFlags.Rotatable;

                    break;

                case DatAttribute.Light:

                    item.LightLevel = reader.ReadUShort();

                    item.LightColor = reader.ReadUShort();

                    break;

                case DatAttribute.Offset:

                    item.OffsetX = reader.ReadUShort();

                    item.OffsetY = reader.ReadUShort();

                    break;

                case DatAttribute.HasHeight:

                    item.ItemHeight = reader.ReadUShort();

                    break;

                case DatAttribute.IdleAnimation:

                    item.Flags |= ItemFlags.IdleAnimation;

                    break;

                case DatAttribute.MinimapColor:

                    item.MinimapColor = reader.ReadUShort();

                    break;

                case DatAttribute.ExtraInfo:

                    item.ExtraInfo = (ExtraInfo)reader.ReadUShort();

                    break;

                case DatAttribute.SolidGround:

                    item.Flags |= ItemFlags.SolidGround;

                    break;

                case DatAttribute.LookThrough:

                    item.Flags |= ItemFlags.LookThrough;

                    break;

                case DatAttribute.End:

                    item.Width = reader.ReadByte();

                    item.Height = reader.ReadByte();

                    if (item.Width > 1 || item.Height > 1)
                    {
                        item.CropSize = reader.ReadByte();
                    }

                    item.Layers = reader.ReadByte();

                    item.XRepeat = reader.ReadByte();

                    item.YRepeat = reader.ReadByte();

                    item.ZRepeat = reader.ReadByte();

                    item.Animations = reader.ReadByte();

                    int sprites = item.Width * item.Height * item.Layers * item.XRepeat * item.YRepeat * item.ZRepeat * item.Animations;

                    item.spriteIds = new List <ushort>(sprites);

                    for (int i = 0; i < sprites; i++)
                    {
                        item.spriteIds.Add(reader.ReadUShort());
                    }

                    return(item);
                }
            }
        }
Пример #23
0
        public static Item Load(ByteArrayFileTreeStream stream, ByteArrayStreamReader reader)
        {
            Item item = new Item();

            item.Group = (ItemGroup)reader.ReadByte();

            item.Flags = (ItemFlags)reader.ReadUInt();

            while (true)
            {
                OtbAttribute attribute = (OtbAttribute)reader.ReadByte();

                stream.Seek(Origin.Current, 2);

                switch (attribute)
                {
                case OtbAttribute.OpenTibiaId:

                    item.OpenTibiaId = reader.ReadUShort();

                    break;

                case OtbAttribute.TibiaId:

                    item.TibiaId = reader.ReadUShort();

                    break;

                case OtbAttribute.Speed:

                    item.Speed = reader.ReadUShort();

                    break;

                case OtbAttribute.SpriteHash:

                    item.SpriteHash = reader.ReadBytes(16);

                    break;

                case OtbAttribute.MinimapColor:

                    item.MinimapColor = reader.ReadUShort();

                    break;

                case OtbAttribute.MaxReadWriteChars:

                    item.MaxReadWriteChars = reader.ReadUShort();

                    break;

                case OtbAttribute.MaxReadChars:

                    item.MaxReadChars = reader.ReadUShort();

                    break;

                case OtbAttribute.Light:

                    item.LightLevel = reader.ReadUShort();

                    item.LightColor = reader.ReadUShort();

                    break;

                case OtbAttribute.TopOrder:

                    item.TopOrder = (TopOrder)reader.ReadByte();

                    break;

                default:

                    stream.Seek(Origin.Current, -3);

                    return(item);
                }
            }
        }
Пример #24
0
        public static Sprite Load(bool invisible, ByteArrayStreamReader reader)
        {
            byte[] pixels = new byte[4 * 32 * 32];

            int pixel = 0;

            byte red = reader.ReadByte();

            byte green = reader.ReadByte();

            byte blue = reader.ReadByte();

            int length = reader.ReadUShort();

            while (true)
            {
                if (length <= 0)
                {
                    break;
                }

                ushort transparent = reader.ReadUShort();

                length -= 2;

                if (invisible)
                {
                    pixel += transparent * 4;
                }
                else
                {
                    for (int i = 0; i < transparent; i++)
                    {
                        pixels[pixel++] = blue;

                        pixels[pixel++] = green;

                        pixels[pixel++] = red;

                        pixels[pixel++] = 255;
                    }
                }

                if (length <= 0)
                {
                    break;
                }

                ushort colored = reader.ReadUShort();

                length -= 2;

                byte[] coloredBytes = reader.ReadBytes(3 * colored);

                length -= 3 * colored;

                for (int i = 0; i < 3 * colored; i += 3)
                {
                    pixels[pixel++] = coloredBytes[i + 2];

                    pixels[pixel++] = coloredBytes[i + 1];

                    pixels[pixel++] = coloredBytes[i];

                    pixels[pixel++] = 255;
                }
            }

            Sprite sprite = new Sprite();

            sprite.Red = red;

            sprite.Green = green;

            sprite.Blue = blue;

            sprite.Pixels = pixels;

            return sprite;
        }
 public void Read(ByteArrayStreamReader reader)
 {
     ChannelId = reader.ReadUShort();
 }