- Fórum
- OTServ
- Recursos
- Linguagens de Programação
- Data/Sprite File Structure
DA
Data/Sprite File Structure
Por Daniel Bighouse, 28 de jan. de 2013 em Linguagens de Programação
otserv
tibia
1
1.4k
Por Daniel Bighouse, 28 de jan. de 2013 em Linguagens de Programação
info
Grupo: Cavaleiro
Registrado: 20/09/12
Posts: 153
Reputação: +31
Tibia: Estrutura do Arquivo Dat
Versão em português:
Nota: A partir de digitar isso, a estrutura Estarei postando trabalhos com a versão atual do cliente, 9,44, e deve funcionar de volta até a bandeira isSprite (8,54?). Quando eu chegar em tempo eu vou atualizar isso para apoiar as estruturas arquivo DAT, tanto para trás que eu puder.
* Todos os nomes que eu uso são o que a CipSoft usa em seu cliente flash. Mas eu também comentou ao lado o que pode ser confuso.
- Os primeiros 4 bytes do arquivo DAT, que eu chamo de DATVERSION, é único para cada versão do cliente para que o cliente sabe que o arquivo Dat correto está sendo usado.
- Em seguida, temos 4 calções (2 bytes cada) que contêm o número de itens, equipamentos, efeitos e projéteis (respectivamente) no arquivo DAT.
- Agora começa os dados reais desses objetos. A primeira coisa que você vai encontrar são o que chamamos Flags. Estas bandeiras deixar o cliente saber se o item pode ser pisado, se ele pode ser pego, se ele emite luz, etc, etc
- Como você pode ver acima, temos uma bandeira novo mercado. Este foi introduzido com o novo sistema de mercado em que o cliente 9,41. Aqui estão as categorias de mercado associados:
- Depois de passar por todos os bytes nos deparamos com as informações necessárias para os sprites do objeto. (altura, largura, camadas, fases, etc)
- Em seguida, loop através de todos os sprites disponíveis associados com o item.
- E é isso. Esperamos que para o próximo objeto e fazê-lo novamente.
Agora, aqui está o código usado para ler o arquivo DAT que você pode jogar para VB.Net e correr. Se você tiver alguma dúvida não hesite em perguntar:
Todos os objetos são armazenados na matriz de dados e você pode acessar objetos de identificação. Aqui está um exemplo:
Tibia: Data File Structure
Versão original em inglês:
Note: As of typing this, the structure I'll be posting works with the current client version, 9.44, and should work back until the isSprite flag (8.54?). When I get time I'll update this to support Dat file structures as far back as I can.
*All the names I use are what CipSoft uses in their flash client. But I also commented beside what may be confusing.
- The first 4 bytes of the Dat file, which I call the DatVersion, is unique for each client version so that the client knows that the correct Dat file is being used.
- Next we have 4 shorts (2 bytes each) that contain the number of items, outfits, effects, and projectiles (respectively) in the Dat file.
- Now starts the actual data of these objects. The first thing you'll encounter are what we call Flags. These Flags let the client know if the item can be walked on, if it can be picked up, if it gives off light, etc. etc.
- As you can see above we have a new Market flag. This was introduced with the new Market system in the 9.41 client. Here are the market categories associated with it:
- After we go through all the bytes we come across the information needed for the sprites of the object. (height, width, layers, phases, etc.)
- Then we loop through all the available sprites associated with the item.
- And that's it. We hope on to the next object and do it again.
Now, here's code used to read the Dat file that you can throw in to VB.Net and run. If you have any questions feel free to ask:
All objects are stored in dataArray and you can access objects by ID. Here's an example:
Alguém arruma ai que a porcaria tem limite de quotes eu acho
Estrutura Tibia.dat
Versão em potuguês:
Os primeiros 4 bytes contém informações para a versão dat, eu acho que isso é usado para ver qual a estrutura de usar (7,7 + ou-7,6). Os próximos dois bytes são contagem de itens, os próximos dois bytes são contagem de roupa, os próximos dois bytes são contagem efeito, e os próximos dois bytes são contagem de distância. O byte seguinte começa a informação bandeiras para o primeiro item (ID = 100), estas bandeiras são indicados por um valor entre & H0 e & H1F:
& H0 = telha chão
& H1 = em cima
& H2 = percorrer (portas, etc)
& H3 = percorrer (arcos etc)
& H4 = contentor
& H5 = empilhável
& H6 = escada?
& H7 = utilizável
& H8 = rune
& H9 = gravável
& HA = legível
& HB recipiente de fluido =
& HC splash =
& Hd = bloqueio
& HE = imóveis
& HF míssil = blocos
& H10 = movimento monstro blocos
& H11 = equipáveis
& H12 = hangable (item parede)
& H13 = horizontal (item parede)
& H14 = vertical (item parede)
& H15 = rotateable
& H16 Informações luz =
& H17 = desconhecido?
& H18 = mudança no andar de baixo?
& H19 = empate compensar
& H1A = altura
& H1B = desenhar com altura deslocamento para todas as peças (2x2) do sprite,
& H1C = offset vida-bar (para monstros maiores)
& H1D = minimap cor
& H1E mudança chão =?
& H1F = desconhecido?
Determinados sinalizadores são seguidas por um valor, como mostrado abaixo:
& H0 = azulejo chão é seguido por um valor de byte 2 indica a velocidade
& H9 = gravável é seguido por um valor de 2 bytes indicando o comprimento do texto max
& HA = legível é seguido por um valor de 2 bytes indicando o comprimento do texto max
& H16 = info luz é seguido por um valor de 2 bytes indicando o nível de luz, em seguida, um outro valor de byte 2 indicando a cor da luz
& H19 = empate deslocamento é seguido bye um valor de 2 bytes indicando o deslocamento x então um outro valor de 2 bytes indicando o deslocamento Y
& H1A = altura é seguido por um valor de byte 2 indica a altura draw (?)
& H1D = cor minimap é seguido por um valor de byte 2 indicando a cor minimap
& H1E mudança chão =? é seguido por um valor de 1 byte indicando um desses valores (86 - buracos que se abrem, de 77 - pode ser usado para ir para baixo, 76 - pode ser usado para ir para cima, 82 - escadas, 79 - switch), em seguida outro valor 1 byte que sempre retorna 4
O final dos valores de bandeira são indicados por um byte & HFF, em seguida, começa a informação objetos. O byte seguinte é a largura, o próximo é a altura, se a largura ou a altura é maior que 1, você tem que saltar o próximo byte a byte, então depois que ele é mistura quadros se não, então você não pule o próximo byte porque é mistura frames (eu espero que fez lol sentido), o próximo é divx, o próximo é divy, o próximo é divz, em seguida, o próximo é o comprimento de animação. O resto das informações objetos depende do número de sprites (largura * altura * mistura quadros * DivX * divy * divz * comprimento de animação). Você loop o número de sprites e em cada loop você ler 2 bytes para obter uma ID sprite para o objeto (o ID da imagem do objeto usa no arquivo spr.). Então você vai para o próximo objeto (101) e repita o processo.
Aqui está uma lista de bytes básica, incluindo as informações de cabeçalho e as informações para o primeiro objeto (100). [X] = contagem de bytes:
.dat Reader
Depois de estudar a. Estrutura dat eu era capaz de fazer um pequeno programa, mas o trabalho de ler o arquivo Tibia.dat e permitir que você obtenha informações de cada objeto. O programa é escrito em VB.Net e as fontes estão incluídos.
Quando você iniciar o programa, ele irá pedir para localizar e abrir o arquivo Tibia.dat. Assim que terminar o programa irá carregar e os itens, roupas, efeitos e campos de distância será preenchido. Na imagem acima eu carregado o 8,40. Dat. A atual estrutura vai trabalhar de volta para 7.7x versão que eu acredito. Se você quiser verificar a informação de um objeto, que é colocar ID (ID de ouro ou seja, é 3031) no campo ID do Cliente e clique em 'Ok'. O IDs comece em 100, há 9.104 itens para a identificação do item Max é 9204, roupas são 9.205-9.530, os efeitos são 9531-9597, e as distâncias são 9599-9640. Se você colocar um valor inferior a 100 ou superior a 9640 o programa irá falhar porque eu não adicionar qualquer tipo de tratamento de erro. Tudo deve ser auto-explicativo, equipáveis também é pickupable, a caixa suspensa de sprites contém IDs dos sprites que o objeto usa a partir do arquivo spr..
Se você tiver alguma dúvida não hesite em perguntar.
Tibia.dat Structure
Versão original em inglês:
The first 4 bytes contains information for the dat version, I think this is used to see which structure to use (7.7+ or 7.6-). The next 2 bytes are item count, the next 2 bytes are outfit count, the next 2 bytes are effect count, and the next 2 bytes are distance count. The next byte starts the flags information for the first item (ID = 100), these flags are indicated by a value between &H0 and &H1F:
Certain flags are followed by a value, as shown below:
The end of the flag values are indicated by a &HFF byte, then starts the objects information. The next byte is width, the next is height, if the width or height is greater than 1 you have to skip the next byte then the byte after it is blend frames if not then you don't skip the next byte because it is blend frames (i hope that made sense lol), the next is divx, the next is divy, the next is divz, then the next is animation length. The rest of the objects information depends on the number of sprites (width * height * blend frames * divx * divy * divz * animation length). You loop the number of sprites and in each loop you read 2 bytes to get a sprite ID for that object (the ID of the image the object uses in the .spr file). Then you go to the next object (101) and repeat the process.
Here's a basic byte list including the header information and the information for the first object (100). [x] = byte count:
After studying the .dat structure I was able to make a small, but working program to read the Tibia.dat file and allow you to get information for each object. The program is written in VB.Net and the sources are included.
When you first start the program it will ask you to locate and open your Tibia.dat file. Once this is finished the program will load and the items, outfits, effects, and distance fields will be filled. In the above screenshot I've loaded the 8.40 .dat file. The current structure will work back to version 7.7x I believe. If you want to check the information of an object, place it's ID (ie. gold's ID is 3031) in the Client ID field and click 'Go'. The IDs start at 100, there are 9104 items so the max item ID is 9204, outfits are from 9205-9530, effects are from 9531-9597, and distances are from 9599-9640. If you put a value lower than 100 or higher than 9640 the program will crash because I didn't add any type of error handling. Everything should be self explanatory, equipable is also pickupable, the sprites dropdown box contains IDs of the sprites that the object uses from the .spr file.
If you have any questions please feel free to ask.
------------------------------------------------------------------------------------------------------------------------------------------------------
Tibia: estrutura do Arquivo Sprite
Versão em português:
Nota: Um grande obrigado a Sketchy pela ajuda com aumentando muito a velocidade de leitura do sprite, especificamente a criação de um bitmap do sprite, substituindo Bitmap.SetPixel () com Bitmap.LockBits () / Bitmap.UnlockBits ().
- Como a estrutura do arquivo Dat, o arquivo de sprite começa com 4 bytes, o que eu chamo de SpriteVersion, e é exclusivo para cada versão do cliente de modo que o cliente sabe que o arquivo correto sprite está sendo usado.
- Isto é seguido por dois bytes, que contém o número de sprites no arquivo de sprite.
- Imediatamente após isso temos um valor de 4 bytes para cada sprite contendo sua deslocamento de byte no arquivo de sprite.
[x] = Número de bytes.
- Agora vamos começar a ficar para os dados reais do sprite. Cada sprite começa com a cor dos pixels transparente '. Neste caso, o cliente usa Tibia magenta para os três bytes retornados são 255, 0, 255. Você não precisa deste pixel ao criar o bitmap.
- Após este é 2 bytes indicando o tamanho do sprite. (Todos os sprites são 32x32 pixels, 1024 pixels, então isso nunca deve mudar.)
- Em seguida, começar a ler os dados de pixel reais do sprite. Isso começa com dois bytes segurando o número de pixels transparentes antes de pixel colorido.
- Em seguida, dois bytes segurando o número de pixels coloridos antes de um pixel transparente. Imediatamente após este é um três-byte valores que prendem o valor RGB do pixel. Por exemplo, se o número de pixels coloridos retornados é 3, então você leria os próximos 9 bytes (3 bytes para cada pixel) para obter as informações de pixel de cada um.
[x] = Número de bytes.
- Na forma que usamos para fazer bitmap a partir dos dados do sprite em TibiaAPI (que você pode ver aqui: http://code.google.c...ce...eReader.cs) usamos Bitmap.SetPixel () para definir a cor do pixel no bitmap. Enquanto esta é uma maneira fácil de conseguir o que queremos, que é também um pouco lento. Mas, graças a esboçado, você pode conseguir um aumento de velocidade de 10x usando Bitmap.LockBits () e Bitmap.UnlockBits (). (Em meus testes, eu poderia carregar o arquivo inteiro 9,44 Sprite em 35 segundos usando Bitmap.SetPixels (), mas eu podia carregá-lo em apenas 3,5 segundos! Usando Bitmap.LockBits () / Bitmap.UnlockBits ().)
Agora, aqui está o código usado para ler o arquivo de sprite que você pode jogar para VB.Net e correr. Este usa as LockBits / método UnlockBits, e eu comentei o código para ajudar você a entender o que está acontecendo. A estrutura Sprite tem sido a mesma desde que me lembro, então você não deve ter um problema usando este código para qualquer versão do cliente. Além disso, este código lê e armazena cada sprite em uma matriz, mas você pode modificá-lo como o código TibiaAPI para recuperar somente um sprite específico. Se você tiver alguma dúvida não hesite em perguntar:
Você pode facilmente verificar cada imagem, adicionando uma caixa de imagem, TextBox e Button a sua forma e usando este código:
Tibia: Sprite File Structure
Versão original em inglês:
Note: A big thanks to Sketchy for the help with greatly increasing the speed of reading the sprite, specifically creating a bitmap of the sprite, by replacing Bitmap.SetPixel() with BitMap.LockBits()/Bitmap.UnlockBits().
- Like the Dat file structure, the sprite file begins with 4 bytes, which I call the SpriteVersion, and is unique for each client version so that the client knows that the correct sprite file is being used.
- This is followed by 2 bytes that contains the number of sprites in the sprite file.
- Immediately following this we have a 4-byte value for each sprite containing it's byte offset in the sprite file.
[x] = Number of bytes.
- Now we start getting in to the actual sprite data. Each sprite begins with the transparent-pixels' color. In this case, the Tibia client uses magenta so the three bytes returned are 255, 0, 255. You don't need this pixel when creating the bitmap.
- Following this is 2 bytes indicating the size of the sprite. (All sprites are 32x32 pixels, 1024 pixels, so this should never change.)
- Next we start reading the actual pixel data of the sprite. This begins with 2 bytes holding the number of transparent pixels before colored pixel.
- Then 2 bytes holding the number of colored pixels before a transparent pixel. Immediately following this is three 1-byte values holding the RGB value of the pixel. For example, if the number of colored pixels returned is 3 then you would read the next 9 bytes (3 bytes for each pixel) to get the pixel information of each.
[x] = Number of bytes.
- In the way we used to make bitmap's from the sprite data in TibiaAPI (which you can view here: http://code.google.c...ce...eReader.cs ) we used Bitmap.SetPixel() to set the pixel color in the bitmap. While this is an easy way to achieve what we want, it's also a bit slow. But, thanks to Sketchy, you can achieve a 10x speed increase by using Bitmap.LockBits() and Bitmap.UnlockBits(). (In my tests, I could load the whole 9.44 sprite file in 35 seconds using Bitmap.SetPixels(), but I could load it in just 3.5 seconds! using Bitmap.LockBits()/Bitmap.UnlockBits().)
Now, here's code used to read the sprite file that you can throw in to VB.Net and run. This uses the LockBits/UnlockBits method, and I have commented the code to help you understand what's going on. The sprite structure has been the same as far back as I can remember, so you shouldn't have a problem using this code for any client version. Also, this code reads and stores each sprite in an array, but you can modify it like the TibiaAPI code to only retrieve a specific sprite. If you have any questions feel free to ask:
You can easily check each image by adding a PictureBox, TextBox, and Button to your form and using this code:
Alguém ai arruma que ta dando erro que quotes abertos não corespondem com quotes fechados!
!!!Mais TODOS estão corretos!!!
Crédito: Jo3Bingham
Editado Janeiro 28 por DanielBadhu