PR on Linux+Wine – A text-based install guide

Help and support regarding PR:BF2 installation and in-game issues
Locked
User avatar
bad_nade
Support Technician
Posts: 1497
Joined: 2008-04-06 18:26
Location: Finland

PR on Linux+Wine – A text-based install guide

Post by bad_nade »

Installing Project Reality: BF2 on Linux
Opinionated guide for installing PR on Arch Linux using the latest wine-staging as the compatibility layer.
I'm not saying this is the only way, or the correct way, but this is how I like to do it.

Credits
I want to give special thanks to [R-COM] PvtNewb for researching and solving most of the technical issues of installing PR on Linux. I'm a long-time casual UNIX/Linux user, but creating this guide was my first contact with Wine. Finding answers to questions like which Linux flavour gives the best chances of success, what software packages need to be installed, debugging the login flow, disabling ASLR, and the base concept of the helper script were all [R-COM] PvtNewb's ideas. I then refined those ideas, sometimes converting them from screenshots to command line compatible form, and composed this guide into its current form.

Disclaimer
This works for me. Your mileage may vary.

Instructions
Complete all four parts, copy-pasting and running each shell command in the order they are listed.

After the fourth part you should see a PR icon on your desktop and in your menus. Use the icon to start PR. You can also run the helper script prbf2.sh from the command line to start PR, optionally with Wine debugging and other advanced options enabled.

Spoiler for Part 1 of 4:
Prerequisites and assumptions
  • Arch Linux up and running
  • X11, or Wayland with XWayland up and running
  • multilib repository is enabled (no 32-bit binaries will be installed)
  • sudo rights
  • shell commands in this guide are written for bash
  • latest PR full installer (v1.8.0.0 as of this writing) downloaded and extracted to $XDG_DOWNLOAD_DIR (default $HOME/Downloads)
  • Microsoft Edge installer downloaded to $XDG_DOWNLOAD_DIR
Start with a full system upgrade
A reboot is highly recommended after the upgrade.

Code: Select all

sudo pacman -Syu
Install Wine packages

Code: Select all

sudo pacman -S \
 wine-staging \
 wine-gecko \
 winetricks
Define environment variables for the install phase
Variables required for playing will be set later in this guide.

Code: Select all

: ${XDG_DATA_HOME:=${HOME}/.local/share}
: ${XDG_DOWNLOAD_DIR:=${HOME}/Downloads}
: ${XDG_DESKTOP_DIR:=${HOME}/Desktop}
export WINEPREFIX="${XDG_DATA_HOME}/wineprefixes/pr"
export WINEARCH=wow64
export WINEDEBUG=-all
Create and initialize our custom prefix

Code: Select all

mkdir -p "${WINEPREFIX}"
wineboot --init
Install dependencies

Code: Select all

winetricks --unattended \
 corefonts \
 vcrun2019 \
 d3dx9 \
 dotnet48 \
 d3dcompiler_42 \
 d3dcompiler_43 \
 d3dcompiler_46 \
 d3dcompiler_47
Install DXVK
Requires a GPU that supports Vulkan 1.3 or newer. See the DXVK wiki for detailed system requirements.

Code: Select all

winetricks --unattended dxvk
Spoiler for Part 2 of 4:
Install Microsoft Edge
A Windows-based browser is required for Steam Community login. PR uses Steam to authenticate online players.

Run the installer

Code: Select all

wine "${XDG_DOWNLOAD_DIR}/MicrosoftEdgeSetup.exe"
Make it the default browser
For HTTP

Code: Select all

wine reg.exe \
 ADD \
 "HKEY_CLASSES_ROOT\\http\\shell\\open\\command" \
 /ve \
 /d "\"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe\" %1" \
 /f
For HTTPS

Code: Select all

wine reg.exe \
 ADD \
 "HKEY_CLASSES_ROOT\\https\\shell\\open\\command" \
 /ve \
 /d "\"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe\" %1" \
 /f
Spoiler for Part 3 of 4:
Helper script
Use this script to start PR once it's installed. The script is designed to work with both the command line and the Desktop Environment's launcher files.

Create the $HOME/.local/bin directory

Code: Select all

mkdir -p "${HOME}/.local/bin"
Create the prbf2.sh helper script

Code: Select all

cat >"${HOME}/.local/bin/prbf2.sh" <<'EOF'
#!/bin/sh

usage() {
  echo "Usage: ${0} {start <ARGS>|login [URL]}"
  echo "  ARGS (optional): Run '${0} start +help' for the list of supported arguments."
  echo "  URL  (required): URL should be provided automatically by the MIME protocol handler."
}

if [ ${#} -eq 0 ]; then
  usage
  exit 2
fi

## Uncomment to force the use of Wayland instead of XWayland
#if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
#  unset DISPLAY
#fi

# Use the custom prefix by default
: ${XDG_DATA_HOME:=${HOME}/.local/share}
export WINEPREFIX="${WINEPREFIX:-${XDG_DATA_HOME}/wineprefixes/pr}"

# Overrideable defaults for debug and performance settings
export WINEDEBUG="${WINEDEBUG--all}"
export STAGING_SHARED_MEMORY="${STAGING_SHARED_MEMORY-1}"
export STAGING_WRITECOPY="${STAGING_WRITECOPY-1}"
export STAGING_RT_PRIORITY_SERVER="${STAGING_RT_PRIORITY_SERVER-90}"
export STAGING_RT_PRIORITY_BASE="${STAGING_RT_PRIORITY_BASE-90}"

# Ensure 32-bit support is always enabled
export WINEARCH=wow64

# Working directory is required by PRLauncher.exe
cd "${WINEPREFIX}/dosdevices/c:/pr/prbf2/mods/pr/bin" || exit ${?}

verb="${1}"; shift
rc=0

case "${verb}" in
  start)
    cat /dev/null >wine-prlauncher.log
    setarch --addr-no-randomize wine PRLauncher.exe "${@}" &>>wine-prlauncher.log &
    rc=${?}
    ;;
  login)
    cat /dev/null >wine-prlauncherlogin.log
    wine PRLauncherLogin.exe "${1}" &>>wine-prlauncherlogin.log &
    rc=${?}
    ;;
  *)
    usage
    rc=2
    ;;
esac

exit ${rc}
EOF
Make it executable

Code: Select all

chmod a+x "${HOME}/.local/bin/prbf2.sh"
Spoiler for Part 4 of 4:
Install PR outside Wine prefix
Makes life easier if you ever have to nuke your Wine prefix or reinstall PR.
From Wine's point of view, the destination path will be c:\pr\prbf2.

Create a dedicated directory for Project Reality

Code: Select all

mkdir -p "${XDG_DATA_HOME}/ProjectReality"
Add it as the c:\pr directory inside the current $WINEPREFIX

Code: Select all

ln -s "${XDG_DATA_HOME}/ProjectReality" "${WINEPREFIX}/dosdevices/c:/pr"
Run the Project Reality: BF2 installer in unattended mode
A progress window will be shown, but without user-selectable options. After this step, you must run also the subsequent path fixing step before attempting to play PR.

Code: Select all

wine "${XDG_DOWNLOAD_DIR}/prbf2_1.8.0.0_full/setup.exe" \
 /DIR=c:\\pr\\prbf2 \
 /SILENT
Fix paths in menu and desktop icons

Code: Select all

sed --in-place \
 --separate \
 --expression="s;^Exec\s*=.*;Exec=\"${HOME}/.local/bin/prbf2.sh\" start;" \
 "${XDG_DATA_HOME}/applications/wine/Programs/Project Reality/Project Reality BF2/Project Reality BF2.desktop" \
 "${XDG_DESKTOP_DIR}/Project Reality BF2.desktop"
Spoiler for Appendix A: Troubleshooting and support info:
Spoiler for Appendix B: Files and directories:
List of notable files and folders used in this guide.
  • $XDG_DATA_HOME
  • $XDG_DOWNLOAD_DIR, $XDG_DESKTOP_DIR
    • Part of XDG well-known user directories. If not set, $HOME/Downloads and $HOME/Desktop are used, respectively.

  • $HOME/.local/bin/prbf2.sh
    • Helper script that is used to start PR. Supports also host OS browser-based Steam login, but by default login is handled entirely inside Wine session.

  • $XDG_DATA_HOME/wineprefixes/pr
    • Custom $WINEPREFIX directory (a.k.a. bottle) which is used to run PR.

  • $XDG_DATA_HOME/ProjectReality
    • Container directory for the PR root directory. Symlinked to c:\pr inside the prefix.

  • $WINEPREFIX/dosdevices/c:/pr/prbf2
    • Root directory for all PR game files. Same location as $XDG_DATA_HOME/ProjectReality/prbf2.

  • $WINEPREFIX/dosdevices/c:/pr/prbf2/mods/pr/bin
    • Location of PR utility executables, like PRLauncher.exe, and also PR and Wine log files.

  • $XDG_DESKTOP_DIR/Project Reality BF2.desktop
    • PR desktop icon, if supported by the Desktop Environment.

  • $XDG_DATA_HOME/applications/wine/Programs/Project Reality/Project Reality BF2/Project Reality BF2.desktop
    • PR icon in the Desktop Environment's application menu, if supported.

  • $XDG_DATA_HOME/applications/wine-protocol-prlauncher-login.desktop
    • MIME type handler for the prlauncher-login protocol. The protocol is used to pass login information from the browser to PR.

  • $XDG_DATA_HOME/applications/wine-protocol-prbf2.desktop
    • MIME type handler for the prbf2 protocol. No longer in use. The protocol provided a method for starting PR and joining to a game server in one action. Syntax of a protocol URL is prbf2://GAME_SERVER_IP:PORT.

Spoiler for Appendix C: Obsolete steps:
The following steps are obsolete in the context of this guide and can be skipped. They are included here only for completeness.
Spoiler for Obsolete:
Disable dxvk for PRLauncher.exe by overriding d3d9.dll
Has no effect if dxvk is not installed, and has no effect on PR main executable.

Code: Select all

wine reg.exe \
 ADD \
 HKEY_CURRENT_USER\\Software\\Wine\\AppDefaults\\PRLauncher.exe\\DllOverrides \
 /v d3d9 \
 /d builtin \
 /f
Change renderer to winevulkan
Not needed with dxvk. Default renderer is gl.

Code: Select all

wine reg.exe \
 ADD \
 HKEY_CURRENT_USER\\Software\\Wine\\Direct3D \
 /v renderer \
 /d vulkan \
 /f
Fix the path in the prlauncher-login protocol handler
This step can be skipped. The file is not needed nor is it created, if the prefix has Windows-based browser installed and available.

Code: Select all

sed --in-place \
 --expression="s;^Exec\s*=.*;Exec=\"${HOME}/.local/bin/prbf2.sh\" login %u;" \
 "${XDG_DATA_HOME}/applications/wine-protocol-prlauncher-login.desktop"
Register it

Code: Select all

xdg-mime default wine-protocol-prlauncher-login.desktop x-scheme-handler/prlauncher-login
Fix the path in the prbf2 protocol handler
This step can be skipped. The protocol is no longer in use.

Code: Select all

sed --in-place \
 --expression="s;^Exec\s*=.*;Exec=\"${HOME}/.local/bin/prbf2.sh\" start +join %u;" \
 "${XDG_DATA_HOME}/applications/wine-protocol-prbf2.desktop"
Register it

Code: Select all

xdg-mime default wine-protocol-prbf2.desktop x-scheme-handler/prbf2
Refresh the database of Desktop entires

Code: Select all

update-desktop-database "${XDG_DATA_HOME}/.local/share/applications"
Locked

Return to “PR:BF2 Support”