Skip to content

Instantly share code, notes, and snippets.

@reneklacan
Last active March 26, 2024 08:48
Show Gist options
  • Save reneklacan/7825b82723bf0534cbd2eae014e121ca to your computer and use it in GitHub Desktop.
Save reneklacan/7825b82723bf0534cbd2eae014e121ca to your computer and use it in GitHub Desktop.
Script to fix AOE4 desync issues
#!/bin/bash
set -ex
STEAM_DIR=/home/$USER/.steam/steam/steamapps
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
function check_deps() {
which wget || (echo "wget is required (on Ubuntu you can install it with 'sudo apt-get install wget')" && exit 1)
which cabextract || (echo "cabextract is required (on Ubuntu you can install it with 'sudo apt-get install cabextract')" && exit 1)
}
function cleanup() {
local arch=$1
rm -f vc_redist.$arch.exe
rm -rf 0 a{0..11} u{0..31}
}
function backup() {
local timestamp=$(date +%s)
mv ucrtbase.dll ucrtbase.dll.bak-$timestamp
mv concrt140.dll concrt140.dll.bak-$timestamp
mv msvcp140.dll msvcp140.dll.bak-$timestamp
mv vcamp140.dll vcamp140.dll.bak-$timestamp
mv vccorlib140.dll vccorlib140.dll.bak-$timestamp
mv vcomp140.dll vcomp140.dll.bak-$timestamp
mv vcruntime140.dll vcruntime140.dll.bak-$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
backup
cleanup $arch
download_and_replace $arch
cleanup $arch
}
check_deps
replace_dlls $AOE4_WIN_SYS32_DIR x64
replace_dlls $AOE4_WIN_SYS64_DIR x86
@broaken13
Copy link

@Yohomie99 Those are commands to enter in a terminal (I believe the steam deck uses one called konsole). You'll need to navigate the terminal to the folder where the script is and run them. So, assuming the script is downloaded to the Downloads folder, you'll open a terminal and type:

  1. cd Downloads or wherever the script is to navigate it's folder (cd means change directory)
  2. chmod +x aoe4-mp-fix.sh This will allow you to execute the script
  3. ./aoe4-mp-fix.sh This executes the script

However, I'm looking at this now with my steam deck, and this looks like it might be quite a bit more of a headache than I initially thought. Looks like it might be necessary to enable developer mode in order to download the dependencies and run the script.

@kaidelorenzo
Copy link

You don't technically need dev mode to run this on the steamdeck. You can compile cabextract from source in a flatpak runtime. That's why I did just FYI.

@GolDNenex
Copy link

GolDNenex commented Feb 23, 2023

Distrobox is great on the steam deck.

In the script edit:

$USER

in this line on the top:

STEAM_DIR=/home/$USER/.steam/steam/steamapps

You should have something like that:

STEAM_DIR=/home/goldnenex/.steam/steam/steamapps

install Distrobox and run the script from it.

@ballerguitarer
Copy link

ballerguitarer commented Aug 16, 2023

Linux noob here (literally, day #3 of Kubuntu here). I ran the code with the set -ex to set -x tweak, and now AOE doesn't even open. Tried uninstalling and reinstalling, but no change, and now none of my games open. Anyone else run into this issue and solve it?

@BloodyIron
Copy link

FYI this script does not account for the following scenarios:

  1. If your games are stored on another drive, as in outside your home folder. I myself have two additional storage drives mounted elsewhere, since well, games are big and need to put them different places.
  2. Once adapted to other locations, this script is also intolerant for spaces in parent folders where a Steam Library could be housed at. Like "/mnt/ssd-1tb/Steam Library" kind of deal.

I'm not sure what the best solution to #1 is, however for #2, double quotes are needed to surround the variables in the early parts declaring paths and sub-paths, and then also for the cd $dir step, should be cd "$dir", and the replace_dlls step needs double quotes around both 32 and 64 bit dirs.

The double quotes may be needed for arch too, but I could be wrong there.

I had to manually adapt the script for my situation and hopefully this helps someone else in the future.

@BloodyIron
Copy link

Either way though, thanks for this script! \o/

@lc-nyovchev
Copy link

For the people who have steam installed by snap, change:

STEAM_DIR=/home/$USER/.steam/steam/steamapps

to:

STEAM_DIR=/home/$USER/snap/steam/common/.local/share/Steam/steamapps

@Principle
Copy link

After this script with GE Proton still had the sync issue, it let me get an hour into the match before that tho. I was able to play through shorter matches no problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment