Closed Sigma88 closed 5 years ago
pinging @blowfishpro in case he might know :)
The cache is written with KSP stock ConfigNode.Save(path) so the problem is in there :( So we either have to escape everything before saving, write our own Save or cache in an other format (binary serialization ? protobuf ? Unity JSON serializer). That may improve perf a bit more. Or not.
in the meantime I've circumvented the issue using &br;
and .Replace("&br;","\n")
let me know if you need some tests
Sounds like KSP is handling escaping properly when loading but not when saving. I'll see about letting Squad know about this
the major problem about this is that the behaviour is not consistent between starts
if you start the game without the cache the result is different than with the cache.
if it wasn't for that I wouldn't have even noticed
Interesting, apparently \n
is only properly processed in the first place because of the localizer. So I guess that explains why it's not handled on save
Ugh, I hit this one too. Used to work before 1.3 because KSP wouldn't do anything with the \n.
I haven't closed the issue just because the info might help people having this same issue, just make sure you use an alternative symbol (I use &br;
)
The problem with changing to &br;
is that I can't easily assess the impact - out of two dozen or so contract packs out there, they could all be using '\n' voraciously... or not using it at all. So I'd rather explore options that don't require that change until I have no other choice.
ah yes, but the issue here (iirc) is that the localizer changes \n to newline so by the time mm gets the cfg it is already messed up
@sarbian @blowfishpro correct me if I'm wrong
That's correct. The only thing I can think of to fix this on MM's side would be to rewrite the ConfigNode saving code and use that when writing the cache.
Agreed, it's not pretty, and even if it was I'm not sure if I'd want to be the one to have MM reformat every config node value before it goes the door in cache.
So @JPLRepo - since I can't easily ping you on the KSP tracker, any chance you (or someone else) can respond on #16315 to let us know if there's any chance for a fix in 1.4.2?
You can always get me on IRC.
In some experiments with Kopernicus today, I was able to get line feeds using a syntax like "\\nn""
The internal "\n" is removed, but in doing so, it creates a valid "\n". I tested this using MM cache or fresh, and both worked in my hands.
Not a great solution, but could be a workaround.
Fixed now
Thanks @blowfish this is great!
example:
will be saved to the cache as
which means that when running KSP without MM cache the description will be loaded as
FirstLine\nSecondLine
while when running KSP and loading the nodes from the MM cache, the description will be loaded as just
FirstLine