private void MemoryHandler_OnExceptionEvent(object sender, Logger logger, Exception ex) { if (sender is not MemoryHandler memoryHandler) { return; } // TODO: this should be handled in sharlayan; when we can detect character changes this will be updated/removed and placed in sharlayan if (ex.GetType() != typeof(OverflowException)) { return; } if (ex.StackTrace is null || !ex.StackTrace.Contains("ChatLogReader")) { return; } SharlayanConfiguration configuration = memoryHandler.Configuration; if (!this._workerSets.TryGetValue(configuration.ProcessModel.ProcessID, out WorkerSet workerSet)) { return; } workerSet.ChatLogWorker.StopScanning(); Task.Run( async() => { await Task.Delay(1000); workerSet.ChatLogWorker.Reset(); workerSet.ChatLogWorker.StartScanning(); }); }
internal static async Task Resolve(SharlayanConfiguration configuration) { if (_loading) { return; } _loading = true; await APIHelper.GetStatusEffects(_statusEffects, configuration); _loading = false; }
private void SetupSharlayanManager() { foreach (Process process in this._gameInstances) { SharlayanConfiguration sharlayanConfiguration = new SharlayanConfiguration { ProcessModel = new ProcessModel { Process = process, }, }; MemoryHandler handler = SharlayanMemoryManager.Instance.AddHandler(sharlayanConfiguration); handler.OnException += this.MemoryHandler_OnExceptionEvent; handler.OnMemoryHandlerDisposed += this.MemoryHandler_OnMemoryHandlerDisposedEvent; handler.OnMemoryLocationsFound += this.MemoryHandler_OnMemoryLocationsFoundEvent; } }
public static async Task <StructuresContainer> GetStructures(SharlayanConfiguration configuration) { string region = configuration.GameRegion.ToString().ToLowerInvariant(); string patchVersion = configuration.PatchVersion; string file = Path.Combine(configuration.JSONCacheDirectory, $"structures-{region}-{patchVersion}.json"); if (File.Exists(file) && configuration.UseLocalCache) { return(EnsureClassValues <StructuresContainer>(file)); } StructuresContainer structuresContainer = await APIResponseToClass <StructuresContainer>(file, $"{configuration.APIBaseURL}/structures/{region}/{patchVersion}.json"); return(structuresContainer); }
public static async Task <Signature[]> GetSignatures(SharlayanConfiguration configuration) { string region = configuration.GameRegion.ToString().ToLowerInvariant(); string patchVersion = configuration.PatchVersion; string file = Path.Combine(configuration.JSONCacheDirectory, $"signatures-{region}-{patchVersion}.json"); if (File.Exists(file) && configuration.UseLocalCache) { return(FileResponseToJSON <Signature[]>(file)); } string json = await APIResponseToJSON($"{configuration.APIBaseURL}/signatures/{region}/{patchVersion}.json"); Signature[] resolved = JsonConvert.DeserializeObject <Signature[]>(json, Constants.SerializerSettings); File.WriteAllText(file, JsonConvert.SerializeObject(resolved, Formatting.Indented, Constants.SerializerSettings), Encoding.UTF8); return(resolved); }
private void SetupSharlayanManager() { foreach (Process process in this._gameInstances) { SharlayanConfiguration sharlayanConfiguration = new SharlayanConfiguration { ProcessModel = new ProcessModel { Process = process, }, }; MemoryHandler handler = SharlayanMemoryManager.Instance.AddHandler(sharlayanConfiguration); handler.OnException += delegate { }; handler.OnMemoryLocationsFound += delegate(object sender, ConcurrentDictionary <string, MemoryLocation> memoryLocations, long processingTime) { foreach ((string key, MemoryLocation memoryLocation) in memoryLocations) { Console.WriteLine($"Process[{handler.Configuration.ProcessModel.ProcessID}] -> MemoryLocation Found -> {key} => {memoryLocation.GetAddress():X}"); } }; } }
public static async Task GetZones(ConcurrentDictionary <uint, MapItem> mapInfos, SharlayanConfiguration configuration) { // These ID's link to offset 7 in the old JSON values. // eg: "map id = 4" would be 148 in offset 7. // This is known as the TerritoryType value // - It maps directly to SaintCoins map.csv against TerritoryType ID string file = Path.Combine(configuration.JSONCacheDirectory, $"zones-{configuration.PatchVersion}.json"); if (File.Exists(file) && configuration.UseLocalCache) { EnsureDictionaryValues(mapInfos, file); } else { await APIResponseToDictionary(mapInfos, file, $"{configuration.APIBaseURL}/xivdatabase/{configuration.PatchVersion}/zones.json"); } }
public static async Task GetStatusEffects(ConcurrentDictionary <uint, StatusItem> statusEffects, SharlayanConfiguration configuration) { string file = Path.Combine(configuration.JSONCacheDirectory, $"statuses-{configuration.PatchVersion}.json"); if (File.Exists(file) && configuration.UseLocalCache) { EnsureDictionaryValues(statusEffects, file); } else { await APIResponseToDictionary(statusEffects, file, $"{configuration.APIBaseURL}/xivdatabase/{configuration.PatchVersion}/statuses.json"); } }