All I know is that by making all refs in PythonCallbackDefines.xml 0 the time between turns was greatly improved. iirc 75% or more faster, so 4 min wait would become a 1 min wait.
I'm no expert, but the callbacks from Python to the SDK aren't that big of a problem in themselves, but the fact that those that are disabled or can be disabled are called repeatedly during game-play. Like hundreds of times during a given player's turn. That will eventually add up to full seconds and become noticeable.
My original proposal (sans any built in support for the Barbarian spawn callbacks mentioned by Asaf) wouldn't use any calls back to the DLL. What I was referring to was instead the fact that Python is used as an extension of C++ in CivIV, and doesn't achieve
anything on its own. All of the Python "hooks" are calls coming from the DLL. So you could disable all those callbacks all you like.
As a rule of thumb, the calls in CvEventManager are merely calls from the DLL to Python, while the callbacks in CvGameUtils return some value back to the DLL. As Asaf said - this isn't a real problem unless this happens
a lot.
I am fairly sure that the documentation suggests that onEndGameTurn is better than onStartGameTurn but then one says it is at the end of start game and the other says it is at teh end of the game turn before the player moves or something. So it could have just been my dyslexia leading me astray (again).
I actually don't know. You might be correct and I'd love to see the documentation you're referring to. Because I don't feel at all comfortable with doing anything simply because it is how I've "always" done it in the past. I'm doing the Python scripting thing because it amuses me, and a big part of the fun is
learning.
Ah! So you thought that (Wolf 5%) means 5% chance for a wolf to spawn this turn whereas I thought it meant that a wolf spawns on 5% of the valid tiles for a wolf! Where the valid tiles for a wolf is defined in the unitinfos XML terrain and feature natives.
And my ignorance about the XML portion of the game is once again obvious.
Those settings would totally have to be utilized, if at all possible. And looking at the CvUnitInfo class in the API gives me two boolean methods for exactly this.
If you want to randomise the actual turn that units are generated we could follow a totally different plan. At the start of an era generate a list of units to place and a turn number based on the specified turn number. Then place the unit on the map at the correct time. You could generate lots of turns or generate some and then more when you run out. The initial list could be done on load or start.
This idea actually occurred to me also... Pre-generating what spawns happen on what turn might be faster, but I'm not sure that speed is even an issue with the proposed module. Maintaining and indexing huge arrays might be both slow and wasteful with memory, but I'm not computer scientist...
There is already the createBarbarianUnits() callback (no need to even enable it in the XML, since it is always called, at least for unmodded BTS). You also have createBarbarianCities().
See earlier post - I have no idea what to do with these? Disabling the default Barbarians spawns would disable this callback also, not? Rendering it practically useless, then?
There's existing code in the DLL for spawning barbarians, which can be tweaked to receive all those parameters from an XML file. I understand that part of the issue here is to do it in Python, but I do think that it would fit better, run faster and will be easier to be used by modders in C++ and XML.
There are, of course, advantages to do it in Python as well.
You're of course right on everything. But the point of this proposal is, as you pointed out, to do it in Python. Partly because C++ is currently out of my own reach, but mainly because any non-programmer modder would be better off simply dumping a CustomBarbarianSpawns.py file into their mod and adding a couple of lines (not blocks of code) into the event manager, than to merge some SDK mod with the other mod-comp they're already utilizing and compiling the whole thing. 9/10 non-programmers wouldn't even attempt it, and 9/10 who would try it would probably fail, at least at their first few attempts. 9/10 probably wouldn't be motivated enough to see it through. Do the math...
So making this entirely in Python, no matter what lag it ends up causing or how much "easier" working with XML is (yeah, right), makes it accessible. This would be the
real benefit of Python over SDK modding.