Unofficial CardLife revival project, pronounced like "celery"
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
957B

  1. using System;
  2. using System.Globalization;
  3. using System.Reflection;
  4. using HarmonyLib;
  5. namespace CLre.Fixes
  6. {
  7. public class EnchantmentTableFloatParseFix
  8. {
  9. }
  10. [HarmonyPatch]
  11. class Float_TryParse_Patch
  12. {
  13. [HarmonyPostfix]
  14. public static void BeforeMethodCall(string s, ref float result, ref bool __result)
  15. {
  16. if (__result) return;
  17. __result = float.TryParse(s,
  18. NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowLeadingSign |
  19. NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowExponent,
  20. NumberFormatInfo.InvariantInfo, out result);
  21. }
  22. [HarmonyTargetMethod]
  23. public static MethodBase Target()
  24. {
  25. return AccessTools.Method(typeof(float), "TryParse", new []{typeof(string), typeof(float).MakeByRefType()});
  26. }
  27. }
  28. }