Before reading this, I assume you have at least some knowledge about the map structure. It's preferable that you have read vanitas' article on map reading over at tibiaauto.net (archived link here: http://web.archive.org/web/201201291...t_mapread.html).
Currently the way bots and other tools read the map is quite inefficient, i.e. to read the player tile most, if not all, code out there uses a bruteforce tactic; read all available tiles until the player is found.
Today I will show you how to read tiles in a smarter way, using information that haven't been discovered yet as far as I know.
It all starts with a pointer, which for the current version of Tibia (9.81) can be found at 0x005DA5E0 (+ base address).
This pointer points to a structure containing tile numbers. These tile numbers change as the player moves, effectively removing any necessities for centralizing memory locations and heavily reducing the amount of WinAPI calls necessary to find the same information.
The structure contains 2016 unsigned integers, exactly how many tiles there are in the map structure.
The player's tile can always be found at the 116th tile of a floor. Keep in mind that each tile number in this structure is 4 bytes long.
Here's a snippet to find it:
Doing this reduces the max amount of tiles read from 2016 to 8. Quite an improvement!Code:uint id = this.Client.Player.ID;
int address = this.Client.Memory.ReadInt32(this.Client.Addresses.Map.TileNumberPointer);
for (int i = 0; i < this.Client.Addresses.Map.MaxZ; i++)
{
int tileNumber = this.Client.Memory.ReadInt32(address +
(this.Client.Addresses.Map.MaxTilesPerFloor * i * 4) +
this.Client.Addresses.Map.TileNumberOffsetCenter);
Objects.Tile t = this.CachedTiles[tileNumber];
t.UpdateObjects();
if (!t.ContainsCreature(id)) continue;
t.WorldLocation = this.Client.Player.Location;
t.RealMemoryLocation = this.TileNumberToMemoryLocation(t.TileNumber, t);
t.MemoryLocation = this.CentralizeMemoryLocation(t.RealMemoryLocation, t);
return t;
}
Using the information described in vanitas' article, you can also get world locations and tiles other than the player's through this.
Happy hacking! :)