|
1 | 1 | using System;
|
2 | 2 | using System.Collections.Generic;
|
| 3 | +using System.Globalization; |
| 4 | +using System.Threading; |
3 | 5 | using LitJson;
|
4 | 6 | using NitroxModel.DataStructures.GameLogic.Entities;
|
5 | 7 | using static LootDistributionData;
|
@@ -42,14 +44,30 @@ public override List<UwePrefab> GetPossiblePrefabs(string biome)
|
42 | 44 |
|
43 | 45 | private LootDistributionData GetLootDistributionData(string lootDistributionJson)
|
44 | 46 | {
|
| 47 | + ForceCultureOverride(); |
45 | 48 | JsonMapper.RegisterImporter((double value) => Convert.ToSingle(value));
|
46 |
| - |
| 49 | + |
47 | 50 | Dictionary<string, LootDistributionData.SrcData> result = JsonMapper.ToObject<Dictionary<string, LootDistributionData.SrcData>>(lootDistributionJson);
|
48 | 51 |
|
49 | 52 | LootDistributionData lootDistributionData = new LootDistributionData();
|
50 | 53 | lootDistributionData.Initialize(result);
|
51 | 54 |
|
52 | 55 | return lootDistributionData;
|
53 | 56 | }
|
| 57 | + |
| 58 | + // LitJson uses the computers local CultureInfo when parsing the JSON files. However, |
| 59 | + // these json files were saved in en_US. Ensure that this is done for the current thread. |
| 60 | + private void ForceCultureOverride() |
| 61 | + { |
| 62 | + CultureInfo cultureInfo = new CultureInfo("en-US"); |
| 63 | + |
| 64 | + // Although we loaded the en-US cultureInfo, let's make sure to set these incase the |
| 65 | + // default was overriden by the user. |
| 66 | + cultureInfo.NumberFormat.NumberDecimalSeparator = "."; |
| 67 | + cultureInfo.NumberFormat.NumberGroupSeparator = ","; |
| 68 | + |
| 69 | + Thread.CurrentThread.CurrentCulture = cultureInfo; |
| 70 | + Thread.CurrentThread.CurrentUICulture = cultureInfo; |
| 71 | + } |
54 | 72 | }
|
55 | 73 | }
|
0 commit comments