The callback functions are spread through the various files since they are called inside other C++ functions in order to change what happens.
Fortunately, they all use the same function call so you can search for that: "gDLL->getPythonIFace()->callFunction". That would give you a list of such functions. Alternatively you can search for the name of the callback, which you can separate from various C++ functions with the same name by searching for it in double quies, since the callback names are in double quotes. This is used for some other similar things, but the ones that have a first argument of PYGameModule are apparently all the callbacks in CvGameUtils.py. The name of the callback is the second argument to that call. So they all look something like this:
Code:
if(GC.getUSE_CAN_TRAIN_CALLBACK())
{
CyCity* pyCity = new CyCity((CvCity*)this);
CyArgsList argsList;
argsList.add(gDLL->getPythonIFace()->makePythonObject(pyCity)); // pass in city class
argsList.add(eUnit);
argsList.add(bContinue);
argsList.add(bTestVisible);
argsList.add(bIgnoreCost);
argsList.add(bIgnoreUpgrades);
long lResult=0;
gDLL->getPythonIFace()->callFunction(PYGameModule, "canTrain", argsList.makeFunctionArgs(), &lResult);
delete pyCity; // python fxn must not hold on to this pointer
if (lResult == 1)
{
return true;
}
}
This is, fairly obviously, the code that calls the canTrain callback.
First, it checks to see if the callback is activated.
Then it sets up the argument list, which is what ends up in the argList tuple in the Python. In this case, it is a CyCity object, a unit ID, and 4 booleans. This, not surprisingly, matches the code in the BtS CvGameUtils.py:
Code:
def canTrain(self,argsList):
pCity = argsList[0]
eUnit = argsList[1]
bContinue = argsList[2]
bTestVisible = argsList[3]
bIgnoreCost = argsList[4]
bIgnoreUpgrades = argsList[5]
return False
Since the canTrain callback will override the DLL's decision, it checks the returned result and if it is true (which is coming through as a 1) then the CvCity::canTrain function just exits with a true, skipping the rest of the function.
That is, in essence, the way most of the callbacks work.