Skip to content
kromster80 edited this page May 24, 2026 · 45 revisions

Instructions for project compilation

Thes instructions explains how to compile a working project.

Prerequirements

  • Microsoft Windows (7 or higher)
  • Delphi 10.3 (earlier versions may also work, though some code downgrades may be required, such as record methods and inline variables)
  • GIT client (TortoiseGit, GitHub for Windows or any other of your choice)
  • OpenGL 1.5 compliant GPU
  • Original "Knights and Merchants: The Peasants Rebellion" installed
  • Latest KaM Remake installed

Optional (can be ignored or skipped with conditional compiler switches):

  • madExcept installed
  • Lazarus (32bit, version 2.0.6 or higher) (needed if you need to compile Linux dedicated server)
  • OpenAL drivers installed (you already should have them, if sound in the KaM Remake works for you)

Walkthrough

  1. Clone the project onto your PC using Git client (instructions are given for TortoiseGit):
    • Right-click in a folder where you want the project to be (e.g. "C:\My Documents\") and select from the drop-down menu "Git Clone"
    • Specify path to the KaM Remake repository, "https://github.com/reyandme/kam_remake" and destination folder (e.g. "C:\My Documents\kam_remake\"). Git will do its job in a couple of minutes.
    • After cloning: right click on the newly cloned folder and choose "TortoiseGit -> Submodule Update ..". This should update external dependencies. Some might fail, ignore until it turns out you need them.
    • From now on paths in this guide will be written as relative to the project folder, so e.g. ".\Maps" means "C:\My Documents\kam_remake\Maps\"
  2. Copy resource files from your "Knights and Merchants: The Peasants Rebellion" installation.
    • You need ".\data" folder, copy whole of it into project folder. When asked - replace all of the existing files/folders.
  3. Copy resources from your "KaM Remake" installation.
    • Copy all the folders from your "KaM Remake" installation. When asked - replace any of the existing files/folders.
  4. Now you will need to revert any downgraded files - do the right-click menu, "TortoiseGit -> Revert...".
  5. You won't have our private network authentication unit, so open ".\KaM Remake.inc" file with Notepad, scroll down and remove a dot like so in the following line "{$DEFINE DBG_SKIP_SECURE_AUTH}" to disable it.
    • This will make Delphi execute the code within DBG_SKIP_SECURE_AUTH clauses.
    • This authentication unit makes it harder for someone to join a multiplayer game using an unofficial client that they compiled themselves.
    • If you somehow have our private network authentication unit (or you wrote your own) then you can skip this step.
  6. If you don't have madExcept installed, then open ".\KaM Remake.inc" file with Notepad, scroll half-way and place a dot like so in the following line "{.$DEFINE USE_MAD_EXCEPT}" to disable it.
    • This will make Delphi skip all the code within USE_MAD_EXCEPT clauses.
    • MadExcept is used to generate and send CrashReports to us.
    • If you have madExcept installed - skip this step.
    • If you want to install it check official website
  7. If you have access to the private repo with sprites: Use RXXPacker util to generate RXX and RXA files. This will convert sprites to the format that we use in the KaM Remake.
    • Copy all the *.rx files from ".\data\gfx\res\" to ".\SpriteResource\" folder.
    • Launch the Delphi/Lazarus and open ".\Utils\RXXPacker\RXXPacker.dpr" project.
    • Compile and launch the project.
    • Check the paths are correct relative to RXXPacker.exe (typically "....\SpriteResource" for RX, "....\SpriteInterp\Output" for interpolated and "....\data\Sprites" for destination)
    • Ensure all 6 available items are selected, RXX and RXA checked, then press "Pack selected".
    • The program will work for 5-10 min, displaying progress on the right.
  8. If you don't have VirtualTreeView installed, then open ".\KaM Remake.inc" file with Notepad and place a dot like so "{.$DEFINE USE_VIRTUAL_TREEVIEW}".
    • This will make Delphi skip all the code within USE_VIRTUAL_TREEVIEW clauses.
    • If you have VirtualTreeView installed - skip this step.
    • If you want to install it check official website and their github repo
  9. Optionally, install Delphi Project Magician, so that the saved Delphi DPROJ files are optimized for git commit/diff and aren't as bloated.
  10. Now you can open ".\KaMProjectGroup.groupproj" (if you have Delphi XE+) project and compile the project and/or its utility tools. Or ".\KaM Remake.dpr" if you have older Delphi version.
    If you open ".\KaM Remake.groupproj" there will be 2 projects with the name KaM_Remake.exe. Second in the list used for not full project compilation (faster version) and should be used with caution to avoid unexpected results due to not full recompilation of the sources.
    So make sure you select first KaM_Remake.exe project in the projects list on the very first compilation (just double click on it).
  11. If you have rights to commit to the repository directly, make sure to enable Git pre-commit hook:
  • Navigate .git\hooks\
  • Create a pre-commit file (without extension) with the following contents:
#!/bin/sh

# Get current revision count.
# If this is the first commit, HEAD does not exist yet.
if git rev-parse --verify HEAD >/dev/null 2>&1; then
    kam_revision=$(git rev-list --count HEAD)
else
    kam_revision=0
fi

# Increment because this commit will create the next revision.
kam_revision=$((kam_revision + 1))

# Update the include file.
printf 'GAME_REVISION_NUM=%s\n' "$kam_revision" > KM_Revision.inc

# Stage the updated file so it is included in the commit.
git add KM_Revision.inc

Project compilation on Lazarus details

⚠️ Warning
At this moment, the KaM Remake cannot be built on Lazarus.
  • Download Lazarus version 2.0.6 32-bit or higher with FPC (free pascal compiler) 3.2.0 or higher. Latest Lazarus version could be found at Lazarus project repository
  • Start Lazarus. Open menu Package -> Online package manager. Choose BGRABitmap and install it. After package it will be unzipped and installed. Choose 'Rebuild lazarus' on request.
  • Now you can open KaM_Remake.lpi and compile the project.

Clone this wiki locally