patch_anti_logincrash.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/usr/bin/env bash
  2. #echo "[NOTE] This patch is in general not required since version 2.3.0."
  3. #echo " If your game freezes at the 7th element in the loading screen,"
  4. #echo " request a patch file in the issue tracker."
  5. #echo " edit this script file to comment/remove the line below."
  6. echo " This is an OPTIONAL patch to reduce CPU usage by disabling mhypbase.dll."
  7. echo "[WARNING] !! UNTESTED PATCH. CHECK FOR BANS USING A TRASH ACCOUNT !!"
  8. echo ""
  9. echo "If you would like to test this patch, modify this script and remove the line below this one."
  10. exit 0
  11. #echo "[NOTE] This patch is not required as of 2022-03-30. However, it might become"
  12. #echo " necessary afterwards (Friday?). If that's the case, comment the line below."
  13. #exit 0
  14. # MacOS and *BSD do not have md5sum: use md5 instead
  15. if [[ $(uname) == "Darwin" || $(uname) == *"BSD" ]]; then
  16. md5sum() {
  17. md5 -q $@
  18. }
  19. fi
  20. DIR=$(dirname "${BASH_SOURCE[0]}")
  21. DATADIR=$(find -maxdepth 1 -type d -name "*_Data")
  22. FILE="$DATADIR/Plugins/xlua.dll"
  23. sum=($(md5sum $FILE))
  24. reltype=""
  25. # original hashes
  26. if [ "${sum}" == "7be5e1c4621535a161440721f49287f5" ]; then
  27. reltype="os"
  28. echo "--- Applying for: International (OS) version"
  29. fi
  30. if [ "${sum}" == "d07c6ce9758744cee6f01c2da57a7b7d" ]; then
  31. reltype="cn"
  32. echo "--- Applying for: Chinese (CN) version"
  33. fi
  34. if [ -z "$reltype" ]; then
  35. # The patch might corrupt invalid/outdated files if this check is skippd.
  36. echo "[ERROR] Wrong file version or the patch is already applied"
  37. echo " -> md5sum: ${sum}" && exit 1
  38. fi
  39. # =========== DO NOT REMOVE START ===========
  40. if [[ -e "$DIR/$FILE" ]]; then
  41. # There is a good reason for this check. Do not pollute the game directory.
  42. echo "[ERROR] Invalid patch download directory. Please move all"
  43. echo " patch files outside the game directory prior executing."
  44. echo " -> See README.md for proper installation instructions" && exit 1
  45. fi
  46. # =========== DO NOT REMOVE END ===========
  47. if ! command -v xdelta3 &>/dev/null; then
  48. echo "[ERROR] xdelta3 application is required"
  49. exit 1
  50. fi
  51. #echo "[INFO] Patch to fix a login and runtime crash"
  52. # ===========================================================
  53. echo ""
  54. echo "[WARNING] Hereby you are violating the game's Terms of Service!"
  55. echo " Do you accept the risk and possible consequences?"
  56. echo " Use Ctrl+C to abort this script if you are not sure."
  57. read -p "Accept? [y/N] " choice
  58. if [[ ! "$choice" == [JjSsYy]* ]]; then
  59. exit 1
  60. fi
  61. echo
  62. echo "--- Patching xLua"
  63. xdelta_fail() {
  64. mv -vf "$FILE.bak" "$FILE"
  65. exit 1
  66. }
  67. mv -f "$FILE" "$FILE.bak"
  68. # Perform patch or restore .bak on failure
  69. xdelta3 -d -s "$FILE.bak" "$DIR/patch_files/xlua_patch_${reltype}.vcdiff" "$FILE" || xdelta_fail
  70. # Disable by renaming
  71. echo "--- Disabling mhypbase"
  72. mv -f "mhypbase.dll" "mhypbase.dll.bak"
  73. # Done!
  74. echo "==> Patch applied! Enjoy the game."
  75. exit 0