asadm / playroom-unity

9 stars 1 forks source link

bug: setStateFloat #23

Closed asadm closed 5 months ago

asadm commented 6 months ago

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 commented 6 months ago

Interesting problem. Will look into this.

SaadBazaz commented 6 months ago

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.

SaadBazaz commented 5 months ago

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.