Esempio n. 1
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();
        }
Esempio n. 2
0
        public static OtbFile Load(string path)
        {
            using (ByteArrayFileTreeStream stream = new ByteArrayFileTreeStream(path))
            {
                ByteArrayStreamReader reader = new ByteArrayStreamReader(stream);

                OtbFile file = new OtbFile();

                file.otbInfo = OtbInfo.Load(stream, reader);

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

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

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

                return(file);
            }
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
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();
        }
Esempio n. 5
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();
        }
Esempio n. 6
0
        public T Create <T>(ByteArrayStreamReader reader) where T : IIncomingPacket
        {
            var packet = (IIncomingPacket)Activator.CreateInstance <T>();

            packet.Read(reader);

            return((T)packet);
        }
        public void Read(ByteArrayStreamReader reader)
        {
            X = reader.ReadUShort();

            Y = reader.ReadUShort();

            Z = reader.ReadByte();
        }
        public void Read(ByteArrayStreamReader reader)
        {
            FightMode = (FightMode)reader.ReadByte();

            ChaseMode = (ChaseMode)reader.ReadByte();

            SafeMode = (SafeMode)reader.ReadByte();
        }
Esempio n. 9
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();
        }
Esempio n. 10
0
        public void Read(ByteArrayStreamReader reader)
        {
            MoveDirections = new MoveDirection[reader.ReadByte()];

            for (int i = 0; i < MoveDirections.Length; i++)
            {
                MoveDirections[i] = (MoveDirection)reader.ReadByte();
            }
        }
Esempio n. 11
0
        public void Read(ByteArrayStreamReader reader)
        {
            ItemId = reader.ReadUShort();

            Type = reader.ReadByte();

            Count = reader.ReadByte();

            KeepEquipped = reader.ReadBool();
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
        public void Read(ByteArrayStreamReader reader)
        {
            ItemId = reader.ReadUShort();

            Type = reader.ReadByte();

            Count = reader.ReadByte();

            IgnoreCapacity = reader.ReadBool();

            BuyWithBackpacks = reader.ReadBool();
        }
        public void Read(ByteArrayStreamReader reader)
        {
            X = reader.ReadUShort();

            Y = reader.ReadUShort();

            Z = reader.ReadByte();

            ItemId = reader.ReadUShort();

            Index = reader.ReadByte();

            CreatureId = reader.ReadUInt();
        }
Esempio n. 15
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);
        }
Esempio n. 16
0
        public void Read(ByteArrayStreamReader reader)
        {
            X = reader.ReadUShort();

            Y = reader.ReadUShort();

            Z = reader.ReadByte();

            ItemId = reader.ReadUShort();

            Index = reader.ReadByte();

            ContainerId = reader.ReadByte();
        }
Esempio n. 17
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);
                }
            }
        }
Esempio n. 18
0
        public static OtbInfo Load(ByteArrayFileTreeStream stream, ByteArrayStreamReader reader)
        {
            OtbInfo otbInfo = new OtbInfo();

            stream.Seek(Origin.Current, 13);

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

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

            otbInfo.Revision = reader.ReadUInt();

            otbInfo.CsdVersion = reader.ReadCsd();

            return(otbInfo);
        }
Esempio n. 19
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);
        }
Esempio n. 20
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();
        }
Esempio n. 21
0
        protected override void OnReceived(byte[] body)
        {
            ByteArrayArrayStream stream = new ByteArrayArrayStream(body);

            ByteArrayStreamReader reader = new ByteArrayStreamReader(stream);

            try
            {
                if (Adler32.Generate(body, 4) == reader.ReadUInt())
                {
                    if (Keys == null)
                    {
                        Rsa.DecryptAndReplace(body, 21);
                    }

                    Command command = null;

                    switch (reader.ReadByte())
                    {
                    case 0x01:
                    {
                        var packet = server.PacketsFactory.Create <EnterGameIncomingPacket>(reader);

                        command = new EnterGameCommand(this, packet);
                    }
                    break;
                    }

                    if (command != null)
                    {
                        server.QueueForExecution(command);
                    }
                }
            }
            catch (Exception ex)
            {
                server.Logger.WriteLine(ex.ToString());
            }

            base.OnReceived(body);
        }
Esempio n. 22
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);
        }
Esempio n. 23
0
        public static Image Load(ByteArrayFileStream stream, ByteArrayStreamReader reader)
        {
            Image image = new Image();

            image.Width = reader.ReadByte();

            image.Height = reader.ReadByte();

            image.Red = reader.ReadByte();

            image.Green = reader.ReadByte();

            image.Blue = reader.ReadByte();

            int sprites = image.Width * image.Height;

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

            for (int i = 0; i < sprites; i++)
            {
                int index = reader.ReadInt();

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

                    stream.Seek(Origin.Begin, index);

                    Sprite sprite = Sprite.Load(true, image.Red, image.Green, image.Blue, reader);

                    image.sprites.Add(sprite);

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

            return(image);
        }
Esempio n. 24
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);
            }
        }
Esempio n. 25
0
        public static MapInfo Load(ByteArrayFileTreeStream stream, ByteArrayStreamReader reader)
        {
            MapInfo mapInfo = new MapInfo();

            stream.Seek(Origin.Current, 1);

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

                    mapInfo.descriptions.Add(reader.ReadString());

                    break;

                case OtbmAttribute.SpawnFile:

                    mapInfo.SpawnFile = reader.ReadString();

                    break;

                case OtbmAttribute.HouseFile:

                    mapInfo.HouseFile = reader.ReadString();

                    break;

                default:

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

                    return(mapInfo);
                }
            }
        }
Esempio n. 26
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;
        }
Esempio n. 27
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);
                }
            }
        }
Esempio n. 28
0
 public void Read(ByteArrayStreamReader reader)
 {
 }
 public void Read(ByteArrayStreamReader reader)
 {
     Enabled = reader.ReadBool();
 }
 public void Read(ByteArrayStreamReader reader)
 {
     Outfit = reader.ReadOutfit();
 }