The Dark Mod - Compilation Guide: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Line 46: Line 46:
For Linux you'll need gcc and scons, plus a few packages depending on your distribution. There is a README.linux file contained in the source package you downloaded, check it out for some details.
For Linux you'll need gcc and scons, plus a few packages depending on your distribution. There is a README.linux file contained in the source package you downloaded, check it out for some details.


== Test the Module ==
== I have a bugfix for the team ==
 
In case you figured out a problem in the TDM game code and you maybe even have a fix available, please drop by at our forums to tell the coding staff. Your fix might be incorporated in the main development branch.
Note: this page is obviously WIP.


[[Category:Tutorial]]
[[Category:Tutorial]]
[[Category:Coding]]
[[Category:Coding]]

Revision as of 07:06, 29 October 2009

This guide should provide you with enough information to compile The Dark Mod's game code from source.

The sources are available through "snapshots", i.e. whenever the Dark Mod team is releasing a new update (e.g. TDM 1.01) the corresponding sources are released as well.

Download the sources

You can download the latest source package from our website: http://www.thedarkmod.com/download_source.php

Windows

For Windows you'll need Visual Studio to compile the project, you can get the free Express editions from the Microsoft website. It should work with every version starting from VC++ 2005 upwards, although I'd recommend the VC++ 2008 one. If you go for the older VC++ 2005, you'll need the Platform SDK as well, which is another large download. You don't need a Platform SDK for VC++ 2008.

Download the sources and unpack them somewhere. You'll find a d3game.sln solution file (which is in VC++ 2005 format), which you can double-click to open in Visual Studio. The newer VC++ 2008 will present you an upgrade wizard to convert the solution to 2008.

Once opened, select the Configuration Type in the topmost toolbar (either "release" or "debug", depending on what you want to do) and hit "Build Solution" (Ctrl-Shift-B). The compilation usually takes a few minutes, watch the output window at the bottom of Visual Studio. Once completed, you'll find the compiled gamex86.dll in a subfolder named "releasedll" (for release builds" or "debugdll" (for debug builds).

In order to "install" the gamex86.dll, you need to copy it somewhere where Doom3.exe can find it. There are two ways to do that: either you place the dll right next to your DOOM3.exe which will override any other mechanism (the game will always load the DLL right next to DOOM3.exe first), or you put them in a PK4 (along with a binary.conf file) and place it in your mod folder. There is some info on www.iddevnet.com/doom3 about how to do that.

Debugging the Game

To debug your custom built game code, you need to attach Visual Studio's debugger to the Doom3.exe process. There are two ways to accomplish that:

The quick one:

  1. Go to Visual Studio and open the d3game solution
  2. Start the game (either through tdmlauncher.exe or through DOOM3.exe plus command lines)
  3. Once the game is up and running, Alt-Tab back to Visual Studio
  4. Go to menu "Debug" > "Attach to Process..." and select the DOOM3.exe process from the list in that dialog popping up.
  5. The debugger will now attach to Doom3 (along with all loaded DLLs) and you can now place breakpoints or intercept game crashes.

The longer one (if you debug your game more than once or twice):

  1. Go to Visual Studio and open the d3game solution
  2. Right-click the Solution in the "Solution Explorer" and select "Add" > "Existing Project..."
  3. Browse to DOOM3.exe and select that, you'll see the DOOM3.exe project added to your solution explorer view.
  4. Right-Click the DOOM3.exe and choose "Select as startup project".
  5. Now you can start the debugger just by hitting F5 and Visual Studio will automatically attach to the Doom3 process.
  6. [Optional]: You can specify command line parameters to Doom3.exe by opening the Doom3.exe project properties and adding the desired parameters (e.g. com_allowConsole or fs_game_base/fs_game) to the "Command Arguments" item. This is necessary if you want to debug a specific TDM mission (although in this case, employing the "quick" method above is easier).

Note: you can still attach your debugger to any running DOOM3.exe process with the second method.

Troubleshooting

My breakpoints don't work (they are hollow circles instead of full ones)
Check if you copied the correct gamex86.dll to the folder where DOOM3.exe is located. The code you're viewing and the DLL must match exactly, otherwise Visual Studio won't load your symbols. Make sure that the configuration type (release or debug build) is matching as well. Also make sure that the code is properly compiled, e.g. hit "Build Solution" again - the output window should tell you that everything is up to date.
I cannot inspect all the variables / The instruction pointer is skipping code
You are probably running a release build, which comes with some optimisations. When debugging a release build, you'll notice that your instruction pointer (the yellow arrow) is sometimes skipping statements. These have most likely been optimised out of the binary during compilation/linking. You'll also have troubles when trying to inspect temporary variables or inlined functions. Use a debug build if this prevents you from figuring out things during debugging.

Linux

For Linux you'll need gcc and scons, plus a few packages depending on your distribution. There is a README.linux file contained in the source package you downloaded, check it out for some details.

I have a bugfix for the team

In case you figured out a problem in the TDM game code and you maybe even have a fix available, please drop by at our forums to tell the coding staff. Your fix might be incorporated in the main development branch.