Ways to disable Python callbacks...

TC01

Deity
Joined
Jun 28, 2009
Messages
2,216
Location
Irregularly Online
So, I was merging the new components of Sephi's BTS on Speed mod with FF+ (the components I hadn't already merged, that is).

Most of the new things are just the removal of Python callbacks. Since Final Frontier (Plus) relies heavily on Python callbacks, and since I'd want to have them as options for modders, I was converting them to XML-defined callbacks.

However, I noticed that there appear to be two different ways to do this. Sephi gave an example like the one below (and I was doing the same thing- this is one of the ones I added):

Code:
	if (GC.getDefineINT("USE_CANNOT_MAINTAIN_CALLBACK") == 1)
	{
		CyCity* pyCity = new CyCity((CvCity*)this);
		CyArgsList argsList2; // XXX
		argsList2.add(gDLL->getPythonIFace()->makePythonObject(pyCity));	// pass in city class
		argsList2.add(eProcess);
		argsList2.add(bContinue);
		long lResult=0;
		gDLL->getPythonIFace()->callFunction(PYGameModule, "cannotMaintain", argsList2.makeFunctionArgs(), &lResult);
		delete pyCity;	// python fxn must not hold on to this pointer 
		if (lResult == 1)
		{
			return false;
		}
	}

However, the ones Firaxis added are slightly different. They look more like the sample that Afforess posted ages ago. in the CAR mod thread.

The Firaxian ones use CvGlobals rather than GC.getDefineINT().

The question I have is: is there a difference? I mean, there's definitely an implementation difference, but would this translate to a difference in speed?
 
The CvGlobals implementation is just a local caching of the call to getDefineINT(), since getDefineINT() iterates the variables until it finds the correct one (look at CvGlobals::cacheGlobals()).
So the answer is: using the CvGlobals cache should be slightly faster.
 
Top Bottom