Skip to content

sourcehold/OpenSHC

Repository files navigation

OpenSHC

An open source re-implementation of Stronghold Crusader 1. The beloved Castle Building, Real Time Strategy, and Simulation game remastered.

Usage

Download and Install

This reimplementation requires you to own a legal copy of the original Stronghold Crusader game from Firefly Studios.

The current method of installation is via the Unofficial Crusader Patch. Make sure to set that up first.

  1. Set up the Unofficial Crusader Patch.
  2. Download the latest release of the reimplementation from the Releases page of this repo.
  3. Launch the GUI from the Unofficial Crusader Patch.
  4. Drag and drop the zip file unto your open UCP3 GUI, or manually move the zip file into the ucp/modules folder inside your game folder.
  5. Reload the UCP3 GUI and activate the module.
  6. Disable Security in the Launch tab of the GUI.
  7. Launch the game!

Note that the goal is to recreate the game. So if there are no changes compared to vanilla, then it is exactly like intended.

Help

Raise an issue here on GitHub to receive support. Or visit the Discord server.

Contribute

The development of this reimplementation is a stepwise process. All developers are welcome to contribute.

Approach

The development of this reimplementation primarily focuses on reimplementing functions and data structures of the original game. The game 1.41 Latin version of the Stronghold Crusader executable serves as the reference point (SHA hash: 012E9D55DAC04B23ED9A334C975D3A5B6287020B). To achieve this, a combination approach is used. The code has mechanisms in place to allow a compilation to both and executable and a DLL. The DLL is meant to be loaded by the UCP and only replace certain functions, while other calls would call into the games executable. This allows to reimplement one function after the other while still maintaining a runnable game.

We use reccmp to verify compatibility of reimplemented code and the original game.

Because the original game was compiled using an old compiler, you have to compile it using this compiler, which is included in the repository via a submodule.

Prerequisites

  1. Stronghold Crusader 1.41 Latin. The Steam version is the easiest one to get, but any patched version will do. Make sure the installation uses a Latin version (English, German, etc).
  2. CMake with the minimum version 3.24.
  3. Python3
  4. A way to execute clang-format
  5. (Recommended) An IDE with CMake integration. The repository has been optimized for Visual Studio Code using the Microsoft C/C++ Extension Pack.

Setup

  1. Clone the repository. Make sure to also pull the submodules to have the compiler included:
    git clone --recursive https://github.com/sourcehold/OpenSHC.git
    • Should NET Framework 3.5 be required, it can be easily installed on Windows 11 by running mt.exe (from the MSVC1400 repo), Windows 11 will ask to install the right version.
  2. Create a softlink to the original game executable with the name _original by running softlink.bat. It will request the full path to the game folder.
  3. Setup the needed Python environment to run reccmp for binary comparison by running setup.bat in the reccmp folder.

Development

The build can be run using the dev tools of the preferred IDE or via the build scripts. Regardless, a CMake installation is required.

Visual Studio Code with the proper extensions only needs to open the folder and the targets can be chosen in the "CMake" menu. Additionally, it configures format-on-save and a debug target for the UCP3.

If the scripts are preferred, the following triggers a build using the scripts:

  1. Open a terminal.
  2. Navigate to this project folder
  3. Execute build.bat:
    build.bat RelWithDebInfo
  4. Compare a function byte by byte to check compilation:
    reccmp/run reccmp-reccmp --target STRONGHOLDCRUSADER --verbose 0x401000

If CMake is installed and not in PATH, for example if installed via Visual Studio, cmakew.bat can be used instead. It tries to detect a CMake installation and uses it.

Note that any code needs to be formatted properly using the provided clang-format. The way to do so it up to the developer. Many IDEs support it out of the box.

If any .cpp or .c files are added to the source code, they should be listed in one of the txt files in cmake/:

  • cmake/core-sources.txt containing the core sources to compile the project.
  • cmake/pklib-sources.txt containing the source files for compiling the pklib dependency.
  • cmake/openshc-sources.txt containing the files with reimplementations of the original game's functions.

Manual configuration

The file build.bat exists for convenience. If you want more control, you can specify the following cmake options.

Output folder of dll

Use cmake --preset RelWithDebInfo -D OPEN_SHC_DLL_DEST=.\build-RelWithDebInfo\dll to specify the destination folder for the .dll and .pdb files in favor of the default.

Note this setting will remain present even if you remove the -D option later from the command. To actually clear this configuration, use cmake --preset RelWithDebInfo --fresh.

Building

Build using cmake --build --preset RelWithDebInfo --target OpenSHC.dll

About

An open source re-implementation of Stronghold Crusader

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •