mflink3012 / spaceengineers-mod-teleportingsensors

A mod for Space Engineers that allows using sensors for teleportation.
2 stars 2 forks source link

Game crash and KeyNotFoundException, when entering non-existing target #3

Closed mflink3012 closed 3 years ago

mflink3012 commented 3 years ago

The game will crash and give the following exception in the logs:

Exception occurred: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at SpaceEngineers.Mod.TeleportingSensor.LogicComponent.UpdateBeforeSimulation100() at VRage.Game.Components.MyGameLogicComponent.VRage.Game.Entity.EntityComponents.Interfaces.IMyGameLogicComponent.UpdateBeforeSimulation100(Boolean entityUpdate) at Sandbox.Game.Entities.Cube.MyFunctionalBlock.UpdateBeforeSimulation100() at Sandbox.Game.Entities.MyParallelEntityUpdateOrchestrator.UpdateBeforeSimulation100() at Sandbox.Game.Entities.MyParallelEntityUpdateOrchestrator.DispatchBeforeSimulation() at Sandbox.Game.Entities.MyEntities.UpdateBeforeSimulation() at Sandbox.Game.World.MySector.UpdateBeforeSimulation() at Sandbox.Game.World.MySession.UpdateComponents() at Sandbox.Game.World.MySession.Update(MyTimeSpan updateTime) at Sandbox.MySandboxGame.Update() at Sandbox.Engine.Platform.Game.UpdateInternal() at Sandbox.Engine.Platform.Game.RunSingleFrame() at Sandbox.Engine.Platform.FixedLoop.<>c__DisplayClass11_0.b__0() at Sandbox.Engine.Platform.GenericLoop.Run(VoidAction tickCallback) at Sandbox.Engine.Platform.Game.RunLoop() at Sandbox.MySandboxGame.Run(Boolean customRenderLoop, Action disposeSplashScreen) at SpaceEngineers.MyProgram.Main(String[] args)

when giving a non-existent target to a sensors Custom Data.

mflink3012 commented 3 years ago

The script already checks for Target != null, but it has to check for TeleporterNetwork.ContainsKey(Target) also. I will fix that.