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 85

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 85

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
Map struct 10.81 - Page 2
Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 37

Thread: Map struct 10.81

  1. #11
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    Take a look at this post:
    http://tibiaauto.net/ta_art_mapread.html

    If you have any doubt after reading it tell me and I will explain you how to update all the values and how to read the structure.

  2. #12
    Junior Member
    Join Date
    Sep 2015
    Posts
    15
    Hey
    First, thanks Lolrapa, for the info!
    Second, arkes, if you ever do make progress, please share your findings here so others can enjoy them too!
    You use some functions in your printscreen (such as MapFromFile) which I would really like to know!

  3. #13
    Junior Member
    Join Date
    Sep 2015
    Posts
    15
    Ok, so I did some playing around:

    Assuming your 'Pointer' is currect, I managed to find my location in the tile array.

    Regardless of that, I noticed something strange! Each tileDef seems to now take up 368(170 in hex) bytes! I see that number in your 'step' variable, but it shows up as a decimal, and not hex.
    Using this new value, I was able to find my position in the array (using the old value - 168(dec), I was never on a whole number when looking for my location in the array).

    Now I can only assume that they increased the item limit on each tile, what with players being able to stack freely now. If they kept the old structure of the tile, each tile should now house up to 121(dec) items.

    I have no idea if that helps you in any way, but I hope it does!!

  4. #14
    my progress

    Code:
            public readonly static int Base = (int)Memory.Tibia.MainModule.BaseAddress;
    
            public readonly static int MapPointer = 0x773ADC + Base; // updated
    
            public static readonly int MaxTiles = 2016; // updated
    
            public static readonly int StepTile = 368; // updated
    
            public static  int DistanceObjectId = 116; // updated
    
            public static int ItemCount = 112; // updated

  5. #15
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    Quote Originally Posted by mahatesh View Post
    Ok, so I did some playing around:

    Assuming your 'Pointer' is currect, I managed to find my location in the tile array.

    Regardless of that, I noticed something strange! Each tileDef seems to now take up 368(170 in hex) bytes! I see that number in your 'step' variable, but it shows up as a decimal, and not hex.
    Using this new value, I was able to find my position in the array (using the old value - 168(dec), I was never on a whole number when looking for my location in the array).

    Now I can only assume that they increased the item limit on each tile, what with players being able to stack freely now. If they kept the old structure of the tile, each tile should now house up to 121(dec) items.

    I have no idea if that helps you in any way, but I hope it does!!
    I've been idle from programming some time but I think that's strange.... I will look into it today noon, but I really don't think they changed this.

    To find your position in this map there is a much better and much faster alternative, Tibia has two maps in memory, making the rigth math you can tell your position in this map in O(1) (Without Looping)
    I'll show how to do when I come home today.

  6. #16
    Junior Member
    Join Date
    Sep 2015
    Posts
    15
    So for those of you who didn't know, there is a working bot for 10.81 - https://github.com/Wisling/tibiaauto

    It's written in C++ (and couldn't be designed any worse, structure-wise), but since it is updated, you can look up addresses there. I took me a while to find anything in there, as there is no 'addresses' class or anything, but a good Ctrl+F will net you some profit

    Quote Originally Posted by arkes View Post
    my progress

    Code:
            public readonly static int Base = (int)Memory.Tibia.MainModule.BaseAddress;
    
            public readonly static int MapPointer = 0x773ADC + Base; // updated
    
            public static readonly int MaxTiles = 2016; // updated
    
            public static readonly int StepTile = 368; // updated
    
            public static  int DistanceObjectId = 116; // updated
    
            public static int ItemCount = 112; // updated
    I am not sure what does 'DistanceObjectId' or 'ItemCount' mean. Just follow the tileDef struct and you can find every item in the tile.

    Code:
    struct objectData
    {
      int objectId;
      int data1;
      int data2;
    }
    
    struct tileDef
    {
      int stackedObjectCount;
      struct objectData[121];
      int padding1;
      int padding2;
    };
    
    struct tileDef map[2016];
    Do you guys happen to know what does data2 hold? It isn't stated anywhere.

    Keep me updated regardless, and keep up the good work!
    Last edited by mahatesh; 09-24-2015 at 05:45 PM. Reason: wording

  7. #17
    I dont have any idea how to update these

    Code:
            public static readonly int StepTileObject = 124;
    
            public static readonly int DistanceTileObjects = 160;
    
            public static readonly int DistanceObjectData = 112;
    
            public static readonly int DistanceObjectDataEx = 120;
    
            public static readonly int TileOrder = 116;
    For everyone who dont know what means the name of variables http://tibiaapi.googlecode.com/svn/t...s_1_1_map.html
    Last edited by arkes; 09-26-2015 at 03:48 PM.

  8. #18
    Junior Member
    Join Date
    Sep 2015
    Posts
    15
    Quote Originally Posted by arkes View Post
    I dont have any idea how to update these

    Code:
            public static readonly int StepTileObject = 124;
    
            public static readonly int DistanceTileObjects = 160;
    
            public static readonly int DistanceObjectData = 112;
    
            public static readonly int DistanceObjectDataEx = 120;
    
            public static readonly int TileOrder = 116;
    For everyone who dont know what means the name of variables http://tibiaapi.googlecode.com/svn/t...s_1_1_map.html
    Well, after reading the description:
    Wouldn't StepTileObject just be SizeOf(objectData) = 12?
    DistanceTileObjects should stay 4, seeing how tileDef still only has 1 int before the object array (how did you get 160? are you counting backwards, as in, from the END of memory?)
    DistanceObjectData should stay 4, since objectData is the same
    DistanceObjectDataEx hould stay 8, since objectData is the same
    TileOrder does not appear in the link, so I can't tell what it even means...

    It looks like the values you pasted and the values you linked differ GREATLY, but from what I see, none of them needs update (aside from TileOrder, since I don't know what that is)
    Last edited by mahatesh; 09-26-2015 at 09:05 PM. Reason: spelling

  9. #19
    If anyone need here is reading whole structure from memory then cast on maptype (language C#)

    Code:
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace MapReader
    {
        class Program
        {
    
            struct TileItem
            {
                public UInt32 count;
    
                public UInt32 id;
    
                [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
                public UInt32[] padding;
            }
    
            struct Tile
            {
                public Int32 objectCount;
    
                [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)]
                public UInt32[] padding;
    
                public TileItem ground;
    
                [MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)]
                public TileItem[] items;
            }
    
            struct Map //  OK
            {
                [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2016)]
                public Tile[] tiles;
            };
    
            public static object GetObjectFromBytes(byte[] buffer, Type objType)
            {
                object obj = null;
                if ((buffer != null) && (buffer.Length > 0))
                {
                    IntPtr ptrObj = IntPtr.Zero;
                    try
                    {
                        int objSize = Marshal.SizeOf(objType);
                        if (objSize > 0)
                        {
                            if (buffer.Length < objSize)
                                throw new Exception(String.Format("Buffer smaller than needed for creation of object of type {0}", objType));
    
                            ptrObj = Marshal.AllocHGlobal(objSize);
    
                            if (ptrObj != IntPtr.Zero)
                            {
                                Marshal.Copy(buffer, 0, ptrObj, objSize);
                                obj = Marshal.PtrToStructure(ptrObj, objType);
                            }
                            else
                                throw new Exception(String.Format("Couldn't allocate memory to create object of type {0}", objType));
                        }
                    }
                    finally
                    {
                        if (ptrObj != IntPtr.Zero)
                            Marshal.FreeHGlobal(ptrObj);
                    }
                }
                return obj;
            }
    
            static void Main(string[] args)
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
    
                int MapPointer = Memory.ReadInt32(Addresses.MapPointer);
                int PlayerId = Memory.ReadInt32(Addresses.Id);
    
    
                byte[] map = Memory.ReadBytes(MapPointer, (uint)Marshal.SizeOf(typeof(Map)));
    
                Map mapa = new Map();
                mapa = (Map)GetObjectFromBytes(map, typeof(Map));
    
                for (int i = 0; i < 2016; i++ )
                {
                    if (mapa.tiles[i].objectCount > 0)
                    {
                        if (mapa.tiles[i].items[0].id == 99 && mapa.tiles[i].items[0].count == PlayerId)
                        {
                            Tile playertile = new Tile();
                            playertile = mapa.tiles[i];
    
                            Console.WriteLine(playertile.ground.id.ToString());
    
                            for (int x = 0; x < playertile.items.Count(); x++)
                                Console.WriteLine(playertile.items[x].id.ToString() + " - COUNT: " + playertile.items[x].count.ToString());
    
                        }
                    }
                }
    
                    stopwatch.Stop();
                Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed);
    
    
                Console.WriteLine("Done");
                Console.ReadLine();
            }
        }
    }

  10. #20
    Junior Member
    Join Date
    Sep 2015
    Posts
    15
    Quote Originally Posted by arkes View Post
    If anyone need here is reading whole structure from memory then cast on maptype (language C#)

    Code:
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace MapReader
    {
        class Program
        {
    
            struct TileItem
            {
                public UInt32 count;
    
                public UInt32 id;
    
                [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
                public UInt32[] padding;
            }
    
            struct Tile
            {
                public Int32 objectCount;
    
                [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)]
                public UInt32[] padding;
    
                public TileItem ground;
    
                [MarshalAs(UnmanagedType.ByValArray, SizeConst = 9)]
                public TileItem[] items;
            }
    
            struct Map //  OK
            {
                [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2016)]
                public Tile[] tiles;
            };
    
            public static object GetObjectFromBytes(byte[] buffer, Type objType)
            {
                object obj = null;
                if ((buffer != null) && (buffer.Length > 0))
                {
                    IntPtr ptrObj = IntPtr.Zero;
                    try
                    {
                        int objSize = Marshal.SizeOf(objType);
                        if (objSize > 0)
                        {
                            if (buffer.Length < objSize)
                                throw new Exception(String.Format("Buffer smaller than needed for creation of object of type {0}", objType));
    
                            ptrObj = Marshal.AllocHGlobal(objSize);
    
                            if (ptrObj != IntPtr.Zero)
                            {
                                Marshal.Copy(buffer, 0, ptrObj, objSize);
                                obj = Marshal.PtrToStructure(ptrObj, objType);
                            }
                            else
                                throw new Exception(String.Format("Couldn't allocate memory to create object of type {0}", objType));
                        }
                    }
                    finally
                    {
                        if (ptrObj != IntPtr.Zero)
                            Marshal.FreeHGlobal(ptrObj);
                    }
                }
                return obj;
            }
    
            static void Main(string[] args)
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
    
                int MapPointer = Memory.ReadInt32(Addresses.MapPointer);
                int PlayerId = Memory.ReadInt32(Addresses.Id);
    
    
                byte[] map = Memory.ReadBytes(MapPointer, (uint)Marshal.SizeOf(typeof(Map)));
    
                Map mapa = new Map();
                mapa = (Map)GetObjectFromBytes(map, typeof(Map));
    
                for (int i = 0; i < 2016; i++ )
                {
                    if (mapa.tiles[i].objectCount > 0)
                    {
                        if (mapa.tiles[i].items[0].id == 99 && mapa.tiles[i].items[0].count == PlayerId)
                        {
                            Tile playertile = new Tile();
                            playertile = mapa.tiles[i];
    
                            Console.WriteLine(playertile.ground.id.ToString());
    
                            for (int x = 0; x < playertile.items.Count(); x++)
                                Console.WriteLine(playertile.items[x].id.ToString() + " - COUNT: " + playertile.items[x].count.ToString());
    
                        }
                    }
                }
    
                    stopwatch.Stop();
                Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed);
    
    
                Console.WriteLine("Done");
                Console.ReadLine();
            }
        }
    }
    Look at these definitions:

    Code:
    struct TileItem
            {
                public UInt32 count;
    
                public UInt32 id;
    
                public UInt32[] padding;
            }
    
            struct Tile
            {
                public Int32 objectCount;
    
                public UInt32[] padding;
    
                public TileItem ground;
    
                public TileItem[] items;
            }
    Your structures don't match the link about map layout - http://tibiaauto.net/ta_art_mapread.html

    Code:
    struct objectData
    {
      int objectId;
      int data1;
      int data2;
    }
    
    struct tileDef
    {
      int stackedObjectCount;
      struct objectData[121];
      int padding1;
      int padding2;
    };
    Note that in TileItem, its ID, then data, then data2. this struct DOES NOT hold count for the tile.
    Tile is also in disarray - should be: count, array of 121 TileItem, padding, padding
    Last edited by mahatesh; 09-27-2015 at 03:23 PM.

Posting Permissions

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