Does a documentation exist for everything in the c++ files?

Jayman1000

Prince
Joined
May 6, 2006
Messages
319
Im a c++ noob and a sort of civ modding noob too, but I have some wishes for changes to make to one of my favourite mods, and that requires knowledge of the programming found in the c++ files.

So my question is this: Does a documentation exist for everything in the c++ files? While trying to learn about how stuff works browsing the programming files I keep seeing references to stuff I don't know where is defined. For example what is gDLL exactly? It is referenced an awful lot, but what is it exactly? (this gDLL is just one example there are tons of other stuff I don't know what actually contains: another example is NUM_CITY_PLOTS (which is a constant, right?). I see this accessed in CvCity.app, but it is not declared there, so where is NUM_CITY_PLOTS actually declared?). I can read and understand (mostly) the code I am reading, the logic etc. but so much is defined elsewhere. Perhaps this is a laughable question to c++ programmers. But please help me :) Where should I begin? Hope someone can help push me in the right direction and/or provide valuable insight. Thanks in advance!
 
Last edited:
Firaxis never released proper documentation, which has caused quite a number of bugs due to trial and error, particularly regarding keeping network games in sync. I recently wrote a tutorial on that specific topic and I recommend reading it.

I recommend using MS Visual C++ (or visual studio to get all languages, but only C++ is required for this). Hovering over something will tell what it is, like gDLL is #define gDLL GC.getDLLIFace(). The DLL interface is how the exe and the DLL communicates. In other words gDLL calls functions written in the exe file. Without any documentation for the interface we have nothing to go on other than the function names, looking at how vanilla use the functions as well as trial and error.

Another good thing about MSVC is that you can right click on something and go to to either declaration or definition. This can help to find stuff like defines and classes, though it's often most useful for jumping to the definition of functions.

NUM_CITY_PLOTS is in CvDefines.h. As written as comments in the top of that file, you should assume this file to be read only because a number of those constants can cause severe problems if they differ from the values in the exe. MAX_PLAYERS seems to be modable, though there are some restrictions.

You didn't mention DllExport, though I will mention it because it seems that people add it at random. It will make the function exposed to the exe to allow the exe to call the DLL. Since the exe will not know about new functions in the DLL, those newly modded in functions should not have the DllExport keyword. Also if a function has that keyword, do not change the arguments or weird stuff can happen when receiving a call from the exe. Default value to arguments will not be used and will not solve that problem.

There are some virtual functions. Do not add/change/remove those. Again this has to do with the interface to the exe.

Use svn/git or similar to keep track of your changes.
 
That's some great info, very usable so much appreciated THANK YOU! :)
 
Top Bottom