Skip to content

Force invariant culture for number parsing - #81

Open
Ruuka6009 wants to merge 1 commit into
marchc1:mainfrom
Ruuka6009:main
Open

Force invariant culture for number parsing#81
Ruuka6009 wants to merge 1 commit into
marchc1:mainfrom
Ruuka6009:main

Conversation

@Ruuka6009

Copy link
Copy Markdown

On locales where . is not the decimal separator (fr-FR, de-DE, ...), float.Parse on game data throws FormatException — opening any main menu dialog crashes in PropertySheet.ApplySchemeSettings parsing PropertySheet.TransitionEffectTime ("0.25"). Both OptionsDialog (via PropertyDialog) and ServerBrowserDialog hit it on construction.

Platform.Initialize now pins the process to InvariantCulture. It is the first call in both the Launcher and Dedicated entry points, so it covers every parse site — not just this one. The TryParse sites did not throw but silently yielded 0, e.g. ConVar.cs:222 turned any fractional convar value into 0.

Also made the PropertySheet parse explicit and non-throwing, matching the existing style in BasePanelClientScheme.res defines no PropertySheet keys, so a missing value would otherwise throw on the empty string.

Locales with a non-dot decimal separator threw FormatException on game
data, crashing any menu dialog via PropertySheet's scheme parse.
@marchc1

marchc1 commented Aug 21, 2026

Copy link
Copy Markdown
Owner

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:

  • Differences in currency symbols (not relevant)
  • Dates? (probably not relevant I don't think we parse any dates lol)

So it's probably fine...

@Ruuka6009

Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants