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 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

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
Optimzing map reading - Page 2
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 27

Thread: Optimzing map reading

  1. #11
    Super Moderator klusbert's Avatar
    Join Date
    Dec 2007
    Posts
    1,201
    Code:
    private void UpdateTileNums()
    
         {
    
             int index = 0;
    
     
    
             int Adr = client.Memory.ReadInt32(Adresses.Map.TileNumberArray);
    
             for (byte z = 0; z < 8; z++)
    
             {
    
                 for (byte y = 0; y < 14; y++)
    
                 {
    
                     for (byte x = 0; x < 18; x++)
    
                     {
    
                         TileNumberArray[z, y, x] = client.Memory.ReadInt32(Adr + index);
    
                         index += 4;
    
     
    
                     }
    
                 }
    
             }
    
     
    
         }
    
         public IEnumerable<Tile> GetTilesSameFloor()
    
         {
    
             UpdateTileNums();
    
           
    
             Location Selfloc = client.PlayerLocation;
    
             int Index = 7 - Selfloc.Z;
    
             if (Index >= 0)
    
             {
    
                 //nothing 
    
             }
    
             else
    
             {
    
                 Index = 2;
    
             }
    
     
    
             for (byte y = 0; y < 14; y++)
    
             {
    
                 for (byte x = 0; x < 18; x++)
    
                 {
    
                     int tilenum =TileNumberArray[Index, y, x];
    
                     int adr = TileNumToMapAdress(tilenum);
    
                     Location loc = new Location(Selfloc.X + x - 8, Selfloc.Y + y -6, Selfloc.Z);
    
                     Tile t = new Tile(client, (uint)adr, (uint)tilenum, loc);
    
                     yield return t;
    
                    
    
                 }
    
             }
    
           
    
         }

    This is just great, this code works like a charm now you dont have to convert tilenums to memloc and memloc to worldloc. I should work faster and it should be 100% accurate. Since tibiaAPIs mapreading is not always 100%.

    http://i.imgur.com/LM9uTfq.jpg
    Attached Images Attached Images
    Last edited by klusbert; 03-21-2013 at 01:48 PM.
    How to find battlelist address --> http://tpforums.org/forum/thread-8146.html
    Updating addresses --> http://tpforums.org/forum/thread-8625.html
    DataReader --> http://tpforums.org/forum/thread-10387.html

  2. #12
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    Quote Originally Posted by klusbert View Post
    Code:
    private void UpdateTileNums()
    
         {
    
             int index = 0;
    
     
    
             int Adr = client.Memory.ReadInt32(Adresses.Map.TileNumberArray);
    
             for (byte z = 0; z < 8; z++)
    
             {
    
                 for (byte y = 0; y < 14; y++)
    
                 {
    
                     for (byte x = 0; x < 18; x++)
    
                     {
    
                         TileNumberArray[z, y, x] = client.Memory.ReadInt32(Adr + index);
    
                         index += 4;
    
     
    
                     }
    
                 }
    
             }
    
     
    
         }
    Nice job, klusbert.
    By the way, there's no need for this loop. You can accomplish the whole nested for loops in a single call to ReadProcessMemory and still get a speed boost.

  3. #13
    Super Moderator klusbert's Avatar
    Join Date
    Dec 2007
    Posts
    1,201
    true, but I think this shows more what is going on. But Do you think I will gain much by caching both tilenum array and tiles array?
    How to find battlelist address --> http://tpforums.org/forum/thread-8146.html
    Updating addresses --> http://tpforums.org/forum/thread-8625.html
    DataReader --> http://tpforums.org/forum/thread-10387.html

  4. #14
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    I made this simple test using the Stopwatch class.

    for each test, a single readprocessmemory call was ~ 2.75 MS faster than these multiple RPM calls. (just this for loop, not couning the tiles caching)

    tested in a for from 0 to 1000 and it gave me 2.9 sec difference. Since it isn't a very huge difference, it's totally up to you. (test made in a single tibia client)

  5. #15
    1) The code in the first post is to search player tile, but why? Since in this new structure the player tile is always the 116th.
    2) What are the constants "Addresses.Map.MaxTilesPerFloor" and "Addresses.Map.TileNumberOffsetCenter" ?
    3) Why in tibiaAPI "maxZ" is 8 since there are more floors than 8 ?
    Thx

  6. #16
    For client 10.21 pointer for structure of "tile indexes" is at 0x5EA640 and it seems to be always located before map pointer.

  7. #17
    Senior Member
    Join Date
    Jan 2012
    Posts
    417
    Did not you meant 0x5EA660 + base? Usually it's located at TilesPointer + 0x1C

  8. #18
    Yes, you are right Blequi, it is located at TilesPointer + 0x1C. TilesPointer - 0x4 is max tiles which is always 2016. My mistake, sorry.
    Last edited by pater; 11-05-2013 at 09:43 AM.

  9. #19
    Sorry for bumping, but this method is nice(Y). Now is there any way to get tile objects straight from this method?

  10. #20
    Senior Member
    Join Date
    Feb 2024
    Posts
    569

    High Rated Product Website

    Please try Google before asking about High Rated Product Guide 89dedbb

Posting Permissions

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