jrossignol / ContractConfigurator

A config file based solution for creating new contracts for Kerbal Space Program.
https://forum.kerbalspaceprogram.com/index.php?/topic/91625-1
Other
64 stars 67 forks source link

Strange Behavior in Converting between CelestialBody and string #655

Closed gyf1214 closed 6 years ago

gyf1214 commented 6 years ago

In converting CelestialBody to string:

https://github.com/jrossignol/ContractConfigurator/blob/439d0707d9d8554409d4ba86af81ace5618ca71f/source/ContractConfigurator/ExpressionParser/Parsers/Classes/CelestialBodyParser.cs#L115

A lowercased display name is returned if it doesn't match its name

However in converting string to CelestialBody:

https://github.com/jrossignol/ContractConfigurator/blob/439d0707d9d8554409d4ba86af81ace5618ca71f/source/ContractConfigurator/Util/ConfigNodeUtil.cs#L903

It checks both name and non-lowercased display name

So, when the display name is uppercased and does not match the name (which happens in some planet packs like GPP), and a CelestialBody is converted to string and then parsed back (which happens in Expression Behavior), an exception be thrown.

I'm not sure what is the intention of the behavior or just a bug.

jrossignol commented 6 years ago

Why on Earth Kerbin is there logic for putting stuff into lowercase? I'm guessing this has something to do with localisation changes in 1.3... but looking at the code a year later it makes no sense. Will do a bit of digging.

jrossignol commented 6 years ago

Oh, makes more sense now. This is so you can do stuff like: "I'm going to {body}", and it will say "I'm going to the Mun" instead of "I'm going to The Mun". So necessary logic in general, but now that I know what it does I can fix the bug.

jrossignol commented 6 years ago

Changed to a case insensitive comparison, so that should fix this issue.