123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- #!/usr/bin/env bash
- # HI3 patch by mkrsym1
- # https://notabug.org/mkrsym1/dusk
- # mirror: https://codeberg.org/an-anime-team/dusk
- script_dir=`dirname "$0"`
- source "${script_dir}"/common
- if [ "$(realpath "${script_dir}")" == "$(realpath .)" ]; then
- error "Do not put the patch installer into the game directory!"
- fi
- if ! command -v xdelta3 2>&1 >> /dev/null; then
- error "xdelta3 is required for patching the game files, but was not found!"
- fi
- root_cmd="pkexec"
- yes_to_all=""
- no_root=""
- # Parse commandline arguments
- while [ "x$1" != "x" ];
- do
- case $1 in
- --root-cmd)
- shift
- root_cmd="$1"
- ;;
- --yes-to-all)
- yes_to_all="1"
- ;;
- --no-root)
- no_root="1"
- ;;
- *)
- error "Invalid commandline argmument: $1"
- ;;
- esac
- shift
- done
- # Logging servers
- logging_servers_glb=$(cat <<EOF
- # Honkai Impact 3rd logging servers
- 0.0.0.0 log-upload-os.hoyoverse.com
- 0.0.0.0 sg-public-data-api.hoyoverse.com
- 0.0.0.0 dump.gamesafe.qq.com
- EOF
- )
- # Region detection
- game_region=""
- logging_servers=""
- bh3base_checksum=($(md5sum BH3Base.dll))
- unityplayer_checksum=($(md5sum UnityPlayer.dll))
- case "${bh3base_checksum}-${unityplayer_checksum}" in
- "8cf160412eac779064456bcf5a408005-94ca69db1084ad419e124093cdfbc1eb")
- game_region="glb"
- logging_servers="${logging_servers_glb}"
- ;;
- *)
- error "Wrong game version or game is already patched. Run uninstall.sh to remove the patch."
- ;;
- esac
- info "Detected region: ${game_region}"
- if ! [ "${yes_to_all}" ]; then
- echo
- echo "Modifying the game is a violation of it's Terms of Service! Make sure that you understand all of the risks and possible consequences before proceeding!"
- read -p "Do you wish to proceed? [y/N] " response
- if [[ ! "$response" == [Yy]* ]]; then
- exit 1
- fi
- fi
- echo
- info "Installing the patch"
- echo
- if ! [ "${no_root}" ]; then
- if [[ ! `cat /etc/hosts` == *"$logging_servers"* ]]; then
- info "Blocking logging servers. This will require superuser privileges (canceling will skip this step)"
- echo "$logging_servers" | $root_cmd tee -a /etc/hosts 2>&1 >> /dev/null
- if test $? -ne 0; then
- warn "Could not block logging servers. Please add the following lines to your /etc/hosts manually:"
- echo "$logging_servers"
- fi
- else
- info "Logging servers are already blocked"
- fi
- else
- info "Skipped blocking logging servers because of --no-root"
- fi
- echo
- info "Copying additional files"
- for additional_file in ${additional_files[@]}
- do
- info "Copying ${additional_file}"
- cp -r "${script_dir}/${game_region}/files/${additional_file}" .
- if test $? -ne 0; then
- error "Failed to copy ${additional_file}!"
- fi
- done
- echo
- info "Patching game files"
- for game_file in ${game_files[@]}
- do
- if test -f "${game_file}"; then
- info "Patching ${game_file}"
-
- mv "${game_file}" "${game_file}.bak"
- xdelta3 -d -s "${game_file}.bak" "${script_dir}/${game_region}/diffs/${game_file}.vcdiff" "${game_file}"
- if test $? -ne 0; then
- error "Failed to patch ${game_file}!"
- fi
- else
- error "${game_file} not found!"
- fi
- done
- echo
- info "Done"
- echo
- echo "!!! PLEASE DON'T SHARE THIS PROJECT IN PUBLIC !!!"
- echo
|