From 7d0559b781d24784d04bfac3e7ceeebea9de538a Mon Sep 17 00:00:00 2001 From: corkr900 <109830893+corkr900@users.noreply.github.com> Date: Sat, 10 Feb 2024 12:00:01 -0600 Subject: [PATCH 1/2] Don't throw frivolous exceptions Previously, an exception was thrown and caught every time the player dies. This is bad for performance and messes with debugging efforts that involve breaking when a handled exception is thrown. With this change, system behavior does not change in an observable way, but an exception is not thrown in the process. --- _Code/Entities/Spawnpoints.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_Code/Entities/Spawnpoints.cs b/_Code/Entities/Spawnpoints.cs index 3143a1f..477b0a8 100644 --- a/_Code/Entities/Spawnpoints.cs +++ b/_Code/Entities/Spawnpoints.cs @@ -160,8 +160,8 @@ private static void Player_Added(On.Celeste.Player.orig_Added orig, Player self, if (scene is Level level) { try { LevelData l = level.Session.MapData.Levels.First(_l => _l.Name == level.Session.Level); - var e = l.Entities.First(_e => trueSpawnPoints.Contains(_e.Name) && _e.Position == self.Position); - if (e.Bool("forceFacing", true)) + var e = l.Entities.FirstOrDefault(_e => trueSpawnPoints.Contains(_e.Name) && _e.Position == self.Position); + if (e != null && e.Bool("forceFacing", true)) self.Facing = e.Bool("flipX", false) ? Facings.Left : Facings.Right; return; From 106741ef2c1486a54ae43b6be2ed82b4e5f7fdc5 Mon Sep 17 00:00:00 2001 From: corkr900 <109830893+corkr900@users.noreply.github.com> Date: Sat, 10 Feb 2024 12:01:25 -0600 Subject: [PATCH 2/2] Fix crash on hot reload Previously, there was a "Key is already present in the dictionary" crash when hot-reloading VivHelper. Added guardrails to prevent that error and safely reload the module. --- .../CustomDashStateCh.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/_Code/Module, Extensions, Etc/CustomDashStateCh.cs b/_Code/Module, Extensions, Etc/CustomDashStateCh.cs index 5ecaeb7..7920d3c 100644 --- a/_Code/Module, Extensions, Etc/CustomDashStateCh.cs +++ b/_Code/Module, Extensions, Etc/CustomDashStateCh.cs @@ -258,6 +258,9 @@ public Vector2 CustomDashDir(Vector2 pDashDir, Vector2 pSpeed) { } public static void LoadPresets() { + if (presetCustomBoosterStates.ContainsKey("Default")) { + presetCustomBoosterStates.Remove("Default"); + } presetCustomBoosterStates.Add("Default", new EntityData { Values = new Dictionary { @@ -267,6 +270,9 @@ public static void LoadPresets() { {"ColorSet", "000000,8cf7cf,4acfc6,1c7856,0e4a36,172b21,0e1c15,ffffff,291c33" } } }); + if (presetCustomBoosterStates.ContainsKey("Superdash")) { + presetCustomBoosterStates.Remove("Superdash"); + } presetCustomBoosterStates.Add("Superdash", new EntityData { Values = new Dictionary { @@ -278,6 +284,9 @@ public static void LoadPresets() { {"ColorSet", "000000,5cd4ff,5ca6e5,005c7b,003146,192d33,191922,ffffff,291c33" }, } }); + if (presetCustomBoosterStates.ContainsKey("FragileDash")) { + presetCustomBoosterStates.Remove("FragileDash"); + } presetCustomBoosterStates.Add("FragileDash", new EntityData { Values = new Dictionary { @@ -287,6 +296,9 @@ public static void LoadPresets() { {"ColorSet", "000000,ffffa7,b2ef5f,84912e,555f1f,3e3e28,2e2e1f,ffffff,291c33" }, } }); + if (presetCustomBoosterStates.ContainsKey("HeldDash")) { + presetCustomBoosterStates.Remove("HeldDash"); + } presetCustomBoosterStates.Add("HeldDash", new EntityData { Values = new Dictionary { @@ -297,6 +309,9 @@ public static void LoadPresets() { {"ColorSet", "000000,f1ceab,e5a565,9c5b1a,5f3f10,3d230a,271707,ffffff,291c33" }, } }); + if (presetCustomBoosterStates.ContainsKey("DoubleSpeed")) { + presetCustomBoosterStates.Remove("DoubleSpeed"); + } presetCustomBoosterStates.Add("DoubleSpeed", new EntityData { Values = new Dictionary { @@ -306,6 +321,9 @@ public static void LoadPresets() { {"ColorSet", "000000,ceffff,62ffff,16ad75,006241,0e2f1e,00160b,ffffff,291c33" }, } }); + if (presetCustomBoosterStates.ContainsKey("HeldSuperdash")) { + presetCustomBoosterStates.Remove("HeldSuperdash"); + } presetCustomBoosterStates.Add("HeldSuperdash", new EntityData { Values = new Dictionary {