Basic DLL tasks

From Civilization Modding Wiki
Revision as of 00:09, 21 February 2014 by Ls612 (talk | contribs) (Compiling the DLL)

Jump to: navigation, search

Basic DLL Tasks

The Civilization V SDK ships with the C++ source code for the Civilization V CvGameCoreDLL. This is the most powerful tool modders have, as it allows us to directly alter game code and game logic, but also one of the least used, as it has a codebase in excess of 100,000 lines of code and the architecture of the program is not always clear. In this article some basic tasks in modding the DLL will be covered, as well as some more advanced ones as well.

Requirements

This article is NOT a C++ tutorial. If you need one of those, Google is your friend. I will assume that you are knowledge of C++ coding, as well as knowledge of how a civ game works. I will not assume knowledge of the Civ 5 dll or the civ 4 dll, which was very similar architecture-wise.

Compiling the DLL

The DLL source comes with solutions for Visual Studio 2008, 2010, and 2012 (the 2012 one also compiles in 2013). However the project requires the VC++ 2008 toolchain. Since Visual Studio 2008 is a slightly outdated IDE it doesn't have the best features, so you should install Visual C++ 2008 Express and Visual C++ 2013 express to get the best development experience. If you don't want to do that just developing in VC2008 is fine as well. Any of the paid versions of Visual studio from these years will also work. Both of the express ones can be downloaded for free from Microsoft's website.

Once you have your IDE(s) installed you only need to make one change to make the DLL compile. In CvGameCoreDLL.rc for each project (there are 3, one for each dll) you need to change the reference to afxres.h to windows.h. After this simply build (you may need to clean first) and you should get 3 dlls, one for vanilla, G&K, and BNW. Note, you can safely remove the projects for versions your mod will not support (ie, you can only have it build the BNW dll).

To add a new DLL to a mod, open up ModBuddy, and right click your mod project and select 'Add existing item'. Navigate to the output folder from Visual Studio and select the DLL file, then click 'add'. After this you need to set import to VFS for true for the DLL, and when your mod loads it should also tell the Civilization 5 exe to unload the normal DLL and load yours.

Basic Civ 5 DLL Architecture

Coming Soon...

Creating a new boolean XML tag/SQL column

Coming Soon...

Creating a new integer/floating point value XML tag/SQL column

Coming Soon...

Creating a new multi-level XML tag/SQL column

Coming Soon...

Debugging your custom DLL

Coming Soon...

Advanced Tips and Tricks

Coming Soon...