[Guide/Research] XWAUP/DSUCP v1.6 on Linux
Posted: Mon Apr 01, 2019 5:41 pm
Dear pilots,
This thread is meant to be, on the one hand, a guide for Linux users as to how to get X-Wing Alliance XWAUP/DSUCP v1.6 installed (and to get the gaming experience as close to native Windows as possible), on the other hand, a research report on some of the issues I have come across, which may potentially be of some interest to people working on the XWAUP project and its components.
Please note that if you are a Linux user and you're willing to try this guide to get XWAUP/DSUCP v1.6 installed, you need to be fluent enough in Linux in general and in using Wine in particular. You should know how to set up a custom Wine prefix with a specific Wine build, whether manually or by using tools like PlayOnLinux or Lutris.
As a person with no Windows machine (by choice), I've been playing the X-Wing series games (all of them, starting with the DOS games and up to and including XvT:BoP and XWA) on Linux for many years. I have installed and tried every single major patch and mod on these games, most of them successfully (the only mod I couldn't get running under Linux is Reshade).
As for XWAUP/DSUCP, I've played every release of the mod starting with v1.2 and up to and including the (currently most recent) v1.6. Most older versions (v1.5 and below) were easy enough to install and worked very well practically out of the box, while v1.6 needed some manual tweaking to get it working without crashing on startup.
So, first things first, how I got XWAUP/DSUCP v1.6 running on Linux.
Note: this was tried on an Intel Core i7-4770 machine with 16 GB RAM and a NVIDIA GTX 960 video card with 4 GB VRAM running Linux Mint 18.3 Cinnamon edition. Your mileage may vary on different hardware and software configurations.
1. You will need a custom Wine prefix for this installation, so please create one. I used a 64-bit Wine prefix, but possibly a 32-bit may suffice. You can use PlayOnLinux/Lutris to manage your custom Wine prefix, or you can make one manually.
2. You will need a recent enough Wine version. Any current Staging version of Wine will do (e.g. 4.4-Staging).
4. If you're planning to use Justagai's 60 fps hook in this Wine prefix, or if you're planning to use tools such as YOGEME, or if you're planning to use anything else that requires .NET Framework, or you'd like to play other games (e.g. XvT:BoP) with that 60 fps patch mentioned before, make sure you get a recent version of Winetricks and use it to install .NET Framework v4.6.1 inside this Wine prefix (use ./winetricks dotnet461 to accomplish that, and make sure you fully go through all the installation procedures - 4.0, 4.5, and 4.6.1 will be installed in succession). Note that this is recommended (check out step 10 for the reason why).
5. Since XWA with XWAUP/DSUCP uses hooks called from dinput.dll, and the DirectDraw patch which we are going to use overrides ddraw.dll, you need to set your Wine prefix up to allow the use of native versions of these libraries. Launch Wine configuration on your custom prefix (winecfg) and add dinput.dll and ddraw.dll to the list of DLL overrides (they should be set to "native,builtin") - you will be warned that it's not recommended to override these libraries, but you can and indeed should ignore this warning in this specific case.
6. Time to get XWA installed inside your custom Wine prefix. Personally I installed the GOG version of the game (I prefer GOG over Steam), but you should in theory be able to install other versions of the game as well, even the CD versions (that's what I used to do before I bought the GOG version). GOG version is probably the easiest to install though since it involves just running and completing the installation procedure from a single .exe file.
7. Once XWA is installed, install XWAUP v1.6 or DSUCP v1.6 (your choice). You can choose any options you prefer, I mostly stuck with the defaults. I also chose the resolution of my monitor (1920x1080) when prompted. Let the installation finish, it should complete without errors and warnings.
8. Now, if this were XWAUP/DSUCP v1.5 or earlier, the game would have worked at this point as is. However, in XWAUP/DSUCP v1.6, a recent change in one of the hooks (Hook_Opt_Limit.dll) currently prevents the game from working on Wine/DXVK without crashing (with the included DDraw.dll that makes the game run on D3D11), and the game would most likely crash with a memory allocation error as soon as you go into the flight engine (interestingly, it can randomly succeed in launching, but very rarely). I have come to a conclusion that it's due to the way DXVK's memory allocator is implemented, and there's little that can be done at this point with that. I tried a few workarounds, but they tend to lead to crashes in missions with many different objects. Therefore, we'll resort to using a different custom DDraw which will work just fine. We'll use a modified Aqrit's DLL, which personally I grabbed from here: https://workupload.com/file/fXsasZps
Download and install it by extracting it into the XWA+XWAUP/DSUCP folder. Overwrite the ddraw.dll which is already there.
9. Check out the settings in aqrit.cfg. I did not change any of them, but your mileage may vary. Note that it's not possible to set the single processor affinity in aqrit.cfg, since it'll slow down the game massively. We'll have to use a different approach to restrict the game to a single CPU core (check out below).
10. At this point, the game should work. However, the way Hook_Time.dll unlocks the FPS in the briefing room seems to not play ball with Aqrit's DDraw.dll - the briefings will be blazing fast and you'll barely be able to understand what's going on. If you're unhappy with that (probably), you can delete Hook_Time.dll from your XWAUP/DSUCP installation folder, then download Justagai's 60 FPS hook from here and put it in the game folder instead: https://onedrive.live.com/?authkey=!ANV ... 981!219391
Note that if you do this, you'll need .NET Framework v4.6.1 installed for this hook to work (check out step 4)
11. Now we need to restrict the game's affinity to a single CPU core. We can accomplish this by making a startup script. For example, create a file called Start_XWingAlliance.sh in your XWAUP/DSUCP folder, with these contents:
wine xwingalliance.exe &
sleep 1
taskset -cp 0 $!
(modify the path to wine as necessary if using a custom prefix, e.g.: WINEPREFIX=<path_to_wineprefix> /path/to/custom_wine/bin/wine xwingalliance.exe &
Once that is done, change its permissions to allow execution (e.g. chmod +x ./Start_XwingAlliance.sh)
12. You're now ready to play the game. Use the script we created in step 11 to play the game with XWAUP/DSUCP 1.6. Enjoy!
------
Thanks a lot for your attention, fellow pilots!
Hopefully this guide/info will be of use to some of you who are using alternative operating systems and are trying to get the modded game to work using Wine.
This thread is meant to be, on the one hand, a guide for Linux users as to how to get X-Wing Alliance XWAUP/DSUCP v1.6 installed (and to get the gaming experience as close to native Windows as possible), on the other hand, a research report on some of the issues I have come across, which may potentially be of some interest to people working on the XWAUP project and its components.
Please note that if you are a Linux user and you're willing to try this guide to get XWAUP/DSUCP v1.6 installed, you need to be fluent enough in Linux in general and in using Wine in particular. You should know how to set up a custom Wine prefix with a specific Wine build, whether manually or by using tools like PlayOnLinux or Lutris.
As a person with no Windows machine (by choice), I've been playing the X-Wing series games (all of them, starting with the DOS games and up to and including XvT:BoP and XWA) on Linux for many years. I have installed and tried every single major patch and mod on these games, most of them successfully (the only mod I couldn't get running under Linux is Reshade).
As for XWAUP/DSUCP, I've played every release of the mod starting with v1.2 and up to and including the (currently most recent) v1.6. Most older versions (v1.5 and below) were easy enough to install and worked very well practically out of the box, while v1.6 needed some manual tweaking to get it working without crashing on startup.
So, first things first, how I got XWAUP/DSUCP v1.6 running on Linux.
Note: this was tried on an Intel Core i7-4770 machine with 16 GB RAM and a NVIDIA GTX 960 video card with 4 GB VRAM running Linux Mint 18.3 Cinnamon edition. Your mileage may vary on different hardware and software configurations.
1. You will need a custom Wine prefix for this installation, so please create one. I used a 64-bit Wine prefix, but possibly a 32-bit may suffice. You can use PlayOnLinux/Lutris to manage your custom Wine prefix, or you can make one manually.
2. You will need a recent enough Wine version. Any current Staging version of Wine will do (e.g. 4.4-Staging).
4. If you're planning to use Justagai's 60 fps hook in this Wine prefix, or if you're planning to use tools such as YOGEME, or if you're planning to use anything else that requires .NET Framework, or you'd like to play other games (e.g. XvT:BoP) with that 60 fps patch mentioned before, make sure you get a recent version of Winetricks and use it to install .NET Framework v4.6.1 inside this Wine prefix (use ./winetricks dotnet461 to accomplish that, and make sure you fully go through all the installation procedures - 4.0, 4.5, and 4.6.1 will be installed in succession). Note that this is recommended (check out step 10 for the reason why).
5. Since XWA with XWAUP/DSUCP uses hooks called from dinput.dll, and the DirectDraw patch which we are going to use overrides ddraw.dll, you need to set your Wine prefix up to allow the use of native versions of these libraries. Launch Wine configuration on your custom prefix (winecfg) and add dinput.dll and ddraw.dll to the list of DLL overrides (they should be set to "native,builtin") - you will be warned that it's not recommended to override these libraries, but you can and indeed should ignore this warning in this specific case.
6. Time to get XWA installed inside your custom Wine prefix. Personally I installed the GOG version of the game (I prefer GOG over Steam), but you should in theory be able to install other versions of the game as well, even the CD versions (that's what I used to do before I bought the GOG version). GOG version is probably the easiest to install though since it involves just running and completing the installation procedure from a single .exe file.
7. Once XWA is installed, install XWAUP v1.6 or DSUCP v1.6 (your choice). You can choose any options you prefer, I mostly stuck with the defaults. I also chose the resolution of my monitor (1920x1080) when prompted. Let the installation finish, it should complete without errors and warnings.
8. Now, if this were XWAUP/DSUCP v1.5 or earlier, the game would have worked at this point as is. However, in XWAUP/DSUCP v1.6, a recent change in one of the hooks (Hook_Opt_Limit.dll) currently prevents the game from working on Wine/DXVK without crashing (with the included DDraw.dll that makes the game run on D3D11), and the game would most likely crash with a memory allocation error as soon as you go into the flight engine (interestingly, it can randomly succeed in launching, but very rarely). I have come to a conclusion that it's due to the way DXVK's memory allocator is implemented, and there's little that can be done at this point with that. I tried a few workarounds, but they tend to lead to crashes in missions with many different objects. Therefore, we'll resort to using a different custom DDraw which will work just fine. We'll use a modified Aqrit's DLL, which personally I grabbed from here: https://workupload.com/file/fXsasZps
Download and install it by extracting it into the XWA+XWAUP/DSUCP folder. Overwrite the ddraw.dll which is already there.
9. Check out the settings in aqrit.cfg. I did not change any of them, but your mileage may vary. Note that it's not possible to set the single processor affinity in aqrit.cfg, since it'll slow down the game massively. We'll have to use a different approach to restrict the game to a single CPU core (check out below).
10. At this point, the game should work. However, the way Hook_Time.dll unlocks the FPS in the briefing room seems to not play ball with Aqrit's DDraw.dll - the briefings will be blazing fast and you'll barely be able to understand what's going on. If you're unhappy with that (probably), you can delete Hook_Time.dll from your XWAUP/DSUCP installation folder, then download Justagai's 60 FPS hook from here and put it in the game folder instead: https://onedrive.live.com/?authkey=!ANV ... 981!219391
Note that if you do this, you'll need .NET Framework v4.6.1 installed for this hook to work (check out step 4)
11. Now we need to restrict the game's affinity to a single CPU core. We can accomplish this by making a startup script. For example, create a file called Start_XWingAlliance.sh in your XWAUP/DSUCP folder, with these contents:
wine xwingalliance.exe &
sleep 1
taskset -cp 0 $!
(modify the path to wine as necessary if using a custom prefix, e.g.: WINEPREFIX=<path_to_wineprefix> /path/to/custom_wine/bin/wine xwingalliance.exe &
Once that is done, change its permissions to allow execution (e.g. chmod +x ./Start_XwingAlliance.sh)
12. You're now ready to play the game. Use the script we created in step 11 to play the game with XWAUP/DSUCP 1.6. Enjoy!
------
Thanks a lot for your attention, fellow pilots!
Hopefully this guide/info will be of use to some of you who are using alternative operating systems and are trying to get the modded game to work using Wine.