diff --git a/CLre/Fixes/EnchantmentTableFloatParseFix.cs b/CLre/Fixes/EnchantmentTableFloatParseFix.cs index d40cb5a..6cfffb2 100644 --- a/CLre/Fixes/EnchantmentTableFloatParseFix.cs +++ b/CLre/Fixes/EnchantmentTableFloatParseFix.cs @@ -58,7 +58,7 @@ namespace CLre.Fixes NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowExponent, NumberFormatInfo.InvariantInfo, out __result); #if DEBUG - API.Utility.Logging.Log($"Parsed \"{s}\" into {__result}"); + API.Utility.Logging.Log($"Parsed \"{s}\" into {__result} (successfully? {success})"); #endif return !success; } diff --git a/CLre/Fixes/FloatLanguageFix.cs b/CLre/Fixes/FloatLanguageFix.cs new file mode 100644 index 0000000..9b781fd --- /dev/null +++ b/CLre/Fixes/FloatLanguageFix.cs @@ -0,0 +1,4 @@ +$HEADER$namespace $NAMESPACE$ +{ + public class $CLASS$ {$END$} +} \ No newline at end of file diff --git a/CLre/Fixes/MapPinPointsFloatFix.cs b/CLre/Fixes/MapPinPointsFloatFix.cs new file mode 100644 index 0000000..993a03a --- /dev/null +++ b/CLre/Fixes/MapPinPointsFloatFix.cs @@ -0,0 +1,59 @@ +using System.Globalization; +using System.Reflection; +using System.Text; +using Game.UI.WorldMapScreen; +using HarmonyLib; +using Svelto.DataStructures; + +namespace CLre.Fixes +{ + public class MapPinPointsFloatFix + { + + } + + [Bugfix(name = "OfflineSpawnpointSavingFloatFix", + description = "Make spawnpoints save properly for everyone, even when floats contain a comma", + more = "https://trello.com/c/hpADhDhQ/21-login-goes-to-original-spawn", + component = BugfixType.HarmonyPatch, id = 9)] + [HarmonyPatch] + class WorldMapPinPointsMessage_InjectValues_Patch + { + private static StringBuilder sb = new StringBuilder(); + + [HarmonyPrefix] + public static bool BeforeMethodCall(WorldMapPinPointsMessage __instance, + FasterList pinPositions) + { +#if DEBUG + API.Utility.Logging.Log("Intercepting Game.UI.WorldMapScreen.WorldMapPinPointsMessage:InjectValues"); +#endif + sb.Length = 0; + for (int i = 0; i < pinPositions.Count; i++) + { + if (pinPositions[i].IsOnMap) + { + // force culture invariant float format (with a . as decimal point) + sb.AppendFormat("{0};{1};", + pinPositions[i].PinPosition.x.ToString("0.0", CultureInfo.InvariantCulture), + pinPositions[i].PinPosition.y.ToString("0.0", CultureInfo.InvariantCulture)); + } + else + { + sb.AppendFormat("{0};{1};", "x", "x"); + } + } + __instance.pinPoints = sb.ToString(); +#if DEBUG + API.Utility.Logging.Log($"Corrected pin point string to culture invariant: {sb.ToString()}"); +#endif + return false; + } + + [HarmonyTargetMethod] + public static MethodBase Target() + { + return AccessTools.Method(typeof(WorldMapPinPointsMessage), "InjectValues"); + } + } +} \ No newline at end of file