Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bug in gpx where tasks were never called #1403

Merged
merged 2 commits into from
Jul 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions PoGo.NecroBot.Logic/Tasks/FarmPokestopsGPXTask.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region using directives
#region using directives

using System;
using System.Collections.Generic;
Expand All @@ -19,6 +19,7 @@ namespace PoGo.NecroBot.Logic.Tasks
{
public static class FarmPokestopsGpxTask
{
static DateTime lastTasksCall = DateTime.Now;
public static async Task Execute(ISession session, CancellationToken cancellationToken)
{
var tracks = GetGpxTracks(session);
Expand All @@ -27,6 +28,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
var maxTrk = tracks.Count - 1;
var curTrkSeg = 0;
var eggWalker = new EggWalker(1000, session);

while (curTrk <= maxTrk)
{
cancellationToken.ThrowIfCancellationRequested();
Expand Down Expand Up @@ -61,7 +63,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
var pokestopList = await GetPokeStops(session);
session.EventDispatcher.Send(new PokeStopListEvent { Forts = pokestopList });

while (pokestopList.Any())
while (pokestopList.Any()) // warning: this is never entered due to ps cooldowns from UseNearbyPokestopsTask
{
cancellationToken.ThrowIfCancellationRequested();

Expand Down Expand Up @@ -100,6 +102,11 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
{
await session.Inventory.RefreshCachedInventory();
}
}

if(DateTime.Now > lastTasksCall)
{
lastTasksCall = DateTime.Now.AddMilliseconds(Math.Min(session.LogicSettings.DelayBetweenPlayerActions, 3000));

await RecycleItemsTask.Execute(session, cancellationToken);

Expand Down Expand Up @@ -189,4 +196,4 @@ private static async Task<List<FortData>> GetPokeStops(ISession session)
return pokeStops.ToList();
}
}
}
}
2 changes: 1 addition & 1 deletion PoGo.NecroBot.Logic/Utils/DelayingUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static class DelayingUtils

public static void Delay(int delay, int defdelay)
{
if (delay > 0)
if (delay > defdelay)
{
float randomFactor = 0.3f;
int randomMin = (int)(delay * (1 - randomFactor));
Expand Down