Next Previous Contents

2. Compilation, Installation, and Use

This section ??? will cover details of compiling the sources for C and C++, common pitfalls, where to install the resulting file, troubleshooting and verifying the game is using the DLL, and related issues.

2.1 Minimal DLL

2.2 DM-only DLL

2.3 Switching the DLL on the fly

For some reason the +set game "directory" from the command line appears to load the DLL for the demo that plays. The variable game is now a latched variable, but is no longer read-only, so you can set it from the console and then start the game ???server. If you want to have a shortcut that jumps straight into your game all you have to do is put a solitary plus sign at the end of your command line:

quake2.exe +set game mygame +set deathmatch 1 +map q2dm1 +

2.4 Compiling as C++

Builtin boolean

A common mistake is replacing qboolean with the C++ type bool. As the boolean values are used in functions and structs visible to the server, size is critical, and the default for the original enum was int, thus define the type simply as integer for C++ compilation. Conversion of the predefined false and true will take care of the rest.

DLL internal prototype mismatch

Two functions???, ypu have to change prototypes

Use of reserved keywords

If you are writing a mod, pleas refrain from using C++ keywords like new in your source. There is one fix in the id sources... ????

Name Mangling and missing symbols

There is a problem with the name mangling. As the main engine imports only function pointers, this affects only one function known by name to the server process: the GetGameAPI function.

nm -D baseq2/ | grep GetGame

 C++ :  0003b3c0 T GetGameAPI__FP13game_import_t
 C   :  00037be0 T GetGameAPI

and you will find only the latter in the main engine. This is easily fixed by telling the compiler to apply C name mangling/symbol generation to that function, by
extern "C" 
game_export_t *GetGameAPI (game_import_t *import)

which allows the source to be compiled both as C and C++.

2.5 Interfacing Java

Next Previous Contents