KSPModdingLibs/KSPCommunityFixes

KSPC >= 1.22.0 breaks SpaceCenter node parsing

89Mods opened this issue · 5 comments

89Mods commented

Installing KSPC at or above version 1.22.0 causes Kopernicus to be unable to parse the fields inside any SpaceCenter nodes in custom planetary systems. This issue only occurs if KSPC is installed and at version 1.22.0 or above. The exception thrown is always Input string was not in a correct format. and for the very first line inside the SpaceCenter node, even if it is something as simple as longitude = 315.97

Logs files

Could you please provide an example Kopernicus config that reproduce this, or at least the name of a planet pack and body in that planet pack ?

Ok, found it by myself by looking at your logs.
This happens because the configs are using non-quite-standard line endings (CR only instead of the usual CR LF), causing our confignode parser to output essentially garbage.
Exerpt from your MMCache :

	Kopernicus
	{
		name = Kerbol System
		Body
		{
			name = Sun
			identifier = Squad/Sun
			identifier = PJ3/Doe\r\t\tcacheFile = PJ3/KopernicusFiles/0_DoeA/Cache/Doe.bin\r\t\t@Properties

Original file (notice how it is all squished as a single line when viewing it in github)
image

This being said, if the stock parser is treating this case "correctly", KSPCF should definitely behave identically. I will try to push a fix ASAP.

Ok, my guess would be that those lines :


need to be if (c == '\n' || c == '\r') to match the stock version (RecurseFormat(PreFormatConfig(s.Split('\n', '\r')))), but I'm unsure if our algorithm will handle that change correctly, and I can't check right now.

@NathanKell Would you mind taking a look at this ?

Yep, and in the commented code there it even is already testing for both, it's just not doing it there. Whoops. :]

(Testing for either works because those cases put the parser in SkipToKey mode, which eats all whitespace until a non-whitespace character.)

89Mods commented

Thanks for the info already. We were able to fix the issues with the config file on our end. No more crashes for now.