Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException when using MKS/USI Nuclear Fuel Containers #70

Closed
fat-lobyte opened this issue Apr 10, 2017 · 6 comments
Closed
Assignees
Milestone

Comments

@fat-lobyte
Copy link

fat-lobyte commented Apr 10, 2017

Hi! I get the following NullReferenceException spam, presumably in every frame:

NullReferenceException: Object reference not set to an instance of an object
  at NearFutureElectrical.RadioactiveStorageContainer.GetResourceAmount (System.String nm) [0x00000] in <filename unknown>:0 
  at NearFutureElectrical.RadioactiveStorageContainer.FixedUpdate () [0x00000] in <filename unknown>:0 
 
(Filename:  Line: -1)

This happens whenever I have either the large or small "Nuclear Fuel Container" part from RoverDudes USI/MKS Mod installed:

screenshot14

A workaround is to delete GameData/NearFutureElectrical/Patches/NFElectricalUSI.cfg.

Mods: Near Future Electrical, UKS
KSP Version: 1.2.2
NFE Version: 0.8.7
USI_Core Version: 0.3.10.0
MKS Version: 0.50.18.0

@ChrisAdderley
Copy link
Collaborator

Most of the USI patch is user-contributed, I do hope someone on the thread or perhaps @Wyzard256 can comment on this.

My best guess is that the USI containers appear (from the screenshot) to have no DepletedFuel storage in them and that might be causing issues

@fat-lobyte
Copy link
Author

@ChrisAdderley

My best guess is that the USI containers appear (from the screenshot) to have no DepletedFuel storage in them and that might be causing issues

Your guess is correct, there is a dedicated container for the waste. The question is, why does it NullRef? Shouldn't the Plugin be able to handle this situation?

@ChrisAdderley
Copy link
Collaborator

The NFT waste transfer mechanic requires a container to have an equal amount of both fuels to transfer, so this use case was never examined. In this use case the transfer would honestly not function correctly.

There is a question here of whether reactors, when installed, should all use USI's refuelling mechanics or whether they should all use NFT's refuelling mechanics.

@Wyzard256
Copy link
Contributor

Mea culpa, it seems: I wrote that part of NFElectricalUSI.cfg, and I tested that transfers worked with these containers, but I didn't notice the NREs in the console. Sorry about that.

@ChrisAdderley FWIW, despite the exceptions, transfers do actually work — I checked again just now. It looks like the problem is in RadioactiveStorageContainer's FixedUpdate where it wants to know how much waste is in the container so it can add the appropriate amount of heat. The USI fuel container has no waste capacity so the GetResourceAmount check fails.

As far as I can see, the fix should be as simple as adding a null check in GetResourceAmount, after looking up the resource and before calling .amount on it. (I'd submit a PR for it, but I've never done any KSP plugin programming so I don't have a dev environment set up to test with.)

@ChrisAdderley
Copy link
Collaborator

More like my fault given than the error handling is crappy enough to die on that :|.

@ChrisAdderley ChrisAdderley added this to the 0.9.0 milestone Apr 12, 2017
@ChrisAdderley ChrisAdderley self-assigned this Apr 12, 2017
@ChrisAdderley
Copy link
Collaborator

A fix has been prepared and is testing to include in 0.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants