NoneGiven/MphRead

Room renderer crashes when launching a room with multiple players in adventure mode

AlaryVanEeckhout opened this issue · 2 comments

Hi, I am on Windows 11 and I downloaded the 0.23.3.0 win version of MphRead.
I drag-and-dropped the AMHE1 version of Metroid Prime Hunters into the program to extract the game files.

So I was in Game mode: auto-select (Adventure or Battle) and I tried to launch single player rooms with multiple players and the program crashes with an error like this:

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at MphRead.Entities.PlayerEntity.CloseDialogs() in D:\mph_build\MphRead\Entities\Players\PlayerDialog.cs:line 414
   at MphRead.Entities.PlayerEntity.Spawn(Vector3 pos, Vector3 facing, Vector3 up, NodeRef nodeRef, Boolean respawn) in D:\mph_build\MphRead\Entities\Players\PlayerEntity.cs:line 869
   at MphRead.Entities.PlayerEntity.ProcessPlayer() in D:\mph_build\MphRead\Entities\Players\PlayerProcess.cs:line 166
   at MphRead.Entities.PlayerEntity.Process() in D:\mph_build\MphRead\Entities\Players\PlayerProcess.cs:line 17
   at MphRead.Scene.UpdateScene() in D:\mph_build\MphRead\Renderer.cs:line 2607
   at MphRead.Scene.OnUpdateFrame() in D:\mph_build\MphRead\Renderer.cs:line 1144
   at MphRead.RenderWindow.OnRenderFrame(FrameEventArgs args) in D:\mph_build\MphRead\Renderer.cs:line 4741
   at OpenTK.Windowing.Desktop.GameWindow.Run()
   at MphRead.Menu.ShowMenuPrompts() in D:\mph_build\MphRead\Menu.cs:line 712
   at MphRead.Program.Main(String[] args) in D:\mph_build\MphRead\Program.cs:line 28

From what I understand, Adventure mode was automatically selected, since it's a single player room.
At the same time, spawning multiple players only seems to crash the program when in Adventure mode.

So, when I launch the rooms with Battle mode explicitly, It works... Unless I am using the debug version of the program, where for most rooms it will crash with an error like this one:

Process terminated. Assertion failed.
   at MphRead.Entities.DoorEntity..ctor(DoorEntityData data, String nodeName, Scene scene, Int32 targetRoomId) in D:\mph_build\MphRead\Entities\DoorEntity.cs:line 71
   at MphRead.SceneSetup.LoadEntities(RoomMetadata metadata, Int32 layerId, Scene scene) in D:\mph_build\MphRead\SceneSetup.cs:line 155
   at MphRead.SceneSetup.SetUpRoom(GameMode mode, Int32 playerCount, BossFlags bossFlags, Int32 nodeLayerMask, Int32 entityLayerId, RoomMetadata metadata, RoomEntity room, Scene scene) in D:\mph_build\MphRead\SceneSetup.cs:line 92
   at MphRead.SceneSetup.LoadRoom(String name, Scene scene, Int32 playerCount, BossFlags bossFlags, Int32 nodeLayerMask, Int32 entityLayerId) in D:\mph_build\MphRead\SceneSetup.cs:line 55
   at MphRead.Scene.AddRoom(String name, GameMode mode, Int32 playerCount, BossFlags bossFlags, Int32 nodeLayerMask, Int32 entityLayerId) in D:\mph_build\MphRead\Renderer.cs:line 231
   at MphRead.RenderWindow.AddRoom(String name, GameMode mode, Int32 playerCount, BossFlags bossFlags, Int32 nodeLayerMask, Int32 entityLayerId) in D:\mph_build\MphRead\Renderer.cs:line 4716
   at MphRead.Menu.ShowMenuPrompts() in D:\mph_build\MphRead\Menu.cs:line 705
   at MphRead.Program.Main(String[] args) in D:\mph_build\MphRead\Program.cs:line 28

But for some rooms (like 90 and 30), the debug version doesn't crash.

I don't know if this is a known issue, but I thought I'd post it, just in case.

Thanks for the report. Unintended combinations of modes, players, etc. aren't really tested and may not work properly. However, I do want to prevent crashes, so that will be fixed.

The debug assertion failures will not be changed for the time being.

Fixed in 0.23.4.0.