Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: setStateFloat #23

Closed
asadm opened this issue Jan 7, 2024 · 3 comments
Closed

bug: setStateFloat #23

asadm opened this issue Jan 7, 2024 · 3 comments
Assignees
Milestone

Comments

@asadm
Copy link
Collaborator

asadm commented Jan 7, 2024

bug report:

I found the problem and a fix!
It is related to a comma separator being used for real number representation in strings instead of dot separator.
In my region (Brazil) comma is used instead of dot. So when the javascript tries to parseFloat(UTF8ToString(value)) the float value gets clamped. The solution was in the C# side:
In the Player class, inside the method public void SetState(string key, float value, bool reliable = false), apply the InvariantCulture parameter when converting the float to a string, like this:
SetPlayerStateFloatByPlayerId(id, key, value.ToString(System.Globalization.CultureInfo.InvariantCulture), reliable);

@SaadBazaz
Copy link
Collaborator

Interesting problem. Will look into this.

@SaadBazaz SaadBazaz added this to the globalization milestone Jan 9, 2024
@SaadBazaz
Copy link
Collaborator

Any toStrings and similar data conversions should adhere to this rule. We will first update setState, test it, ensure it's working fine in Brazil and similar settings, then port it to the other functions.

@momintlh momintlh mentioned this issue Jan 16, 2024
9 tasks
@SaadBazaz
Copy link
Collaborator

Closing as completed in #30. However, it is possible that this issue lurks in more string-like places. Will keep an eye out and refer here if we find it again.

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

No branches or pull requests

3 participants