diff --git a/PokemonGo.RocketAPI/Client.cs b/PokemonGo.RocketAPI/Client.cs index 269a82b6c..ea2a53c1c 100644 --- a/PokemonGo.RocketAPI/Client.cs +++ b/PokemonGo.RocketAPI/Client.cs @@ -10,6 +10,7 @@ using PokemonGo.RocketAPI.Extensions; using PokemonGo.RocketAPI.Login; using static PokemonGo.RocketAPI.GeneratedCode.Response.Types; +using System.IO; namespace PokemonGo.RocketAPI { @@ -29,7 +30,16 @@ public class Client public Client(ISettings settings) { Settings = settings; - SetCoordinates(Settings.DefaultLatitude, Settings.DefaultLongitude, Settings.DefaultAltitude); + if (File.Exists(Directory.GetCurrentDirectory() + "\\Coords.txt")) + { + string latlngFromFile = File.ReadAllText(Directory.GetCurrentDirectory() + "\\Coords.txt"); + String[] latlng = latlngFromFile.Split(':'); + SetCoordinates(Convert.ToDouble(latlng[0]), Convert.ToDouble(latlng[1]), Settings.DefaultAltitude); + } + else + { + SetCoordinates(Settings.DefaultLatitude, Settings.DefaultLongitude, Settings.DefaultAltitude); + } //Setup HttpClient and create default headers HttpClientHandler handler = new HttpClientHandler() @@ -47,11 +57,19 @@ public Client(ISettings settings) "application/x-www-form-urlencoded"); } + + public void SaveLatLng(double lat, double lng) + { + string latlng = lat.ToString() + ":" + lng.ToString(); + File.WriteAllText(Directory.GetCurrentDirectory() + "\\Coords.txt", latlng); + } + private void SetCoordinates(double lat, double lng, double altitude) { CurrentLat = lat; CurrentLng = lng; CurrentAltitude = altitude; + SaveLatLng(lat, lng); } public async Task DoGoogleLogin()