EverestAPI / Everest

Everest - Celeste Mod Loader / Mod API
https://everestapi.github.io/
MIT License
372 stars 81 forks source link

Handle NRE when attempting to load a non-existant room #583

Closed coloursofnoise closed 1 year ago

coloursofnoise commented 1 year ago

Renaming a room when the current session is in said room will crash with a NullReferenceException when loading the map.

Either the exception should be caught and a postcard displayed, or it should fallback to the starting room of the map.

Example error log with mod hooks trimmed:

Ver 1.4.0.0-xna [Everest: 3761-azure-491f9]
02/11/2023 16:22:11
System.NullReferenceException: Object reference not set to an instance of an object.
   at DMD<Celeste.Level::LoadLevel>(Level this, IntroTypes playerIntro, Boolean isFromLoader)
   at DMD<Celeste.LevelLoader::StartLevel>(LevelLoader this)
   at Celeste.LevelLoader.Update() in /home/vsts/work/1/s/Celeste.Mod.mm/Patches/LevelLoader.cs:line 248
   at DMD<Monocle.Engine::Update>(Engine this, GameTime gameTime)
   at Celeste.Celeste.Update(GameTime gameTime)
   at Microsoft.Xna.Framework.Game.Tick()
   at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
   at Microsoft.Xna.Framework.GameHost.OnIdle()
   at Microsoft.Xna.Framework.WindowsGameHost.RunOneFrame()
   at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
   at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at Microsoft.Xna.Framework.WindowsGameHost.Run()
   at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
   at Monocle.Engine.RunWithLogging() in /home/vsts/work/1/s/Celeste.Mod.mm/Patches/Monocle/Engine.cs:line 34
DemoJameson commented 1 year ago

Fixed in https://github.com/EverestAPI/Everest/pull/633