Skip to content

Instantly share code, notes, and snippets.

@TechT10n
Last active May 23, 2024 07:26
Show Gist options
  • Save TechT10n/79b853003f2e9841a18e8b6decd0fd3e to your computer and use it in GitHub Desktop.
Save TechT10n/79b853003f2e9841a18e8b6decd0fd3e to your computer and use it in GitHub Desktop.
#!/bin/bash
# Just a simple bash script to automate extracting & moving a required dll to fix multiplayer sync-error issue.
# All credit for the script to TechT10n
# Credit for writing down the steps for this solution goes to jrbergen, who in turn got the solution from Cytomax55.
# More details here: https://gist.github.com/jrbergen/0ce746676c4fbcc2becd6054d1bba2ed
# and here: https://github.com/ValveSoftware/Proton/issues/3875#issuecomment-764191557
# Below is the default Steam library location.
# Change the path for STEAM_ROOT if you do not use the default location for your Steam Library (do NOT include the trailing /)
STEAM_ROOT=~/.steam/steam
STEAM_PATH=${STEAM_ROOT}/steamapps/compatdata/231430/pfx/drive_c/windows/system32
DLL_FILE=ucrtbase.dll
# If the link to download the right version of VCredist changes in the future, you can change the link below.
VCREDIST_DOWNLOAD_LINK=https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x64.exe
# Define some colors for fluff / more readable output
GREEN=$(tput setaf 2)
BLUE=$(tput setaf 4)
NORMAL=$(tput sgr0)
RED=$(tput setaf 1)
printf "${BLUE}This script requires sudo permissions to copy to the Steam path, \n"
printf " as well as to change the owner/group for the DLL to the current user.\n"
printf " It shouldn't use sudo permissions for anything else.\n${NORMAL}"
sudo -v # Ask sudo permission to change the user owner/group for the .DLL
mkdir -p tmp
wget -P tmp $VCREDIST_DOWNLOAD_LINK
cabextract tmp/vc_redist.x64.exe --dir tmp
cabextract tmp/a10 --dir tmp
cp tmp/${DLL_FILE} .
sudo -n cp tmp/${DLL_FILE} "${STEAM_PATH}/"
rm -rf tmp
USER=$(whoami)
GROUP=$(id -g)
if [[ -e "${STEAM_PATH}/${DLL_FILE}" ]]
then
sudo -n chown ${USER} "${STEAM_PATH}/${DLL_FILE}"
sudo -n chgrp ${GROUP} "${STEAM_PATH}/${DLL_FILE}"
else
printf "%40s\n" "${RED}Failure:${BLUE} setting the group/owner for the .DLL failed."
printf " Did you provide the right Steam path, and is CoH2 installed via Steam?\n"
printf " If that is not the issue, try performing the script steps manually.${NORMAL}\n\n"
set -e && false # Exit script
fi
CHKFILE="${STEAM_PATH}/${DLL_FILE}"
if [[ -e "${CHKFILE}" ]]
then
printf "%40s\n" "${GREEN}Success:${BLUE} ${DLL_FILE} was copied to ${STEAM_PATH}${NORMAL}\n"
else
printf "%40s\n" "${RED}Failure:${BLUE} ${DLL_FILE} file copy failed. Try performing the script steps manually.${NORMAL}"
fi
@TechT10n
Copy link
Author

TechT10n commented Apr 3, 2023

All credit for this solution goes to jbergen.

Here is the original post that identifies in more detail what this script is doing and why.

To run this, you will need to have sudo rights on your machine. You also need to have wget and cabextract installed.

To install dependancies

# for arch (SteamDeck / SteamOS)
sudo pacman -Syu && sudo pacman -S cabextract wget 

# for RedHat based distros
sudo dnf update
sudo dnf install wget cabextract

# for debian based distros
sudo apt-get update && sudo apt-get upgrade
sudo apt install wget cabextract

Then run the script

chmod +x coh2_multiplayer_fix.sh
./coh2_multiplayer_fix.sh

@jrbergen
Copy link

Thanks @TechT10n! Can I add a link to your script on the gist page? That way people can just run this script; way easier, and more people potentially playing CoH on Linux :).

Perhaps we can also copy this one for coh3 (I suppose only the steam game ID will have to change).

@jrbergen
Copy link

jrbergen commented Apr 20, 2023

FYI: I took the liberty to make a few minor changes to your script in my fork of your script (forked to allow me to easily change).
If you like them, feel free to merge them.

@TechT10n
Copy link
Author

Thanks @jrbergen. I do like your changes and have merged them in.

Absolutely feel free to link, use, or improve this script in any way you like.

@jrbergen
Copy link

Awesome, Thanks! I'll add a link to your script in my gist.

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