Tweakscale shouldn't remove its persisted node in craft files
gotmachine opened this issue · 7 comments
Is a very bad idea.
By removing (well, renaming, but the effect is the same) a module node from the craft file, your are shifting the indexes of all further module nodes. KSP rely on the prefab modules indexes and the persisted modules indexes to be synchronized when reloading a part. When that synchronization is lost, it will attempt to reconnect things with some heuristics that will fail in many not-so-corner cases, causing modules to loose their persisted state, or even worst, to be loaded with the persisted state of the wrong module.
(if you want a detailed explanation, read this : KSPModdingLibs/KSPCommunityFixes#14)
Additionally, you're not optimizing anything, quite the contrary, as triggering the "indexing mismatch" code will cause a lot of extra processing.
The PartModule.GetPersistentId()
may explain why I didn't was bitten by this, as I rarely use anything too fancy. I'm reasonably confident I would had detected this on my airplanes with dual mode engines.
(still pissed on the matter)
This is hardly "news", I personally always discourage players to add/remove plugins in existing saves, but I've indeed seen the "indexing mismatch log entries are harmless" misinformation being relayed frequently on the forums.
Including by me, and this makes the thing even bitter for my taste.
This stunt caused me a HUGE pain in the ass on my first year of TweakScale's tenure, and now you are telling me that all that pain was for nothing, as we are in the same square we were on the KSP 1.3.x. times.
Also, for modules that are designed to exist in multiple occurrences in a part, it is possible to work around the issue by defining unique identifiers for modules and a bit of OnLoad() logic. As far as I know, only B9PS implement such a fix :
It was what I was thinking on the bath - an Instance for each PartModule, the same way we have an InstanceID for each Part. What's, frankly, it's already there on the KSP API!
So… Why it is not being used at all, damn it?
(in a way or another, I will deactivate the feature).
Executed on commit 781f51e .
This will be published this week, probably on Wednsday.
Thanks for the heads up, @gotmachine !
This is an old request, to do not save TweakScale on crafts that doesn't have scalings - so the crafts would be exported without TweakScale.
I'm using this stunt on my games for almost a year already, but, again, my KSP installments are the same for all this time, so I my tests are probably biased by the add'ons I use.
I just read the issue your pinpointed, and I acknowledge the problem.
I will deactivate the feature and issue a new release ASAP.
On a side note, this also means that there's no safe way to add or remove an Add'On on an ongoing savegame.
Terrible news.
On a side note, this also means that there's no safe way to add or remove an Add'On on an ongoing savegame.
This is hardly "news", I personally always discourage players to add/remove plugins in existing saves, but I've indeed seen the "indexing mismatch log entries are harmless" misinformation being relayed frequently on the forums. Arguably, this is only an issue for modules that :
- Can exist in multiple occurrences on the same part
- Are persisting data
There are actually very few cases of such modules in stock (or at least, cases were the persisted data being lost is very noticeable / game breaking), but arguably a lot more cases with mods.
Also, for modules that are designed to exist in multiple occurrences in a part, it is possible to work around the issue by defining unique identifiers for modules and a bit of OnLoad() logic. As far as I know, only B9PS implement such a fix : https://github.com/blowfishpro/B9PartSwitch/blob/dd7482a87deb750690ac0d77860b3d02460b698a/B9PartSwitch/CustomPartModule.cs#L58-L75
For the posteriority, this is the reason StealthSave was created:
https://forum.kerbalspaceprogram.com/index.php?/topic/192048-18/&do=findComment&comment=4031803
So, I was trying to uninstall both this and Tweakscale at the same time (because I don't need either at the moment), and I've noticed that when I try to launch craft I've built since I installed it, they have Modules missing and thus can't be loaded (Refunding and Tweakscale). What can I do to remove those modules from my craft parts?
Just ignore the messages, as you would do by uninstalling any other add'on (as b9-ps, KIS, Atmospheric AutoPilot, etc).
Keep in mind that, as any other add'on, if the craft you are loading uses it that part will be defaulted, and your craft will be mangled - just don't save the craft if that happens, and nothing will be lost.
On a side note, on the latest releases from TweakScale a new feature will avoid these pesky messages in the future, as only parts really using TweakScale will cause some problems if you uninstall TweakScale and then try to load a craft made with it.
It was never about "optimisations", and I don't have the slightest idea from where this idea came from. :)