private bool IsConfigReady() { if (RequireConfigFileUpdate()) { try { var jsonString = File.ReadAllText(_settings.ScriptPath); _game = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize <Game>(jsonString); } catch (Exception e) { Log.Error($"Could not open split config file, check config file settings: {e.Message}"); _settings.ResetASLSettings(); return(false); } try { if (Version.Parse(_game.MinVersion).CompareTo(Factory.CURRENT_VERSION) < 0) { throw new Exception($"Newer version of the auto splitter is required"); } _autostart = _game.Autostart; SetSplitList(); CheckRunnableSetting(); if (_autostart != null) { Log.Info($"auto start split detected: {_autostart.DebugDescription()}"); } Log.Info($"{_splits.Count} splits detected:"); foreach (var split in _splits) { Log.Info($"- {split.DebugDescription()}"); } } catch (Exception e) { Log.Error($"Splits could not be parsed: {e}"); _settings.ResetASLSettings(); return(false); } _fs_watcher.Path = Path.GetDirectoryName(_settings.ScriptPath); _fs_watcher.Filter = Path.GetFileName(_settings.ScriptPath); _fs_watcher.EnableRaisingEvents = true; _do_reload = false; } return(!_do_reload); }
private void ScriptCleanup() { if (Script == null) { return; } try { Script.RunShutdown(_state); } catch (Exception ex) { Log.Error(ex); } finally { _settings.SetGameVersion(null); _settings.ResetASLSettings(); // Script should no longer be used, even in case of error // (which the ASL shutdown method may contain) Script = null; } }