Force invariant culture for number parsing - #81
Conversation
Locales with a non-dot decimal separator threw FormatException on game data, crashing any menu dialog via PropertySheet's scheme parse.
|
I find it mildly questionable as to if its a good idea to set culture across the board to invariant; my concern mostly being that it's a really big decision to make this far into things Although it's likely fine since everything else in the original engine wasn't taking culture into account obviously, and probably this should've happened from the beginning for parsing purposes The only differences I can see from https://stackoverflow.com/questions/2329297/net-are-there-any-differences-between-invariantculture-and-en-us:
So it's probably fine... |
|
Yeah, that’s fair I’m still trying to get a better understanding of the current project flow, so part of this was simply to get the game running in the first place maybe I should’nt have made a global PR lol I also agree that changing culture globally is a fairly big decision and I don’t want to assume it’s the right long-term approach without understanding all the existing code, For now though it gets things running, and hopefully it can also help others get the game working while we figure out a proper approach. |
On locales where
.is not the decimal separator (fr-FR, de-DE, ...),float.Parseon game data throwsFormatException— opening any main menu dialog crashes inPropertySheet.ApplySchemeSettingsparsingPropertySheet.TransitionEffectTime("0.25"). BothOptionsDialog(viaPropertyDialog) andServerBrowserDialoghit it on construction.Platform.Initializenow pins the process toInvariantCulture. It is the first call in both the Launcher and Dedicated entry points, so it covers every parse site — not just this one. TheTryParsesites did not throw but silently yielded 0, e.g.ConVar.cs:222turned any fractional convar value into 0.Also made the PropertySheet parse explicit and non-throwing, matching the existing style in
BasePanel—ClientScheme.resdefines noPropertySheetkeys, so a missing value would otherwise throw on the empty string.