Exposing AI method to Python

How did you manage to include CvPlayerAI.h in CvPlayer.h without cyclic dependencies?
PHP:
class CvPlayerAI;
This will inform the compiler that there is a class called CvPlayerAI. It doesn't know anything about the contents or that it's related to CvPlayer. All it knows is that there is a class of that name, meaning it can accept pointers to that class. Some header files (CvPlayer.h included) starts with a few class declarations.

Generally speaking, if you can get away with declaring the class instead of including the header file, do it. Header files including header files quickly turns into a mess and it slows down the compiler. It becomes less of an issue due to using a precompiled header file, but it's always a good idea to include as little as possible.
 
Makes sense, thanks.
 
I have an update on this. DO NOT REMOVE VANILLA VIRTUAL FUNCTIONS!!!

Also do not add your own, at least not before any vanilla ones. It looks like the exe is compiled using that header file and somehow it can use the virtual functions without mentioning them by name or having them use DllExport. Instead it just assumes their memory location based on the order of virtual functions. If functions are add or removed, the assumption about order will no longer work and weird stuff will happen, most likely crashes or as I just experienced: failure to load a savegame.

Adding variables before virtual functions will likely also mess up something.
 
Back
Top Bottom