zer0Kerbal / OnDemandFuelCells

On Demand Fuel Cells (ODFC) is a plugin to support fuel cells that only generate power when it is needed, thereby saving precious fuel. Simulates fuel cells in Kerbal Space Program (KSP), and do a better job of it than stock's use of a resource converter. The main difference is it only generates electricity when it's really needed (batteries almost empty), and otherwise lets electricity of a craft float up and down, as it might in a solar powered vehicle when the sun is eclipsed by another celestial body. It also allows fuel cells to generate byproducts, aimed at supporting life support mods like TACLS.
https://forum.kerbalspaceprogram.com/index.php?/topic/187625-*/
GNU General Public License v2.0
2 stars 5 forks source link

[Bug šŸž]: Repeated Exception Handling Error/Sci Lab broken #102

Open help137 opened 1 year ago

help137 commented 1 year ago

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)

github-actions[bot] commented 1 year ago

:+1: Thank you @help137 :octocat:

:question::grey_question:

Have you reviewed the open issues logs and recent changelogs?

In order to help us help you, please provide:

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

:vibration_mode::eyes:Please either watch this repositiory for updates.

:speech_balloon:Kindly read our simple guides to:

0xE1E10 commented 1 year ago

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: https://github.com/sswelm/KSP-Interstellar-Extended/issues/667 https://github.com/sswelm/KSP-Interstellar-Extended/commit/2755fdd5d0b5977cf986bd3aaedab07e181655c2

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.