KSPModdingLibs / KSPCommunityFixes

Community patches for bugs in the KSP codebase
49 stars 17 forks source link

Persisted modules are losing their customisations when switched to derived/base instances. #236

Open BrettRyland opened 2 months ago

BrettRyland commented 2 months ago

Describe your problem with KSPCF : If a craft is built with the Waterfall mod installed and then loaded on an install without the Waterfall mod (or vice-versa), then the ModuleEnginesFX module is replaced by a default ModuleEngines (or vice-versa) module. E.g.,

[WRN 23:26:54.357] [KSPCF:ModuleIndexingMismatch] Persisted module "ModuleEnginesFX" at index [0] has been removed, no matching module in the part config
[WRN 23:26:54.358] [KSPCF:ModuleIndexingMismatch] Module "ModuleEngines" at index [0] doesn't exist in the persisted part, a new instance will be created

The effect of this is that any customisations of the engine, such as activating it on an action group, are lost. Since ModuleEngine is a base class of ModuleEnginesFX, it would be better to build the new module by casting it from the old module whenever such a cast is valid (i.e., both modules classes are known and one is derived from the other). This is likely also an issue for any other mods that change modules to derived versions of a base class.

KSP version : 1.12.5 Link to your KSP.log file : KSP log files Example craft files where the bobcat engine is activated on AG1 if-and-only-if the module is not replaced.