-
Notifications
You must be signed in to change notification settings - Fork 20
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
PersistentIConfigNode patch can cause deprecated parts to show up (enum parsing becomes case-sensitive?) #159
Comments
So... When parsing an enum, the KSPCF parser will actually catch exceptions rising when the config value is undefined in the enum, with the end result being the enum set to its default value, which in the case of the In stock, the exception isn't catched immediately, resulting in the whole part failing to load :
While this indeed results in a different behavior, I'd say that the issue is on the mod author. I guess the intent was to soft-depreciate some parts, hidding them in the part list but avoiding to break existing crafts, which isn't achieved in stock as a result of the config typo. On the KSPCF side, I guess we should add some logging when an enum parsing fails, but the behavior of try/catching early sounds better than letting it propagate, see the current code for reference : KSPCommunityFixes/KSPCommunityFixes/Modding/PersistentIConfigNode.cs Lines 625 to 633 in 081c3bd
|
Nice catch. While I agree the soft-deprecation doesn’t work without KSPCF, it’s definitely a worse experience for the user when KSPCF is installed. What do you think about changing enum parsing to be case-insensitive? That would fix this issue and possibly other similar ones….but quite a weird hack. |
I'd say that the user experience problem has more to do with broken mods configs and little with KSPCF, and changing enum parsing to case-insensitive is just as likely to break stuff, in any case we're in undefined behavior territory. This being said, I agree that swallowing the exception silently is bad, and that definitely warrants adding some logging, I think this should do :
Besides, this only happens in a very specific code path (the |
I dunno, I feel pretty strongly that KSPCF shouldn't do what it's currently doing here. A mod author might never notice the exception in the logs if everything in game seems fine, and they shouldn't have to test their mod with KSPCF installed to see if it might break. Possible options:
|
Well, if we take the current example, the parts wrongly being present in the propulsion category is a clear in-game indication that something isn't fine, whereas the stock behavior resulting in part compilation had a less immediately visible effect. I'd argue that in practice the KSPCF behavior allowed a bug in that mod to be detected and hopefully reported. Letting the exception propagate isn't a good idea. For all other types, the behavior for a value parsing failing is to ignore that value, this notably has the benefit of providing a stable behavior for changes in the data model. |
I don't intend to adress this more than the logging I added. I something arise, feel free to open a new issue. |
As described here: https://forum.kerbalspaceprogram.com/topic/204002-18-112-kspcommunityfixes-bugfixes-and-qol-tweaks/?do=findComment&comment=4315970
Describe your problem with KSPCF : When the PersistentIConfigNode patch is enabled, many deprecated parts from Tantares will appear in the VAB. This does not occur when the PersistentIConfigNode patch is disabled. The root of the issue seems to be that these parts have their category set to
None
instead ofnone
, but the stock code seems to accept either one (or possibly there's some other mechanism that sets the category tonone
if it fails to parse. Notablynone
is -1 instead of 0, and enums in C# will default to 0.KSP version : 1.12.5
Link to your
KSP.log
file : https://drive.google.com/drive/folders/1AbMk8hD8jh2PLdSfEBo5I2TBCTrFqlIY?usp=sharingThe text was updated successfully, but these errors were encountered: