From e3a53546bd15e30e2b9e110959198bc25320c72d Mon Sep 17 00:00:00 2001 From: Seregy Date: Thu, 11 Aug 2016 21:53:00 +0300 Subject: [PATCH] Invariant Culture for parsing in osu commands --- NadekoBot/Modules/Searches/Commands/OsuCommands.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/NadekoBot/Modules/Searches/Commands/OsuCommands.cs b/NadekoBot/Modules/Searches/Commands/OsuCommands.cs index 5907fc6c..6d95b72e 100644 --- a/NadekoBot/Modules/Searches/Commands/OsuCommands.cs +++ b/NadekoBot/Modules/Searches/Commands/OsuCommands.cs @@ -2,6 +2,7 @@ using NadekoBot.Classes; using Newtonsoft.Json.Linq; using System; +using System.Globalization; using System.IO; using System.Net; using System.Text.RegularExpressions; @@ -75,7 +76,7 @@ namespace NadekoBot.Modules.Searches.Commands var reqString = $"https://osu.ppy.sh/api/get_beatmaps?k={NadekoBot.Creds.OsuAPIKey}&{mapId}"; var obj = JArray.Parse(await SearchHelper.GetResponseStringAsync(reqString).ConfigureAwait(false))[0]; var sb = new System.Text.StringBuilder(); - var starRating = Math.Round(Double.Parse($"{obj["difficultyrating"]}"), 2); + var starRating = Math.Round(Double.Parse($"{obj["difficultyrating"]}", CultureInfo.InvariantCulture), 2); var time = TimeSpan.FromSeconds(Double.Parse($"{obj["total_length"]}")).ToString(@"mm\:ss"); sb.AppendLine($"{obj["artist"]} - {obj["title"]}, mapped by {obj["creator"]}. https://osu.ppy.sh/s/{obj["beatmapset_id"]}"); sb.AppendLine($"{starRating} stars, {obj["bpm"]} BPM | AR{obj["diff_approach"]}, CS{obj["diff_size"]}, OD{obj["diff_overall"]} | Length: {time}"); @@ -120,7 +121,7 @@ namespace NadekoBot.Modules.Searches.Commands { var mapReqString = $"https://osu.ppy.sh/api/get_beatmaps?k={NadekoBot.Creds.OsuAPIKey}&b={item["beatmap_id"]}"; var map = JArray.Parse(await SearchHelper.GetResponseStringAsync(mapReqString).ConfigureAwait(false))[0]; - var pp = Math.Round(Double.Parse($"{item["pp"]}"), 2); + var pp = Math.Round(Double.Parse($"{item["pp"]}", CultureInfo.InvariantCulture), 2); var acc = CalculateAcc(item, m); var mods = ResolveMods(Int32.Parse($"{item["enabled_mods"]}")); if (mods != "+")