From 9b1acde11fd24fafce3d13e4a83982f60cd3ddd4 Mon Sep 17 00:00:00 2001 From: DemoJameson Date: Thu, 7 Sep 2023 17:15:07 +0800 Subject: [PATCH] Fix game crashes when everest settings file is corrupted --- Celeste.Mod.mm/Mod/Core/CoreModuleSettings.cs | 7 ++++++- Celeste.Mod.mm/Mod/Everest/ButtonBinding.cs | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Celeste.Mod.mm/Mod/Core/CoreModuleSettings.cs b/Celeste.Mod.mm/Mod/Core/CoreModuleSettings.cs index 2c7e9e802..83506f22b 100644 --- a/Celeste.Mod.mm/Mod/Core/CoreModuleSettings.cs +++ b/Celeste.Mod.mm/Mod/Core/CoreModuleSettings.cs @@ -296,8 +296,13 @@ public string CurrentBranch { set => _CurrentBranch = value is "dev" or "beta" or "stable" ? "updater_src_" + value : value; // branch names were changed at some point } + private Dictionary _LogLevels = new Dictionary(); + [SettingIgnore] - public Dictionary LogLevels { get; set; } = new Dictionary(); + public Dictionary LogLevels { + get => _LogLevels; + set => _LogLevels = value ?? new Dictionary(); + } [SettingSubHeader("MODOPTIONS_COREMODULE_MENUNAV_SUBHEADER")] [SettingInGame(false)] diff --git a/Celeste.Mod.mm/Mod/Everest/ButtonBinding.cs b/Celeste.Mod.mm/Mod/Everest/ButtonBinding.cs index c90687635..5ae91e93f 100644 --- a/Celeste.Mod.mm/Mod/Everest/ButtonBinding.cs +++ b/Celeste.Mod.mm/Mod/Everest/ButtonBinding.cs @@ -18,17 +18,17 @@ public class ButtonBinding { public List Buttons { get => Binding.Controller; - set => Binding.Controller = value; + set => Binding.Controller = value ?? new List(); } public List Keys { get => Binding.Keyboard; - set => Binding.Keyboard = value; + set => Binding.Keyboard = value ?? new List(); } public List MouseButtons { get => ((patch_Binding) Binding).Mouse; - set => ((patch_Binding) Binding).Mouse = value; + set => ((patch_Binding) Binding).Mouse = value ?? new List(); } private Binding _Binding;