Skip to content

Instantly share code, notes, and snippets.

@jcdickinson
Last active August 3, 2022 21:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcdickinson/f267580fadbb7396b72aebc5f041fbdd to your computer and use it in GitHub Desktop.
Save jcdickinson/f267580fadbb7396b72aebc5f041fbdd to your computer and use it in GitHub Desktop.
AOE4 Desync Fix
#!/usr/bin/env bash
set -e
STEAM_DIR=$HOME/.steam/steam/steamapps
if [ ! -e "$STEAM_DIR" ]; then
# Possibly flatpak
STEAM_DIR=/var/home/$USER/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps
fi
if [ ! -e "$STEAM_DIR" ]; then
echo "Could not find steam" >&2
exit 1
fi
AOE4_DIR=$STEAM_DIR/compatdata/1466860
AOE4_WIN_DIR=$AOE4_DIR/pfx/drive_c/windows
AOE4_WIN_SYS32_DIR=$AOE4_WIN_DIR/system32
AOE4_WIN_SYS64_DIR=$AOE4_WIN_DIR/syswow64
if [ ! -e "$AOE4_DIR" ]; then
echo "Could not find AOE4 compat dir, you need to run it at least once" >&2
exit 1
fi
function cleanup() {
local arch=$1
rm -f "vc_redist.$arch.exe"
rm -rf 0 a{0..11} u{0..31}
}
function backup-file() {
filename="$1"
timestamp="$2"
if [ -f "ucrtbase.dll" ]; then
[ -e "$1" ] && mv "$1" "$1".bak-$timestamp
echo "$1 -> $2"
fi
}
function backup() {
local timestamp=$(date +%s)
backup-file concrt140.dll $timestamp
backup-file msvcp140.dll $timestamp
backup-file vcamp140.dll $timestamp
backup-file vccorlib140.dll $timestamp
backup-file vcomp140.dll $timestamp
backup-file vcruntime140.dll $timestamp
backup-file ucrtbase.dll $timestamp
}
function download_and_replace() {
local arch=$1
wget "https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.$arch.exe"
cabextract "vc_redist.$arch.exe"
cabextract a10
}
function replace_dlls() {
local dir=$1
local arch=$2
cd "$dir"
echo "replacing dlls in directory $dir"
backup
cleanup "$arch"
download_and_replace "$arch"
cleanup "$arch"
}
replace_dlls $AOE4_WIN_SYS32_DIR x64
replace_dlls $AOE4_WIN_SYS64_DIR x86
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment