kylepaulsen / RoR2-Original-Sound-Track

A Risk of Rain 2 mod that allows you to play Risk of Rain 1 (or any) music in place of the normal soundtrack.
2 stars 13 forks source link

String to float culture info problem #1

Closed xiaoxiao921 closed 1 year ago

xiaoxiao921 commented 4 years ago

Hi, depending on the country you are in, the System.Globalization.CultureInfo used by the computer isnt the same, in my case, float.parse except the seperator to be a comma, not a dot, so it fails parsing correctly the string and stacktrace the plugin. A lot of users could be affected

here is a test program showing the problem

using System;

public class Program
{
    public static void Main()
    {
        string test = "0.5";
        System.Globalization.CultureInfo frFr = new System.Globalization.CultureInfo("fr-FR");
        //var f = Single.Parse(test, System.Globalization.CultureInfo.InvariantCulture); works cause it use the default aka US i think
        var f = Single.Parse(test, frFr); // doesnt work it except a commat 0,5
        Console.Write(f);
    }
}
kylepaulsen commented 4 years ago

@xiaoxiao921 This should be fixed now in v1.1.1 I think. Using CultureInfo.InvariantCulture to parse like you suggested so values in the settings.xml must be in this form: 0.52.