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 85
How you solve problem of resending packets
Results 1 to 5 of 5

Thread: How you solve problem of resending packets

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Posts
    9

    How you solve problem of resending packets

    For example, when I wrote auto lotter, I call function which moves items from external container to our container. And it works, but how you detect if function should be called again? Because something happened and item was not moved? In my current code I'm calling this function as long as item is in external backpack, looter is called every time when bot loops, so delay between is like 20ms and often I see message "Its not possible" - packet to move item was already sent but local memory doesn't reflect that, so function is called again.

    How you solve this problem?

  2. #2
    I smell a complete lack of synchronization. Sending and receiving a packet should be treated as a completely atomic operations from point of view of bot creator. Since you are calling your move item function which under the hood results in the sending of a packet, you should be able to switch or trigger part of your logic layer into the "listening" state and grab a result of your operation (move item) from the incoming packet. There is of course a more complex logic needed (assuming you send packet A (move item), packet B (walk), and you get a reply for packet A (item can't be moved - not possible), packet B(can't walk - not possible) - so you are required to figure out for which sent packet you get a reply.

    Basically talking, you should have a mechanism which will actually tell you "re-send this packet again" based on any logic which can be determined from I/O packets.

  3. #3
    Junior Member
    Join Date
    Feb 2011
    Posts
    9
    Yeah, I don't have a synchronisation because I've been thinking that if I call internal Tibia functions, then I don't need to care about that (Tibia will care). Do I need to monitor what is Tibia receiving? Currently I rely on memory state to synchronise and it just works, but has its own disadvantages (like delay between function call (internal Tibia function mapped by pointer), packed send, packet receive and memory update). How to do in this case? Because as I understand you say about calling send and recv, and its completly fine in case you deal with packets, I'm not dealing with packets.

  4. #4
    The simplest possible way of synchronizing with the Tibia client internals would be hooking PeekMessage function - it would assure you, that Tibia client internals will not interrupt in any way your functions. I am sorry as I was not clear enough about sending and receiving packets (I picked up the lowest possible layer of the abstraction) - what I meant is that there are places which can tell you precisely what has happened. Relaying on the memory state is neither sufficient nor safe. Imagine you spawn a thread to "monitor" a state of any memory location - than you must have kind of synchronization between your and the other threads manipulating monitored memory location.

  5. #5
    Senior Member Lolrapa's Avatar
    Join Date
    Mar 2014
    Posts
    125
    Even if you sychronize correctly with peekMessge you will have to find a way to check if the item was really mooved, I think that any way you do this you'll have to wait, since the loop exeuction of the bot is much faster than the response of the game to the actual mooving.

    Maybe you can find a way to get a response form the server, then you moove an item and wait until 'item mooved' or 'item can't be mooved'
    or you just wait a random amount of time (the necessary to perform the action) and check again if the item was or mooved or not.

Posting Permissions

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