123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- #!/usr/bin/env bash
- # Templates for next patch
- #echo " === !! UNTESTED PATCH. CHECK FOR BANS USING A TRASH ACCOUNT !! ==="
- #echo " === AND REPORT RESULTS TO THE MAIN REPOSITORY. THANK YOU ==="
- #echo "If you would like to test this patch, modify this script and remove the line below this one."
- #exit 1
- #echo " === !! This patch is very new but almost identical to 1.3.2 !! ==="
- #echo " === If you are worried, use a secondary account for a few days ==="
- #read -p "Continue? [Enter] " _dumpster_
- DIR=$(dirname "${BASH_SOURCE[0]}")
- FILE="UnityPlayer.dll"
- CEXE="GenshinImpact_Data/upload_crash.exe"
- sum=($(md5sum $FILE))
- if [ "${sum}" != "572c45840c86267fa311978fe951c860" ]; then
- # The patch might corrupt invalid/outdated files if this check is skippd.
- echo "Wrong file version or patch is already applied"
- echo "md5sum: ${sum}" && exit 1
- fi
- # =========== DO NOT REMOVE START ===========
- if [[ -e "$DIR/$FILE" ]]; then
- # There is a good reason for this check. Do not pollute the game directory.
- echo "Please move all patch files outside the game directory prior executing."
- echo " -> See README.md for proper installation instructions" && exit 1
- fi
- # =========== DO NOT REMOVE END ===========
- if ! command -v xdelta3 &>/dev/null; then
- echo "xdelta3 application is required"
- echo " -> Debian/Ubuntu: apt install xdelta3"
- echo " -> Fedora: dnf install xdelta"
- exit 1
- fi
- # ===========================================================
- echo "[WARNING] Hereby you are violating the game's Terms of Service!"
- echo " Do you accept the risk and possible consequences?"
- read -p "Accept? [y/n] " choice
- if [[ ! "$choice" == [JjSsYy]* ]]; then
- exit 1
- fi
- echo "--- Setting up blocked servers"
- # START OF SUDO DANGER ZONE
- etc_hosts="$(cat /etc/hosts)"
- # See 110/network.md (up-to-date as of 1.4.0)
- servers=$(cat <<EOF
- # Genshin logging servers (do not remove!)
- 0.0.0.0 log-upload-os.mihoyo.com
- 0.0.0.0 overseauspider.yuanshen.com
- EOF
- )
- if [[ ! "$etc_hosts" == *"$servers"* ]]; then
- echo "[MANDATORY] Adding following logging servers to /etc/hosts"
- echo " If you really really want to skip this (Ctrl+C),"
- echo " PLEASE add the entries manually. Otherwise they will receive"
- echo " logs about The Wine project, hence UNCOVERING THIS PATCH!"
- echo "$servers" | sudo -k tee -a /etc/hosts
- if [ $? -ne 0 ]; then
- read -p "Please check your /etc/hosts file now. Enter to continue. "
- fi
- else
- echo "-- Logging servers are already blocked. Skip."
- fi
- servers=$(cat <<EOF
- # Optional Unity proxy/cdn servers
- 0.0.0.0 prd-lender.cdp.internal.unity3d.com
- 0.0.0.0 thind-prd-knob.data.ie.unity3d.com
- 0.0.0.0 thind-gke-usc.prd.data.corp.unity3d.com
- 0.0.0.0 cdp.cloud.unity3d.com
- 0.0.0.0 remote-config-proxy-prd.uca.cloud.unity3d.com
- EOF
- )
- if [[ ! "$etc_hosts" == *"$servers"* ]]; then
- echo ""
- echo "[Optional] Adding common Unity proxy/cdn servers to /etc/hosts"
- echo " Normally this does not cause any issues. If issues arise in other games,"
- echo " consider commenting a few lines to check what makes the difference."
- read -p "Add 5 servers? [y/n] " choice
- if [[ "$choice" == [JjSsYy]* ]]; then
- echo "-- Adding proxy/cdn servers"
- echo "$servers" | sudo tee -a /etc/hosts
- if [ $? -ne 0 ]; then
- read -p "--- FAILED to add the servers. What happened?!"
- fi
- fi
- else
- echo "-- Unity proxy/cdn servers are already blocked. Skip."
- fi
- etc_hosts=""
- # END OF SUDO DANGER ZONE
- echo ""
- # No crashes shall be reported!
- echo "--- Renaming the crash reporter"
- if [[ -e "$CEXE" ]]; then
- # Replace existing backups
- mv -f "$CEXE" "$CEXE.bak"
- fi
- # Registry entry to add on startup
- cp -f "$DIR/patch_files/mhyprot2_running.reg" .
- # Add launcher
- echo "--- Adding launcher script"
- cp -n "$DIR/patch_files/launcher.bat" .
- # Do the patch now, replace existing backups (hash confirmed)
- echo "--- Patching UnityPlayer"
- mv -f "$FILE" "$FILE.bak"
- xdelta3 -d -s "$FILE.bak" "$DIR/patch_files/unityplayer_patch.vcdiff" "$FILE"
- # Done!
- echo "==> Patch applied! Enjoy the game."
- exit 0
|