zer0Kerbal/OnDemandFuelCells

[Bug 🐞]: Repeated Exception Handling Error/Sci Lab broken

Opened this issue Β· 2 comments

Brief description of your issue (aka the problem)

I'm getting the following error over and over in my KSP log (usual size 3MB, with this error chain, 86MB). It also seems to be breaking the Science Lab, (MPL-LG-2) as it will not completely transmit science with ODFC installed (appears to transmit, but science is still in lab, none added at KSC).

Notes:
Lab is the only part on the base with ODFC.
There is a fuel source on the base (LFO).
Other science (sensors, etc) transmits normally.
Uninstalling ODFC causes the Science Lab to Transmit normally.

[ERR 11:19:43.965] [ODFC v1.2.99.1-zed'K]: OnFixedUpdate: _electricCharge is null

[ERR 11:19:43.972] Exception handling event onPartActionUICreate in class ModuleScienceLab:System.NullReferenceException: Object reference not set to an instance of an object
  at ModuleScienceLab.updateModuleUI () [0x00000] in <4b449f2841f84227adfaad3149c8fdba>:0 
  at ModuleScienceLab.onPartActionUI (Part p) [0x00025] in <4b449f2841f84227adfaad3149c8fdba>:0 
  at EventData`1[T].Fire (T data) [0x000b0] in <4b449f2841f84227adfaad3149c8fdba>:0 

[EXC 11:19:43.972] NullReferenceException: Object reference not set to an instance of an object
	ModuleScienceLab.updateModuleUI () (at <4b449f2841f84227adfaad3149c8fdba>:0)
	ModuleScienceLab.onPartActionUI (Part p) (at <4b449f2841f84227adfaad3149c8fdba>:0)
	EventData`1[T].Fire (T data) (at <4b449f2841f84227adfaad3149c8fdba>:0)
	UnityEngine.DebugLogHandler:LogException(Exception, Object)
	KSPe.Util.Log.UnityLogDecorator:UnityEngine.ILogHandler.LogException(Exception, Object)
	ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
	UnityEngine.Debug:LogException(Exception)
	EventData`1:Fire(Part)
	UIPartActionWindow:CreatePartList(Boolean)
	UIPartActionWindow:UpdateWindow()
	UIPartActionController:UpdateActiveWindows()
	UIPartActionController:UpdateFlight()
	UIPartActionController:Update()
[ERR 11:19:43.988] [ODFC v1.2.99.1-zed'K]: OnFixedUpdate: _electricCharge is null

[ERR 11:19:43.995] [ODFC v1.2.99.1-zed'K]: OnFixedUpdate: _electricCharge is null

[ERR 11:19:44.002] Exception handling event onPartActionUICreate in class ModuleScienceLab:System.NullReferenceException: Object reference not set to an instance of an object
  at ModuleScienceLab.updateModuleUI () [0x00000] in <4b449f2841f84227adfaad3149c8fdba>:0 
  at ModuleScienceLab.onPartActionUI (Part p) [0x00025] in <4b449f2841f84227adfaad3149c8fdba>:0 
  at EventData`1[T].Fire (T data) [0x000b0] in <4b449f2841f84227adfaad3149c8fdba>:0 

[EXC 11:19:44.002] NullReferenceException: Object reference not set to an instance of an object
	ModuleScienceLab.updateModuleUI () (at <4b449f2841f84227adfaad3149c8fdba>:0)
	ModuleScienceLab.onPartActionUI (Part p) (at <4b449f2841f84227adfaad3149c8fdba>:0)
	EventData`1[T].Fire (T data) (at <4b449f2841f84227adfaad3149c8fdba>:0)
	UnityEngine.DebugLogHandler:LogException(Exception, Object)
	KSPe.Util.Log.UnityLogDecorator:UnityEngine.ILogHandler.LogException(Exception, Object)
	ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
	UnityEngine.Debug:LogException(Exception)
	EventData`1:Fire(Part)
	UIPartActionWindow:CreatePartList(Boolean)
	UIPartActionWindow:UpdateWindow()
	UIPartActionController:UpdateActiveWindows()
	UIPartActionController:UpdateFlight()
	UIPartActionController:Update()

Operating system

Windows 10-64

KSP version

1.12.5

Version of addon

1.2.99.1

Steps to reproduce the behavior or issue

Have ODFC installed, have a Science Lab as a part of a Mun base, with data, scientist, antennas, power, etc.
Click Transmit Science.

Expected behavior

Science to transmit, be removed from lab and added at KSC for use.

Actual behavior

Science appears to transmit, but is not removed from lab and is not added at KSC for use.

Environment

Mod: 1.2.99.1
KSP: 1.12.5
Download: Curseforge/Manual

Log files

KSP_LOG.zip

Had to zip, GitHub won't accept an 86MB log file.

Screenshots

No response

Additional context

No response

How did you download and install this?

CurseForge (download and manual installation)

πŸ‘ Thank you @help137 :octocat:

❓❔

Have you reviewed the open issues logs and recent changelogs?

In order to help us help you, please provide:

  • <KSP_ROOT>/KSP.LOG
  • and one of the following:
    • if Module Manger is installed
      • <KSP_ROOT>/GameData/ModuleManager.ConfigCache
    • if Module Manger /L is installed
      • <KSP_ROOT>/PluginData\ModuleManager\ConfigCache.cfg
  • Screenshots of issue (if appropriate) (images tell a much stronger tale)

You can archive these files (rar or zip, sadly no 7zip) and drag-n-drop them into an issue comment

πŸ“³πŸ‘€Please either watch this repositiory for updates.

πŸ’¬Kindly read our simple guides to:

Because ODFC shifted the module indices of Squad's default lab module.

Long explanation: https://forum.kerbalspaceprogram.com/topic/182402-science-lab-not-transmitting/
Other KSP mods with same problem and fix:
sswelm/KSP-Interstellar-Extended#667
sswelm/KSP-Interstellar-Extended@2755fdd

Relavant parts of my ModuleManager.ConfigCache:

UrlConfig
{
	parentUrl = Squad/Parts/Science/LargeCrewedLab/largeCrewedLab.cfg
...
		MODULE
		{
			name = ODFC
...
		}
		MODULE
		{
			name = ModuleScienceContainer
...
		}
		MODULE
		{
			name = ModuleScienceLab
			containerModuleIndex = 0
...
		}
...
		MODULE
		{
			name = WBIModuleScienceExperiment
...
		}

In original file from GameData/Squad/Parts/Science/LargeCrewedLab/largeCrewedLab.cfg, ModuleScienceContainer is the first module. ModuleScienceLab is the second module, which refers to the first with containerModuleIndex 0. Since ODFC inserted itself at the front, everybody's index is shifted and the science lab cannot find the container to transmit the science.

I'm not very well versed with ModuleManager syntax. But the ODFC patch seems to explicitly ask to insert itself as first:
https://github.com/zer0Kerbal/OnDemandFuelCells/blob/master/GameData/OnDemandFuelCells/Config/LargeCrewedLab.cfg#L18

Mods like WildBlueTools just use MODULE without the 0:
https://github.com/Angel-125/WildBlueTools/blob/master/GameData/WildBlueIndustries/000WildBlueTools/ModuleManagerPatches/MM_Stock.cfg#L64
In my ModuleManager.ConfigCache, WildBlueTools modules gets inserted at the end after the Squad modules. Indices remain the same and everything works.

Is there a reason why you have to be the first? I suppose you could try to patch the containerModuleIndex from Squad's lab module. But that sounds pretty fragile if every mod decides to do the same. Probably easiest to just let Squad be first just like how the Intersteller mod fixed this.