patch_anti_logincrash.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. exit 0
  7. #echo "[NOTE] This patch is not required as of 2022-03-30. However, it might become"
  8. #echo " necessary afterwards (Friday?). If that's the case, comment the line below."
  9. #exit 0
  10. # MacOS and *BSD do not have md5sum: use md5 instead
  11. if [[ $(uname) == "Darwin" || $(uname) == *"BSD" ]]; then
  12. md5sum() {
  13. md5 -q $@
  14. }
  15. fi
  16. DIR=$(dirname "${BASH_SOURCE[0]}")
  17. DATADIR=$(find -maxdepth 1 -type d -name "*_Data")
  18. FILE="$DATADIR/Plugins/xlua.dll"
  19. sum=($(md5sum $FILE))
  20. reltype=""
  21. # original hashes
  22. if [ "${sum}" == "a583a9cee97e8da74b6e4a3d39d9393b" ]; then
  23. reltype="os"
  24. echo "--- Applying for: International (OS) version"
  25. fi
  26. if [ "${sum}" == "TODO" ]; then
  27. reltype="cn"
  28. echo "--- Applying for: Chinese (CN) version"
  29. fi
  30. if [ -z "$reltype" ]; then
  31. # The patch might corrupt invalid/outdated files if this check is skippd.
  32. echo "[ERROR] Wrong file version or the patch is already applied"
  33. echo " -> md5sum: ${sum}" && exit 1
  34. fi
  35. # =========== DO NOT REMOVE START ===========
  36. if [[ -e "$DIR/$FILE" ]]; then
  37. # There is a good reason for this check. Do not pollute the game directory.
  38. echo "[ERROR] Invalid patch download directory. Please move all"
  39. echo " patch files outside the game directory prior executing."
  40. echo " -> See README.md for proper installation instructions" && exit 1
  41. fi
  42. # =========== DO NOT REMOVE END ===========
  43. if ! command -v xdelta3 &>/dev/null; then
  44. echo "[ERROR] xdelta3 application is required"
  45. exit 1
  46. fi
  47. echo "[INFO] Patch to fix a login and runtime crash"
  48. echo ""
  49. # ===========================================================
  50. echo "[WARNING] Hereby you are violating the game's Terms of Service!"
  51. echo " Do you accept the risk and possible consequences?"
  52. read -p "Accept? [y/n] " choice
  53. if [[ ! "$choice" == [JjSsYy]* ]]; then
  54. exit 1
  55. fi
  56. echo
  57. echo "--- Applying xLua patch"
  58. xdelta_fail() {
  59. mv -vf "$FILE.bak" "$FILE"
  60. exit 1
  61. }
  62. mv -f "$FILE" "$FILE.bak"
  63. # Perform patch or restore .bak on failure
  64. xdelta3 -d -s "$FILE.bak" "$DIR/patch_files/xlua_patch_${reltype}.vcdiff" "$FILE" || xdelta_fail
  65. # Done!
  66. echo "==> Patch applied! Enjoy the game."
  67. exit 0