Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
Tibia: Data File Structure - Page 2
Page 2 of 7 FirstFirst 1234 ... LastLast
Results 11 to 20 of 70

Thread: Tibia: Data File Structure

  1. #11
    Junior Member
    Join Date
    May 2010
    Posts
    20

    RE: Tibia: Data File Structure

    Hello, it tryed this script with Tibia.dat from tibia 8.54 and i get the following error here
    Code:
    Dim numSpr As Integer = itemData.Width * itemData.Height
                    numSpr *= itemData.Layers * itemData.PatternWidth
                    numSpr *= itemData.PatternHeight * itemData.PatternDepth
                    numSpr *= itemData.Phases
    It gives an overflow

    I'm using VS 2010 express edition

  2. #12
    Administrator
    Join Date
    Mar 2007
    Posts
    1,723

    RE: Tibia: Data File Structure

    Quote Originally Posted by Darkhaos
    Hello, it tryed this script with Tibia.dat from tibia 8.54 and i get the following error here
    Code:
    Dim numSpr As Integer = itemData.Width * itemData.Height
                    numSpr *= itemData.Layers * itemData.PatternWidth
                    numSpr *= itemData.PatternHeight * itemData.PatternDepth
                    numSpr *= itemData.Phases
    It gives an overflow

    I'm using VS 2010 express edition
    The code I have posted doesn't work before the 8.60 client. The reason you're getting that error is because the flags for the 8.54 client are different from what's posted and getting the reader out of line. I posted the 8.54 flags a while back on this forum, and there are plenty of sources available to help anyone get the flags all the way back to the 7.00 client, which I have.

  3. #13
    Junior Member
    Join Date
    May 2010
    Posts
    20

    RE: Tibia: Data File Structure

    Quote Originally Posted by Jo3Bingham
    Quote Originally Posted by Darkhaos
    Hello, it tryed this script with Tibia.dat from tibia 8.54 and i get the following error here
    Code:
    Dim numSpr As Integer = itemData.Width * itemData.Height
                    numSpr *= itemData.Layers * itemData.PatternWidth
                    numSpr *= itemData.PatternHeight * itemData.PatternDepth
                    numSpr *= itemData.Phases
    It gives an overflow

    I'm using VS 2010 express edition
    The code I have posted doesn't work before the 8.60 client. The reason you're getting that error is because the flags for the 8.54 client are different from what's posted and getting the reader out of line. I posted the 8.54 flags a while back on this forum, and there are plenty of sources available to help anyone get the flags all the way back to the 7.00 client, which I have.
    But the code is the same? i only need to change the flags?


  4. #14
    Administrator
    Join Date
    Mar 2007
    Posts
    1,723

    RE: Tibia: Data File Structure

    Yeah, the flags are the only thing that needs to be changed.

  5. #15
    Junior Member
    Join Date
    May 2010
    Posts
    20

    RE: Tibia: Data File Structure

    Quote Originally Posted by Jo3Bingham
    Yeah, the flags are the only thing that needs to be changed.
    I've looked in forum for the .54 flags and can't find them :/

  6. #16
    Administrator
    Join Date
    Mar 2007
    Posts
    1,723

    RE: Tibia: Data File Structure

    Quote Originally Posted by Darkhaos
    Quote Originally Posted by Jo3Bingham
    Yeah, the flags are the only thing that needs to be changed.
    I've looked in forum for the .54 flags and can't find them :/
    http://tpforums.org/forum/thread-4361-post-58833.html#pid58833

  7. #17
    Junior Member
    Join Date
    Dec 2007
    Posts
    18

    RE: Tibia: Data File Structure

    Great jo3, its amazing! o.O

    The code converted and working to C#

    [code=c#]public class DatFile
    {
    public ItemData[] dataArray;

    //ground tile
    const byte Flag_Bank = 0;
    const byte Flag_Clip = 1;
    const byte Flag_Bottom = 2;
    const byte Flag_Top = 3;
    const byte Flag_Container = 4;
    //stackable
    const byte Flag_Cumulative = 5;
    //always used
    const byte Flag_ForceUse = 6;
    //usable
    const byte Flag_MultiUse = 7;
    //writeable
    const byte Flag_Write = 8;
    //readable
    const byte Flag_WriteOnce = 9;
    const byte Flag_LiquidContainer = 10;
    //splashes
    const byte Flag_LiquidPool = 11;
    const byte Flag_Unpass = 12;
    const byte Flag_Unmove = 13;
    //blocks projectiles
    const byte Flag_Unsight = 14;
    //blocks creature movements
    const byte Flag_Avoid = 15;
    //pickupable
    const byte Flag_Take = 16;
    const byte Flag_Hang = 17;
    const byte Flag_HookSouth = 18;
    const byte Flag_HookEast = 19;
    const byte Flag_Rotate = 20;
    const byte Flag_Light = 21;
    const byte Flag_DontHide = 22;
    const byte Flag_Translucent = 23;
    const byte Flag_Shift = 24;
    const byte Flag_Height = 25;
    const byte Flag_LyingObject = 26;
    const byte Flag_AnimateAlways = 27;
    const byte Flag_Automap = 28;
    const byte Flag_LensHelp = 29;
    const byte Flag_FullBank = 30;
    const byte Flag_IgnoreLook = 31;
    const byte Flag_Clothes = 32;
    const byte Flag_Market = 33;

    public enum MarketCategory
    {
    Armors = 1,
    Amulets = 2,
    Boots = 3,
    Containers = 4,
    Decoration = 5,
    Food = 6,
    Helmets_Hats = 7,
    Legs = 8,
    Others = 9,
    Potions = 10,
    Rings = 11,
    Runes = 12,
    Shields = 13,
    Tools = 14,
    Valuables = 15,
    Ammunition = 16,
    Axes = 17,
    Clubs = 18,
    DistanceWeapons = 19,
    Swords = 20,
    Wands_Rods = 21,
    MetaWeapons = 22
    //all weapons
    }

    public struct ItemData
    {
    public int ID;

    public bool isBank;
    public int Waypoints;
    public bool isClip;
    public bool isBottom;
    public bool isTop;
    public bool isContainer;
    public bool isCumulative;
    public bool isForceUse;
    public bool isMultiUse;
    public bool isWriteable;
    public int MaxTextLength;
    public bool isWriteableOnce;
    public bool isLiquidContainer;
    public bool isLiquidPool;
    public bool isUnpassable;
    public bool isUnmoveable;
    public bool isUnsight;
    public bool isAvoid;
    public bool isTakeable;
    public bool isHangable;
    public bool isHookSouth;
    public bool isHookEast;
    public bool isRotateable;
    public bool isLight;
    public int Brightness;
    public int LightColor;
    public bool isDontHide;
    public bool isTranslucent;
    public bool isDisplaced;
    public int DisplacementX;
    public int DisplacementY;
    public bool isHeight;
    public int Elevation;
    public bool isLyingObject;
    public bool isAnimateAlways;
    public bool isAutomap;
    public int isAutomapColor;
    public bool isLensHelp;
    public int LensHelp;
    public bool isFullBank;
    public bool isIgnoreLook;
    public bool isCloth;
    public int ClothSlot;
    public bool isMarket;
    public MarketCategory MarketCategory;
    public int MarketTradeAs;
    public int MarketShowAs;
    public string MarketName;
    public int MarketRestrictProfession;
    public int MarketRestrictLevel;

    public int Width;
    public int Height;
    public int ExactSize;
    public int Layers;
    public int PatternWidth;
    public int PatternHeight;
    public int PatternDepth;
    public int Phases;
    public int NumberOfSprites;

    public int[] Sprites;
    }

    public void Load()
    {
    string FileName = @"C:\Tibia.dat";

    using (System.IO.BinaryReader reader = new System.IO.BinaryReader(System.IO.File.OpenRead(Fil eName)))
    {
    int DatVersion = reader.ReadInt32();
    int Items = reader.ReadUInt16();
    int Outfits = reader.ReadUInt16();
    int Effects = reader.ReadUInt16();
    int Projectiles = reader.ReadUInt16();

    int maxID = Items + Outfits + Effects + Projectiles;
    int ID = 100;

    dataArray = (ItemData[])Array.CreateInstance(typeof(ItemData), maxID - ID);

    while ((ID < maxID))
    {
    ItemData itemData = new ItemData();
    itemData.ID = ID;
    bool _while = true;
    do
    {
    byte optByte = 0;
    optByte = reader.ReadByte();
    switch (optByte)
    {
    case Flag_Bank:
    itemData.isBank = true;
    itemData.Waypoints = reader.ReadUInt16();
    //ground speed
    break;
    case Flag_Clip:
    itemData.isClip = true;
    break;
    case Flag_Bottom:
    itemData.isBottom = true;
    break;
    case Flag_Top:
    itemData.isTop = true;
    break;
    case Flag_Container:
    itemData.isContainer = true;
    break;
    case Flag_Cumulative:
    itemData.isCumulative = true;
    break;
    case Flag_ForceUse:
    itemData.isForceUse = true;
    break;
    case Flag_MultiUse:
    itemData.isMultiUse = true;
    break;
    case Flag_Write:
    itemData.isWriteable = true;
    itemData.MaxTextLength = reader.ReadUInt16();
    break;
    case Flag_WriteOnce:
    itemData.isWriteableOnce = true;
    itemData.MaxTextLength = reader.ReadUInt16();
    break;
    case Flag_LiquidContainer:
    itemData.isLiquidContainer = true;
    break;
    case Flag_LiquidPool:
    itemData.isLiquidPool = true;
    break;
    case Flag_Unpass:
    itemData.isUnpassable = true;
    break;
    case Flag_Unmove:
    itemData.isUnmoveable = true;
    break;
    case Flag_Unsight:
    itemData.isUnsight = true;
    break;
    case Flag_Avoid:
    itemData.isAvoid = true;
    break;
    case Flag_Take:
    itemData.isTakeable = true;
    break;
    case Flag_Hang:
    itemData.isHangable = true;
    break;
    case Flag_HookSouth:
    itemData.isHookSouth = true;
    break;
    case Flag_HookEast:
    itemData.isHookEast = true;
    break;
    case Flag_Rotate:
    itemData.isRotateable = true;
    break;
    case Flag_Light:
    itemData.isLight = true;
    itemData.Brightness = reader.ReadUInt16();
    itemData.LightColor = reader.ReadUInt16();
    break;
    case Flag_DontHide:
    itemData.isDontHide = true;
    break;
    case Flag_Translucent:
    itemData.isTranslucent = true;
    break;
    case Flag_Shift:
    itemData.isDisplaced = true;
    itemData.DisplacementX = reader.ReadUInt16();
    itemData.DisplacementY = reader.ReadUInt16();
    break;
    case Flag_Height:
    itemData.isHeight = true;
    itemData.Elevation = reader.ReadUInt16();
    break;
    case Flag_LyingObject:
    itemData.isLyingObject = true;
    break;
    case Flag_AnimateAlways:
    itemData.isAnimateAlways = true;
    break;
    case Flag_Automap:
    itemData.isAutomap = true;
    itemData.isAutomapColor = reader.ReadUInt16();
    break;
    case Flag_LensHelp:
    itemData.isLensHelp = true;
    itemData.LensHelp = reader.ReadUInt16();
    break;
    case Flag_FullBank:
    itemData.isFullBank = true;
    break;
    case Flag_IgnoreLook:
    itemData.isIgnoreLook = true;
    break;
    case Flag_Clothes:
    itemData.isCloth = true;
    itemData.ClothSlot = reader.ReadUInt16();
    //head, torso, legs, feet, etc.
    break;
    case Flag_Market:
    itemData.isMarket = true;
    itemData.MarketCategory = (MarketCategory)reader.ReadUInt16();
    //see the MarketCategory enum above
    itemData.MarketTradeAs = reader.ReadUInt16();
    itemData.MarketShowAs = reader.ReadUInt16();

    //using the binary reader's ReadString() function returned the correctly lengthed string, but started a character early
    //eg. "gold coin" would say " gold coi"
    //to bypass this I just read the string length (first 2 bytes) then read that many bytes
    //but the string is iso-8859-1 encoded, so you have to decode it to get the actual string
    int MarketNameLength = reader.ReadUInt16();
    itemData.MarketName = System.Text.Encoding.GetEncoding("iso-8859-1").GetString(reader.ReadBytes(MarketNameLength ));

    itemData.MarketRestrictProfession = reader.ReadUInt16();
    itemData.MarketRestrictLevel = reader.ReadUInt16();
    break;
    case 255:
    _while = false;
    break;
    default:
    //MessageBox.Show("Invalid flag!: " + optByte.ToString());
    break;
    }
    } while (_while);

    itemData.Width = reader.ReadByte();
    itemData.Height = reader.ReadByte();
    if (itemData.Width > 1 | itemData.Height > 1)
    {
    itemData.ExactSize = reader.ReadByte();
    }

    itemData.Layers = reader.ReadByte();
    itemData.PatternWidth = reader.ReadByte();
    itemData.PatternHeight = reader.ReadByte();
    itemData.PatternDepth = reader.ReadByte();
    itemData.Phases = reader.ReadByte();

    int numSpr = itemData.Width * itemData.Height;
    numSpr *= itemData.Layers * itemData.PatternWidth;
    numSpr *= itemData.PatternHeight * itemData.PatternDepth;
    numSpr *= itemData.Phases;

    itemData.NumberOfSprites = numSpr;

    itemData.Sprites = (int[])Array.CreateInstance(typeof(int), itemData.NumberOfSprites);
    for (int i = 0; i <= itemData.NumberOfSprites - 1; i++)
    {
    itemData.Sprites[i] = reader.ReadUInt16();
    }

    dataArray[ID - 100] = itemData;
    ID += 1;
    }
    }
    }
    }[/code]

  8. #18
    Administrator
    Join Date
    Mar 2007
    Posts
    1,723

    RE: Tibia: Data File Structure

    I'm confused by your wording. Are you saying that the sprite Ids in my SprEx tool aren't matching up with the right item? Then this is a problem with my SprEx tool, and not the data file structure. I'll look in to it, thanks.

    EDIT - I done some testing and my SprEx tool returns the proper sprite Id, as I had programmed it to. The problem must lie in the value that you are getting in Cheat Engine, it must not be what you believe it to.

  9. #19
    Junior Member
    Join Date
    Dec 2007
    Posts
    18

    RE: Tibia: Data File Structure

    Sorry jo3, the error is in my C# code...

    In your structure ItemData the property MaxTextLength is a boolean...

  10. #20
    Administrator
    Join Date
    Mar 2007
    Posts
    1,723

    RE: Tibia: Data File Structure

    Quote Originally Posted by carteni
    In your structure ItemData the property MaxTextLength is a boolean...
    Thanks for seeing that. Fixed in original post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •