patch_anti_logincrash.sh 2.1 KB

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