R-T-B / Kopernicus

Kopernicus is a mod for Kerbal Space Program which allows users to replace the planetary system used by the game.
GNU Lesser General Public License v3.0
32 stars 11 forks source link

DiscoverableObjects.SpawnAsteroid() is calling GameEvents.onNewVesselCreated with a null Vessel reference #55

Closed gotmachine closed 3 years ago

gotmachine commented 3 years ago

Using R67 on KSP 1.11, didn't check with "legacy" Kopernicus. Identified because Kerbalism is subscribing to that event.

[ERR 03:27:23.417] Exception handling event onNewVesselCreated in class Callbacks:System.NullReferenceException: Object reference not set to an instance of an object
  at KERBALISM.Serenity.GetModuleGroundExpControl (Vessel v) [0x00014] in C:\Users\Got\Source\Repos\Kerbalism\Kerbalism\src\Kerbalism\Utility\Serenity.cs:47 
  at KERBALISM.Callbacks.VesselCreated (Vessel v) [0x00001] in C:\Users\Got\Source\Repos\Kerbalism\Kerbalism\src\Kerbalism\System\Callbacks.cs:433 
  at EventData`1[T].Fire (T data) [0x000b0] in <f8bc9e2b903e48a5b248ab0083c07c62>:0 
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Debug:LogError(Object)
    EventData`1:Fire(Vessel)
    Kopernicus.RuntimeUtility.DiscoverableObjects:SpawnAsteroid(Asteroid, UInt32)
    Kopernicus.RuntimeUtility.DiscoverableObjects:UpdateAsteroid(Asteroid, Double)
    Kopernicus.RuntimeUtility.<AsteroidDaemon>d__9:MoveNext()
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
R-T-B commented 3 years ago

thanks, I'll look into this today.

R-T-B commented 3 years ago

This should fix it, testing now prior to release:

https://github.com/R-T-B/Kopernicus/commit/996bbb99ff8cf8e921dfba0b0f65d4d333309523

PS: Legacy Kopernicus is also affected. Will patch it as well if this works.

R-T-B commented 3 years ago

It appears fixed, pushing it out now.

R-T-B commented 3 years ago

Closed with release 69 on BE, 23 on stable. Feel free to reopen if you find similar, consider this a catchall for nullrefs related to that event.