patch_anti_logincrash.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/bin/env bash
  2. echo "[NOTE] This patch is not required as of 2021-10-13. 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}" != "526b36c2b8a070db61428b7fe69906a3" ]; then
  15. # The patch might corrupt invalid/outdated files if this check is skippd.
  16. echo "Wrong file version or 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 "Please move all patch files outside the game directory prior executing."
  23. echo " -> See README.md for proper installation instructions" && exit 1
  24. fi
  25. # =========== DO NOT REMOVE END ===========
  26. if ! command -v xdelta3 &>/dev/null; then
  27. echo "xdelta3 application is required"
  28. exit 1
  29. fi
  30. echo "[INFO] Patch to fix a login and runtime crash"
  31. echo ""
  32. # ===========================================================
  33. echo "[WARNING] Hereby you are violating the game's Terms of Service!"
  34. echo " Do you accept the risk and possible consequences?"
  35. read -p "Accept? [y/n] " choice
  36. if [[ ! "$choice" == [JjSsYy]* ]]; then
  37. exit 1
  38. fi
  39. echo
  40. echo "--- Applying xLua patch"
  41. xdelta_fail() {
  42. mv -vf "$FILE.bak" "$FILE"
  43. exit 1
  44. }
  45. mv -f "$FILE" "$FILE.bak"
  46. # Perform patch or restore .bak on failure
  47. xdelta3 -d -s "$FILE.bak" "$DIR/patch_files/xlua_patch.vcdiff" "$FILE" || xdelta_fail
  48. # Done!
  49. echo "==> Patch applied! Enjoy the game."
  50. exit 0