|
1 | | -# OpenSHC |
| 1 | +# OpenSHC [](https://discord.gg/SKJGEGgPTv) |
| 2 | +[Join our Discord Server!](http://discord.gg/SKJGEGgPTv) |
2 | 3 |
|
3 | | -An open source re-implementation of Stronghold Crusader 1. The beloved Castle Building, Real Time Strategy, and Simulation game remastered. |
| 4 | +An open source re-implementation of Stronghold Crusader 1. The beloved Castle Building, Real Time Strategy, and Simulation game reimplemented. |
| 5 | + |
| 6 | +For running and developing this re-implementation, you need to own Stronghold Crusader 1.41 (Latin version), preferably from Steam or GOG. |
| 7 | + |
| 8 | +## Motivation |
| 9 | + |
| 10 | +The original game is a masterpiece, seeing new reignited popularity since the release of the Definitive Edition. |
| 11 | +However, the Definitive Edition does not address various shortcomings in the original game. |
| 12 | +Furthermore, the new Definitive Edition requires modern hardware to run, which isn't something all fans can afford. |
| 13 | + |
| 14 | +This reimplementation seeks to cater to the wishes of the dedicated community by providing an |
| 15 | +open source reimplementation that benefits modding to those that own the original Stronghold Crusader (available from Steam and GOG). |
4 | 16 |
|
5 | 17 | ## Usage |
6 | 18 |
|
7 | | -### Download and Install |
| 19 | +OpenSHC builds as a DLL that is loaded at game start. Functions that have a functionally identical reimplementation are hooked, such that the reimplemented versions are run instead of the original. This enables easy modding, although modding itself is currently beyond the scope of the OpenSHC project. |
8 | 20 |
|
9 | | -This reimplementation requires you to own a legal copy of the original Stronghold Crusader game from Firefly Studios. |
| 21 | +## Contribute |
10 | 22 |
|
11 | | -The current method of installation is via the [Unofficial Crusader Patch](https://github.com/UnofficialCrusaderPatch/UnofficialCrusaderPatch). Make sure to set that up first. |
| 23 | +The development of this reimplementation is a stepwise process in which we aim to achieve a functionally identical reimplementation. We track progress using various tools. |
12 | 24 |
|
13 | | -0. Set up the Unofficial Crusader Patch. |
14 | | -1. Download the latest release of the reimplementation from the Releases page of this repo. |
15 | | -2. Launch the GUI from the Unofficial Crusader Patch. |
16 | | -3. 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. |
17 | | -4. Reload the UCP3 GUI and activate the module. |
18 | | -5. Disable Security in the Launch tab of the GUI. |
19 | | -6. Launch the game! |
| 25 | +All developers are welcome to contribute. |
20 | 26 |
|
21 | | -Note that the goal is to recreate the game. So if there are no changes compared to vanilla, then it is exactly like intended. |
| 27 | +### Requirements |
22 | 28 |
|
23 | | -### Help |
| 29 | +Before you begin, install the following: |
24 | 30 |
|
25 | | -Raise an issue here on GitHub to receive support. Or visit the [Discord](https://discord.gg/27W68ZaFT4) server. |
| 31 | +* **Stronghold Crusader 1.41 (Latin version)** |
| 32 | + |
| 33 | + The Steam release is the easiest version to obtain. Make sure the game installation uses a Latin-language version such as English or German. |
26 | 34 |
|
27 | | -## Contribute |
| 35 | +* **CMake 3.24 or later** |
| 36 | + |
| 37 | + You can install it from: |
| 38 | + |
| 39 | + * [https://cmake.org/download/](https://cmake.org/download/) |
| 40 | + * [https://github.com/Kitware/CMake/releases/](https://github.com/Kitware/CMake/releases/) |
| 41 | + |
| 42 | + If you already installed the Microsoft Visual C++ Development Tools, you can also install CMake through Visual Studio. |
| 43 | + |
| 44 | +* **Python 3** |
| 45 | + |
| 46 | +* **clang-format 22 or later** |
| 47 | + |
| 48 | + Install it with: |
| 49 | + |
| 50 | + ```bash |
| 51 | + python -m pip install clang-format |
| 52 | + ``` |
| 53 | + |
| 54 | +* **An IDE with CMake support (recommended)** |
| 55 | + |
| 56 | + The repository is optimized for Visual Studio Code with the Microsoft C/C++ Extension Pack. |
| 57 | + |
| 58 | + To automatically format and style new C++ files, install the clang-format Extension Pack. |
| 59 | + |
| 60 | +--- |
28 | 61 |
|
29 | | -The development of this reimplementation is a stepwise process. All developers are welcome to contribute. |
| 62 | +### Setup |
30 | 63 |
|
31 | | -### Approach |
| 64 | +#### 1. Clone the repository |
32 | 65 |
|
33 | | -The development of this reimplementation primarily focuses on reimplementing functions and data structures of the original game. |
34 | | -The game 1.41 Latin version of the Stronghold Crusader executable serves as the reference point (SHA hash: 012E9D55DAC04B23ED9A334C975D3A5B6287020B). |
35 | | -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. |
36 | | -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. |
| 66 | +Clone the repository with submodules included: |
37 | 67 |
|
38 | | -We use [reccmp](https://github.com/isledecomp/reccmp) to verify compatibility of reimplemented code and the original game. |
| 68 | +```bash |
| 69 | +git clone --recursive https://github.com/sourcehold/OpenSHC.git |
| 70 | +``` |
39 | 71 |
|
40 | | -Because the original game was compiled using an old compiler, you have to compile it using [this compiler](https://github.com/sourcehold/MSVC1400), which is included in the repository via a submodule. |
| 72 | +Then enter the project directory: |
41 | 73 |
|
42 | | -If you made any advances or noticed something while implementing, please also add or update the status in [addresses-SHC-3BB0A8C1.txt](status/addresses-SHC-3BB0A8C1.txt). |
43 | | -The structure is simply `<address-enum> | <matching-percent> | <comment>`. |
44 | | -Should the address list change, please run the following command to recreate the file: |
45 | | -```sh |
46 | | -python .\status\extract_header_and_update.py .\src\precomp\addresses-SHC-3BB0A8C1.hpp |
| 74 | +```bash |
| 75 | +cd OpenSHC |
47 | 76 | ``` |
48 | | -Percentages and comments should be kept, but always check the difference. |
49 | 77 |
|
| 78 | +> The `--recursive` flag is required because the repository depends on submodules, including the compiler. |
50 | 79 |
|
51 | | -### Prerequisites |
| 80 | +--- |
52 | 81 |
|
53 | | -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). |
54 | | -2. CMake with the minimum version 3.24. |
55 | | -3. [Python3](https://www.python.org/) |
56 | | -4. A way to execute `clang-format` |
57 | | -5. (Recommended) An IDE with CMake integration. The repository has been optimized for Visual Studio Code using the [Microsoft C/C++ Extension Pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools-extension-pack). |
| 82 | +#### 2. Create a symbolic link to the original game |
58 | 83 |
|
59 | | -### Setup |
| 84 | +Run the following command: |
60 | 85 |
|
61 | | -1. Clone the repository. Make sure to also pull the submodules to have the compiler included: |
| 86 | +```bash |
| 87 | +softlink.bat |
| 88 | +``` |
62 | 89 |
|
63 | | - ```sh |
64 | | - git clone --recursive https://github.com/sourcehold/OpenSHC.git |
65 | | - ``` |
| 90 | +The script will ask for the full path to your Stronghold Crusader installation directory. |
66 | 91 |
|
67 | | - - 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. |
| 92 | +After the link is created, a folder named `_original` will appear in the repository root. |
68 | 93 |
|
69 | | -2. Create a softlink to the original game executable with the name `_original` by running [softlink.bat](softlink.bat). It will request the full path to the game folder. |
70 | | -3. Setup the needed Python environment to run `reccmp` for binary comparison by running [setup.bat](reccmp/dll/setup.bat) in the reccmp/dll folder (or the `setup.bat` in the reccmp/exe folder if binary comparison on the reimplemented .exe file is preferred) |
| 94 | +> This script may require administrator privileges to be able to create the symbolic link |
71 | 95 |
|
72 | | -### Development |
| 96 | +--- |
73 | 97 |
|
74 | | -The build can be run using the dev tools of the preferred IDE or via the build scripts. Regardless, a CMake installation is required. |
| 98 | +#### 3. Set up the Python environment for binary comparison |
| 99 | + |
| 100 | +To set up the binary comparison tools, run: |
| 101 | + |
| 102 | +```bash |
| 103 | +reccmp\dll\setup.bat |
| 104 | +``` |
75 | 105 |
|
76 | | -Visual Studio Code with the proper extensions only needs to open the folder and the targets can be chosen in the "CMake" menu. |
77 | | -Additionally, it configures format-on-save and a debug target for the UCP3. |
| 106 | +> In the future, if you want to setup comparison of the reimplemented executable instead of the DLL, use: |
| 107 | +> ```bash |
| 108 | +> reccmp\exe\setup.bat |
| 109 | +> ``` |
78 | 110 |
|
79 | | -If the scripts are preferred, the following triggers a build using the scripts: |
| 111 | +--- |
80 | 112 |
|
81 | | -1. Open a terminal. |
82 | | -2. Navigate to this project folder |
83 | | -3. Execute build.bat: |
84 | | - ```sh |
85 | | - build.bat RelWithDebInfo |
86 | | - ``` |
87 | | -4. Compare a function byte by byte to the OpenSHC.dll to check compilation: |
88 | | - ```sh |
89 | | - reccmp/dll/run reccmp-reccmp --target STRONGHOLDCRUSADER --verbose 0x401000 |
90 | | - ``` |
| 113 | +### Verifying the Setup |
91 | 114 |
|
92 | | -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. |
| 115 | +If **both** commands complete successfully, your development environment is ready and you can start working on OpenSHC. |
93 | 116 |
|
94 | | -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. |
| 117 | +#### 1. Build the project |
95 | 118 |
|
96 | | -If any `.cpp` or `.c` files are added to the source code, they should be listed in one of the txt files in `cmake/`: |
| 119 | +From the `OpenSHC` directory, run: |
97 | 120 |
|
98 | | -- `cmake/core-sources.txt` containing the core sources to compile the project. |
99 | | -- `cmake/pklib-sources.txt` containing the source files for compiling the pklib dependency. |
100 | | -- `cmake/openshc-sources.txt` containing the files with reimplementations of the original game's functions. |
| 121 | +```bash |
| 122 | +build.bat RelWithDebInfo OpenSHC.dll |
| 123 | +``` |
| 124 | +
|
| 125 | +--- |
| 126 | + |
| 127 | +#### 2. Run binary comparison |
| 128 | + |
| 129 | +This verifies byte-level accuracy between the reimplementation and the original binary: |
| 130 | + |
| 131 | +```bash |
| 132 | +reccmp/dll/run reccmp-reccmp --target STRONGHOLDCRUSADER |
| 133 | +``` |
101 | 134 |
|
102 | | -You can also create a local only `cmake/openshc-sources.txt.local` file, which will be used instead of `cmake/openshc-sources.txt` if it exists, to allow faster tests. |
103 | | -Extending this files name in any way, like `openshc-sources.txt.local.bak`, will prevent it from being used, but it is still ignored by git. This allows to keep small local file lists. |
| 135 | +> Tip: use `reccmp/dll/run reccmp-reccmp --target STRONGHOLDCRUSADER --verbose <hex address of function>` to investigate code byte mismatches. |
104 | 136 |
|
105 | | -#### Manual configuration |
| 137 | +--- |
106 | 138 |
|
107 | | -The file `build.bat` exists for convenience. If you want more control, you can specify the following cmake options. |
| 139 | +## Tutorials |
| 140 | +When you are set up, follow any of the [tutorials](https://sourcehold.github.io/OpenSHC/wiki/tutorials/reimplementation-tutorial-1.html) to get you started! |
108 | 141 |
|
109 | | -##### Building |
110 | 142 |
|
111 | | -Build using `cmake --build --preset RelWithDebInfo --target OpenSHC.dll` will create the dll in `build-RelWithDebInfo/DLL`. |
112 | | -Build using `cmake --build --preset RelWithDebInfo --target OpenSHC.exe` will create the exe in `build-RelWithDebInfo/EXE`. |
113 | | -Build using `cmake --build --preset RelWithDebInfo --target OpenSHC.dll.deploy` will prepare the modules folder in the UCP setup of the bound SHC. |
114 | | -Build using `cmake --build --preset RelWithDebInfo --target OpenSHC.exe.runnable` will prepare the runtime folder of the exe to make it runnable. |
| 143 | +## Help |
| 144 | +Raise an issue here on GitHub to receive support. Or visit the [Discord](https://discord.gg/SKJGEGgPTv) server. |
0 commit comments