Repository: PokemonGoF/PokemonGo-Bot

Issue:
Loitering does not seem to work properly
<!--

STOP ! ! !

Read the following before creating anything (or you will have your issue/feature request closed without notice)

1. Please only create an ISSUE or a FEATURE REQUEST - don't mix the two together in one item
2. For a Feature Request please only fill out the FEATURE REQUEST section
3. For a Issue please only fill out the ISSUE section
4. Issues are NOT to be used for help/config problems/support - use the relevant slack channels as per the README
5. Provide a good summary in the title, don't just write problem, or awesome idea!
6. Delete all irrelevant sections not related to your issue/feature request (including this top section)

===============ISSUE SECTION===============

Before you create an Issue, please check the following:

1. Have you validated that your config.json is valid JSON? Use http://jsonlint.com/ to check.
2. Have you [searched our issue tracker](https://github.com/PokemonGoF/PokemonGo-Bot/issues?q=is%3Aissue+sort%3Aupdated-desc) to see if the issue already exists? If so, comment on that issue instead rather than creating a new issue.
3. Are you running on the `master` branch? We work on the `dev` branch and then add that functionality to `master` when it is stable. Your issue may be fixed on `dev` and there is no need for this issue, just wait and it will eventually be merged to `master`.
4. All Issue sections MUST be completed to help us determine the actual problem and find its cause
-->
### Expected Behavior

<!-- Tell us what you expect to happen -->

Run the bot, go to the next point as in my path file, then, while loitering, move to forts, spin the pokestop and catch pokemons.
### Actual Behavior

<!-- Tell us what is happening -->

only while is following a path spin the pokestops, while is loitering it does nothing.
### Your FULL config.json (remove your username, password, gmapkey and any other private info)

<!-- Provide your FULL config file, feel free to use services such as pastebin.com to reduce clutter -->

http://pastebin.com/HDWecKDg
### Output when issue occurred

<!-- Provide a reasonable sample from your output log (not just the error message), feel free to use services such as pastebin.com to reduce clutter -->

http://pastebin.com/2fY2XXBC
in the line 40 and 426 start to loiter.
### Steps to Reproduce

<!-- Tell us the steps you have taken to reproduce the issue -->

./run.sh
### Other Information

OS: Ubuntu 16.04

<!-- Tell us what Operating system you're using --> 

Branch: master

<!-- dev or master --> 

Git Commit: a8ee31256d412413b107cce81b62059634e8c802

<!-- run 'git log -n 1 --pretty=format:"%H"' --> 

Python Version: Python 2.7.12

<!-- run 'python -V' and paste it here) --> 

Any other relevant files/configs (eg: path files) 

<!-- Anything else which may be of relevance -->

path file
[
    {"location": "40.7814675, -73.9741015, 33", "loiter": 300},
  {"location": "40.7795502, -73.9632225, 46", "loiter": 300},
  {"location": "40.7739931, -73.9665484, 23", "loiter": 300},
  {"location": "40.7741881, -73.9707756, 25", "loiter": 300},
  {"location": "40.7757805, -73.9717841, 26", "loiter": 300},
  {"location": "40.7772429, -73.9712047, 29", "loiter": 300},
  {"location": "40.7678016, -73.9717411, 18", "loiter": 300},
  {"location": "40.7663878, -73.9732003, 21", "loiter": 300},
  {"location": "40.7647626, -73.9732003, 32", "loiter": 300},
  {"location": "40.7653802, -73.9750671, 26", "loiter": 300},
  {"location": "40.7665015, -73.9748954, 14", "loiter": 300},
  {"location": "40.7762842, -73.9740157, 32", "loiter": 300}
]

<!-- ===============END OF ISSUE SECTION=============== -->

<!-- Note: Delete these lines and everything BELOW if creating an Issue -->



Discussion:
#5416 

You want to loiter but also walk around? Makes no sense. The whole point of "loiter" is to have your bot wait (loiter) at a pokestop if it's lured. You can't do that AND walk somewhere else.

@Gobberwart The actual behavior, happens after the update from 11123a82cb18c172a262dc9e46e7b2c175666828 to a8ee31256d412413b107cce81b62059634e8c802.
As is documented [here](https://github.com/PokemonGoF/PokemonGo-Bot/blob/master/docs/configuration_files.md#followpath-settings) the loiter field indicates the number of seconds that the bot loiter after reaching a point, during that time, the next Task -in the task list- is executed. The next task, in my configuration file, is MoveToFort, and, as expected, when loitering the bot should move to forts and catch pokemons, as it happens in 11123a82cb18c172a262dc9e46e7b2c175666828.


Resolving patch:
diff --git a/pokemongo_bot/cell_workers/follow_path.py b/pokemongo_bot/cell_workers/follow_path.py
--- a/pokemongo_bot/cell_workers/follow_path.py
+++ b/pokemongo_bot/cell_workers/follow_path.py
@@ -18,7 +18,7 @@
 from datetime import datetime as dt, timedelta
 
 STATUS_MOVING = 0
-STATUS_LOITERING = 1
+STATUS_WANDERING = 1
 STATUS_FINISHED = 2
  
 class FollowPath(BaseTask):
@@ -28,7 +28,7 @@ def initialize(self):
         self._process_config()
         self.points = self.load_path()
         self.status = STATUS_MOVING
-        self.loiter_end_time = 0
+        self.wander_end_time = 0
         self.distance_unit = self.bot.config.distance_unit
         self.append_unit = False
 
@@ -139,12 +139,12 @@ def endLaps(self):
         self.bot.login()
 
     def work(self):
-        # If done or loitering allow the next task to run
+        # If done or wandering allow the next task to run
         if self.status == STATUS_FINISHED:
             return WorkerResult.SUCCESS
 
-        if self.status == STATUS_LOITERING and time.time() < self.loiter_end_time:
-            return WorkerResult.RUNNING
+        if self.status == STATUS_WANDERING and time.time() < self.wander_end_time:
+            return WorkerResult.SUCCESS
 
         last_lat, last_lng, last_alt = self.bot.position
 
@@ -190,12 +190,14 @@ def work(self):
             }
         )
         
-        if (self.bot.config.walk_min > 0 and is_at_destination) or (self.status == STATUS_LOITERING and time.time() >= self.loiter_end_time):
-            if "loiter" in point and self.status != STATUS_LOITERING:
-                self.logger.info("Loitering for {} seconds...".format(point["loiter"]))
-                self.status = STATUS_LOITERING
-                self.loiter_end_time = time.time() + point["loiter"]
-                return WorkerResult.RUNNING
+        if (self.bot.config.walk_min > 0 and is_at_destination) or (self.status == STATUS_WANDERING and time.time() >= self.wander_end_time):
+            if "loiter" in point:
+                self.logger.warning("'loiter' is obsolete, please change to 'wander' in {}".format(self.path_file))
+            if "wander" in point and self.status != STATUS_WANDERING:
+                self.logger.info("Wandering for {} seconds...".format(point["wander"]))
+                self.status = STATUS_WANDERING
+                self.wander_end_time = time.time() + point["wander"]
+                return WorkerResult.SUCCESS
             if (self.ptr + 1) == len(self.points):
                 if self.path_mode == 'single':
                     self.status = STATUS_FINISHED


Test patch: