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.
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.
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!
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!!
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'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.
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
I am not sure what does 'DistanceObjectId' or 'ItemCount' mean. Just follow the tileDef struct and you can find every item in the tile.
Do you guys happen to know what does data2 hold? It isn't stated anywhere.Code:struct objectData { int objectId; int data1; int data2; } struct tileDef { int stackedObjectCount; struct objectData[121]; int padding1; int padding2; }; struct tileDef map[2016];
Keep me updated regardless, and keep up the good work!
Last edited by mahatesh; 09-24-2015 at 05:45 PM. Reason: wording
I dont have any idea how to update these
For everyone who dont know what means the name of variables http://tibiaapi.googlecode.com/svn/t...s_1_1_map.htmlCode: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;
Last edited by arkes; 09-26-2015 at 03:48 PM.
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
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:
Your structures don't match the link about map layout - http://tibiaauto.net/ta_art_mapread.htmlCode: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; }
Note that in TileItem, its ID, then data, then data2. this struct DOES NOT hold count for the tile.Code:struct objectData { int objectId; int data1; int data2; } struct tileDef { int stackedObjectCount; struct objectData[121]; int padding1; int padding2; };
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.