Jump to content

Safe removal of a mod


Recommended Posts

Hello everyone,

my testers users notified me of a problematic bug.

My mod uses PartModules extensively, and obviously they are saved in the ship's persistent file. If one has a ship in flight and removes my mod, then a long stream of NREs is thrown when the ship is selected in the tracking station, and cannot be flown.

I get that basically the game is trying to load the module from the save file, but the module doesn't exist anymore, therefore the failures.

My question is: is there a way to design a mod that can be safely removed from crafts that are in-flight?

Link to comment
Share on other sites

How exactly are you adding the partmodules and to what?

For my mod, I add the partmodule via modulemanager and a part.cfg. Removing my mod causes no errors to be thrown by KSP.

Now, I do have a pretty basic implementation of a partmodule that I'm just storing some strings in, but at a basic level it looks like partmodules should be okay to just leave behind when a mod is uninstalled..

D.

Edited by Diazo
Link to comment
Share on other sites

I am doing the same: I have some partmodules that are added via the module manager cfg files.

I add my modules to a lot of parts, and they all have a quite big state stored in them, but conceptually it seems to be just like your case.

Link to comment
Share on other sites

My only thought then is are you nesting partmodules somehow? Or it is the fancier data types maybe?

When I say I'm only storing strings, that is all I'm storing. Well, 5 strings and 1 bool, but I'd consider a bool an even simpler data type then a string.

Or have you got a custom data type that KSP can't recognize because the definition for it is in your mod?

I'm really just throwing things at the wall and seeing what sticks here. Is this for one of your mods that you have the source posted somewhere so I could take a look?

D.

Link to comment
Share on other sites

Generally, a module that is missing will not produce a NRE, the part loader will complain that the part cannot load a module, and it will be saved to the persistence without any records pertaining to this module when the next time to save persistence comes up. I.e. normally, a PartModule-installing plugin is perfectly safe to remove, though I suppose some things, like TweakScale, may be the exception, depending on whether they modify the part after it starts or not.

If you're getting NRE, there's got to be something more interesting going on in there.

Link to comment
Share on other sites

My only thought then is are you nesting partmodules somehow? Or it is the fancier data types maybe?

Actually no, it's just a plain part module. Also, I'm storing only floats, bools and in one case a string.

All my modules (except for one) are derived from this class.

There is also another class that acts as a runtime configuration manager.

If you're getting NRE, there's got to be something more interesting going on in there.

Well, the silver lining is that I'm not doing something glaringly wrong :)

Link to comment
Share on other sites

All my modules (except for one) are derived from this class.

Hmmmm... You know what, this might be it.

I'm not sure if everything that handles PartModules actually correctly handles classes that inherit classes that inherit PartModules. I know it's a problem with science modules, at least.

Link to comment
Share on other sites

hmmmm... You know what, this might be it.

I'm not sure if everything that handles partmodules actually correctly handles classes that inherit classes that inherit partmodules. I know it's a problem with science modules, at least.

awesome. ;.;

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...