If you find any step in this guide unclear, seek out help on the discord.
WSL allows you run Linux commands on Windows, essential for compiling KeeperFX on Windows.
wsl --install
First, let's open a terminal that accepts Linux commands:
Ctrl
+ ~
to open VSCode's integrated terminal.wsl
into a command prompt.Ctrl
+ ~
to open VSCode's integrated terminal, then type wsl
and press Enter to open the WSL terminal.Then input these commands into your terminal:
sudo apt update
sudo apt install -y build-essential g++-mingw-w64-i686 libpng16-16
cd ~
git clone --recursive https://github.com/dkfans/keeperfx.git
File -> Clone repository
.URL
tab, then paste the KeeperFX repository URL: https://github.com/dkfans/keeperfx.git
Click on File -> Open Folder
and select the keeperfx
directory that was created when you cloned the KeeperFX source code.
keeperfx.exe
executable file. Do this and a launch.json
file will be created in the /.vscode/
folder./.vscode/
and open launch.json
.launch.json
file you can modify the "args"
section to set the map and campaign/mappack you wish to load immediately upon game launch. The "cwd"
field is your game directory where the compiled executable will be copied to.linuxscript.sh
file will be automatically created in the /.vscode/
folder.linuxscript.sh
and update the game_directory
path to your KeeperFX game installation.game_arguments
section to set the map and campaign/mappack you wish to load immediately upon game launch.Click on the 'Extensions' tab (located on the left side), search for @recommended
and install all recommended extensions.
Regarding settings.json
, launch.json
and linuxscript.sh
, if you ever need to revert these files to their defaults, you can delete them from your /.vscode/
folder, then restart VSCode and they'll be recreated from the templates. Git won't track any modifications to files inside of /.vscode/
.
F5
Ctrl
+Shift
+B
If an error occurs, follow its instructions or seek help. Once compiled, the new executable will be automatically copied to your game directory, and the game will launch automatically.
.h/.hpp
) can cause longer compile times.keeperfx.cfg
, set DISABLE_SPLASH_SCREENS=TRUE
and SKIP_HEART_ZOOM=TRUE
Alt
+F4
to instantly close the game.Shift
+F5
or hit F5
twice in order to exit the game.function () at src/main.cpp:3386
. Here, 3386
is the line number where the crash happened. If this detail isn't provided, type: -exec bt
in the debug console to help trace the cause of the crash.To compile manually instead of using the VSCode build task, follow these steps:
Open a terminal (refer to step 4) and navigate to the source code directory, if you're using VSCode's terminal then it'll be there by default. Then:
make all
to compile. For a faster compile, use make -j8 all
make clean
first.wsl make all
to compile. For a faster compile, use wsl make -j8 all
wsl make clean
first.Once the compilation is complete, the compiled files will be in the /bin/
sub-directory.
In the 'Explorer' tab of VSCode, locate the /bin/
sub-directory. Right-click on it and select "Reveal in Explorer" to view the compiled files.
Copy the files from /bin/
and paste them into your game directory, replacing existing files. Or use the terminal to copy them.
keeperfx.exe
. Alternatively, set up a game shortcut with launch arguments, or use the terminal.Use the JUSTLOG()
function to write values to the keeperfx.log
file. You can find a list of other logging functions inside globals.h
JUSTLOG("%d", name_of_variable);
JUSTLOG("%f", name_of_variable);
JUSTLOG("%s", name_of_variable);
if (get_gameturn() == 40) {
JUSTLOG("%d", name_of_variable);
}
Your three options are:
~
to view keeperfx.log
in-game and display new entries in real-timekeeperfx.log
in a text editor, this will be a static view(Linux Users) Open a terminal, navigate to your DK directory, and use:
tail -f keeperfx.log
Get-Content keeperfx.log -Wait
Command | Description |
---|---|
standard | Build binaries for 'standard release' of KeeperFX |
heavylog | Build binaries for 'heavylog release' of KeeperFX |
clean | Removes files created during previous builds |
all | Cleans if necessary, then runs standard |
package | Compress binaries and other files into 7z archive |
pkg-languages | Generate text strings DAT files from PO/POT translation sources |
pkg-gfx | Generate all graphics DAT/TAB/RAW/PAL files from PNG bitmaps |
pkg-landviews | Generate only landview graphics |
pkg-menugfx | Generate only menu graphics |
pkg-enginegfx | Generate only engine graphics |
pkg-sfx* | Generate sound DAT files from wave files. |
*This command currently does not work with WSL. You need MinGW with MSYS for it.
On Windows, your compile speed depends on the directory you installed the source code to and your WSL version.
To check your current WSL version, enter wsl --list --verbose
into a command prompt, which will also list the name of your distribution. You can set your WSL version with: wsl --set-version <NameOfDistribution> <Version>
Whether you should use WSL1 or WSL2 depends on the location you've installed your source code:
WSL1 | WSL2 | |
---|---|---|
Windows directory C:\Github\keeperfx\ |
Fast | Slow |
\\wsl$ directory /home/username/keeperfx/ |
Slow | Fast |
So with that in mind, your two options are:
\\wsl$
directoryBut because the second option is much more complex to set up and slows down Github Desktop, we recommend staying on WSL1 with the source code in a Windows directory. If VSCode ever prompts you about upgrading to WSL2, you can ignore it and click Don't show again
. WSL2 can massively slow things down if used incorrectly.
If you still want to try WSL2, you will have to:
git clone
command (see step 5) while in a WSL terminal (not a normal command prompt).File -> Open Folder
and navigate through the WSL filesystem until you find keeperfx
and open the project./mnt/d/Games/DungeonKeeper/
pkg_lang.mk:117: *** target pattern contains no '%'. Stop.
during compilation on Ubuntu, edit the pkg_lang.mk
file and comment out line 117 or whatever the specific line is. Note: This might be a rare problem.Permission issues: If your game directory is in C:\Program Files\
or C:\Program Files (x86)\
, you might get permission errors during compilation. To solve this, move your DK game folder elsewhere. Note: you'll then need to update launch.json
with your new directories.
WSL issues: Resetting WSL can potentially help with some difficult compilation errors:
wsl --list
wsl --unregister distroName
(replace 'distroName' with your listed distribution's name)wsl --install -d Ubuntu
For any other issues, ask on the discord.