I actually just tried it, and it seems to work. I uploaded it
here and
here.
The functionality of picking a random name is outsourced from CvUnit::init() to the new function CvGame::getNewGreatBornPersonName(). Instead, CvUnit::init() and CvPlayer::initUnit() get the new parameter szName.
CvPlayer::createGreatPeople(), which is used (obviously) by the standard GP system and also when a player gets a free GP from researching a tech, uses the new function and parameter.
The second commit fixes the commander (not the general) beavior python-only (with the new variable thing you mentioned and scriptdata, so I had not to expose getter and setter of a CvUnit variable).
There are several side-effects; great people not created via CvPlayer::createGreatPeople() will not get a random name. I searched in python and XML and found the following cases:
- Kidnapped GP - I think that's fine. They at least shouldn't get a new name.
- Unnamed GPs in scenarios - Also fine. I don't think there are any in the official scenarios.
- BigGoodLair GP "Prisoner" Reward - Probably should get a random name. It is handled by activation a "GoodyInfo" (GOODY_EXPLORE_LAIR_PRISONER_XXX), and should be a minor DLL change.
- Free Scientist from Secret Codes UC Resolution - I think this is also a minor DLL change just using getNewGreatBornPersonName()
- GPs from Events - Several Prophets, the Artist from the Clairone (Harpy) Event, and Bareke. I'm thinking of adding the <Name> and <bGreatPerson> (for a random name if <Name> is empty, the addition to the used GP names and maybe the global message) tags; exposing CvGame::isGreatPersonBorn(), addGreatPersonBornName() and getNewGreatBornPersonName() would offer more control to python and allow f.e. preventing the Bareke event if he's already born. But I doubt any changes here will make it to MNAI. At least for Bareke and Clairone no names are better than random names anyway.
I assumed that there would be some way to prevent the "new unit event" from happening when recreating a unit after detaching it from another unit (as it is not really a new unit).
I thought about that, too; but it would also require a new parameter in CvUnit and I think it could have larger side-effects or provoke mistakes, because a modder expects unitCreated to be fired every time a unit is placed on the map.
If that is possible then we would not get new general/commander names in existing units after detaching them. To finish the solution, CvUnit could get a new attribute similar to the one that already exists for joined unit artwork (see
http://sourceforge.net/p/tholalsffhaimod/bugs/149/) but that would store the joined unit's name. After a detach, the detached unit would get the name stored in the unit it was joined to in this new attribute.
As I said, I did that for the commander. You merged the two, right? So you use the General "lead troops as a warlord" action and not the commander spell? If so, my solution (in the second revision) won't work; you'd have to do that variable and expose at least a getter to python, since "split general" is a spell.
Your solution seems to require mostly DLL changes. Besides your own work and possibly EitB, I'm not aware of any other MNAI modmodmods that include DLL changes. I don't know what merge process is used by Sareln for EitB (based on his posts I guess he does it manually with winmerge or some other similar tool) but if I understood your change correctly it won't be a lot more intrusive than the usual changes that Tholal does between versions. In our case, Tholal has added new attributed and exposed them to python in the past and they have not been a big headache to merge. A Mercurial merge of this change from MNAI would probably be trivial and Mercurial should handle it automatically.
OK then
... I just noticed the typo getNew
GreatBornPersonName(). Will fix it soon.