Skip to content

georgeto/gothic3sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gothic 3 SDK

This unofficial Gothic 3 SDK is intended for modders with experience in C++ and reverse engineering.

The Gothic 3 game engine (Genome) consists of multiple dynamic-link libraries (DLLs) that depend on one another. Therefore, each of these DLLs exports most of its functionality. We can reconstruct C++ class and function declarations from the exported symbols, which we then use to interface with the engine.

Note for existing users of the Gothic 3 SDK

In April 2025 a major overhaul of the SDK was released, which now uses CMake as its build system instead of Visual Studio. Furthermore, the previously incomplete bindings were completed, so that now there are bindings for all symbols exported by the Gothic 3 DLLs.

Binary compatibility

Gothic 3 was build using Visual Studio 2005 (platform toolset v80) so for optimal compatibility we should use the same compiler for our project. Citing the MSVC documentation regarding the topic of binary compatibility:

In Visual Studio 2013 and earlier, binary compatibility between object files (OBJs), static libraries (LIBs), dynamic libraries (DLLs), and executables (EXEs) built by using different versions of the compiler toolset and runtime libraries was not guaranteed.

But let's face it, no one wants to work with Visual Studio 2005 these days. After extensive testing I came to the conclusion that although not officially guaranteed, Visual Studio 2013 (platform toolset v120) seems to be binary compatible with the v80 compiler, at least in the areas relevant for this project. Using the v120 compiler has the advantage of an improved IDE and the ability to use C++11 language features. Even more recent versions of Visual Studio (MSVC compiler) turned out to work fine, the most recent that the Gothic 3 SDK was extensively tested with is Visual Studio 2022 (v143) with the C++17 Language Standard.

Usage

Examples of using the Gothic 3 SDK are provided in the gothic3sdk-examples repository. It also serves as a template and inspiration on how to use or integrate the Gothic 3 SDK into your own project. For a list of possible integration options, see Integration.

Building

The Gothic 3 SDK is built with CMake.

To download and build the Gothic 3 SDK (here using Visual Studio 2022) execute the following commands:

git clone https://github.com/georgeto/gothic3sdk
cd gothic3sdk
cmake -S . -B build -G "Visual Studio 17 2022" -A Win32
cmake --build build --config Release -j

The above sequence creates a build directory, generates a Visual Studio solution, and then builds the project in Release mode. If you prefer working from within Visual Studio, you can skip the last build step and instead open the generated solution in Visual Studio and then build from there.

Integration

There are several ways to integrate the Gothic 3 SDK into your project. If you use CMake as your build system, you can choose to integrate it by fetching it with a package manager like CPM.cmake or using CMake's FetchContent module. Alternatively you can include it as a Git submodule, or in vendor library style, by putting a copy of the gothic3sdk repository into your project.

CPM

To integrate the Gothic 3 SDK via CPM.cmake, add the following snippet to your project's CMakeLists.txt, which will fetch and configure the SDK automatically during the CMake generation step:

# Fetch and setup gothic3sdk.
CPMAddPackage(
  NAME gothic3sdk
  OPTIONS
    "G3SDK_HEADER_ONLY OFF"
  GITHUB_REPOSITORY georgeto/gothic3sdk
  GIT_TAG <revision to checkout>
)
include(${gothic3sdk_SOURCE_DIR}/cmake/Setup.cmake)

To see this in action, have a look at the Gothic 3 SDK examples.

Local override

If you need to override the gothic3sdk package locally, for example when you need to modify the Gothic 3 SDK itself, please refer to the local package override feature of CPM.make.

For the CMake generation step you can specify the location of your local gothic3sdk repository.

cmake -S . -B build -G "Visual Studio 17 2022" -A Win32 -DCPM_gothic3sdk_SOURCE=C:/path/to/your/local/gothic3sdk

Git submodule

To integrate the Gothic 3 SDK as a Git submodule, run the following commands in your project's root directory:

git submodule add https://github.com/georgeto/gothic3sdk.git thirdparty/gothic3sdk
git submodule update --init --recursive

Then, include the SDK into your build by adding the following line to your CMakeLists.txt:

add_subdirectory(thirdparty/gothic3sdk)
include(thirdparty/gothic3sdk/cmake/Setup.cmake)

Vendor library style

For a vendor library style integration just put a copy of the gothic3sdk into a subfolder within your project (for example, thirdparty/gothic3sdk).

Then, include the SDK into your build by adding the following line to your CMakeLists.txt:

add_subdirectory(thirdparty/gothic3sdk)
include(thirdparty/gothic3sdk/cmake/Setup.cmake)

Formatting

All code, except third-party code, is formatted with clang-format according to the style configured in .clang-format.

Exception Handling

By default C++ exception handling is disabled (see MSVC: Default exception handling behavior). This is sufficient, because Gothic 3 does not use C++ exceptions, but only structured exception handling (SEH).

In case you use a library that needs C++ exception handling, you can set target_compile_options(<my_target> PRIVATE "/EHsc") to enable it for your target (see for example Script_DumpProperties and Script_RemoteControl).

Legacy Version

For the legacy version of the Gothic 3 SDK, which does not use CMake but is only a Visual Studio Project, see the legacy branch. It should be noted, however, that the legacy version is incomplete, i.e. it is missing a lot of bindings.

Credits

About

An unofficial SDK for Gothic 3.

Resources

License

Unknown, GPL-3.0 licenses found

Licenses found

Unknown
LICENSE
GPL-3.0
COPYING

Stars

Watchers

Forks

Packages

No packages published