patch_anti_logincrash.sh 1.8 KB

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