Merkava120
Oberleutnant
I think it is because unitinfo is a CyUnit type not a CvUnitInfo type.
Mmm, that would make sense. How do I get a CvUnitInfo type?
I think it is because unitinfo is a CyUnit type not a CvUnitInfo type.
Mmm, that would make sense. How do I get a CvUnitInfo type?
gc.getUnitInfo(unit.getUnitType())
Thanks a lot, this worked!And once the game has started, you could remove the leading number. It might also be possible to prepend numbers only while the EXE is sorting the list. In the debugger, I see that the EXE calls CvInfoBase::getDescription repeatedly for each civ as the civ selection screen (under Play Now) is loaded, so it looks like getDescription gets called for every comparison that occurs while sorting the list. But I'm not sure if getDescription is called one last time for each civ when sorting is over, i.e. when the descriptions are put on the screen. And even if so, identifying that last call would be difficult.
//bluepotato start: fix civ listing
static int* asked;
static bool civsInited = false;
static int civs;
void CvInfoBase::resetAsked() { //this is a static function. it's exposed to python and called in CvWBInterface.getPlayerData()
for(int i = 0; i<GC.getNumCivilizationInfos(); i++) {
asked[i] = 0;
}
}
//bluepotato end
const wchar* CvInfoBase::getDescription(uint uiForm) const
{
while(m_aCachedDescriptions.size() <= uiForm)
{
m_aCachedDescriptions.push_back(gDLL->getObjectText(m_szTextKey, m_aCachedDescriptions.size()));
}
//bluepotato start: fix civ listing
int i;
if(!civsInited) {
civs = 0;
asked = new int[GC.getNumCivilizationInfos()];
for(i = 0; i<GC.getNumCivilizationInfos(); i++) {
asked[i] = GC.getNumCivilizationInfos(); //so that civilopedia doesn't break
if(GC.getCivilizationInfo((CivilizationTypes)i).isPlayable()) {
civs++;
}
}
civsInited = true;
}
for(i = 0; i<GC.getNumCivilizationInfos(); i++) {
if(wcscmp(m_szTextKey.c_str(), GC.getCivilizationInfo((CivilizationTypes)i).getTextKeyWide()) == 0) {
asked[i]++;
if(asked[i]<civs) {
return L"";
}
}
}
//bluepotato end
return m_aCachedDescriptions[uiForm];
}
Cool. If the EXE really calls getDescription exactly once for each pair of playable civs, then I would assume that it performs an insertion sort. I can see that resetting is tricky, e.g. when the player cancels the civ selection and later comes back to it (maybe browsing the main menu Civilopedia in between). Once the game has started, it seems a bit wasteful to test for equality of m_szTextKey with every civ text key on every getDescription call. A guardThanks a lot, this worked! [...]
Identifying the last call wasn't actually the most difficult thing; I spent way more time trying to figure out a way to reset the amount of tracked getDescription calls as soon as a scenario is loaded (that's what the resetAsked() function is for). If anyone is interested, here's the code I've come up with:
For a prettier implementation (not a suggestion ... just musing), I'd let CvCivilizationInfo override getDescription. Since getDescription isn't virtual and can't be made virtual (DllExport), that would have to be done by forwarding from getDescription to a virtual protected function, say, CvInfoBase::getDescriptionInternal, which then gets overidden by CvCivilizationInfo.Yes, it's ugly, but it does the job.
As long as the scenario selection screen is used, it can always be reset from CvWBInterface.getPlayerData() since that function is called every time the scenario civ selection screen is loaded. For mapscripts maybe getDescription could be used, but that's not relevant in my case.I can see that resetting is tricky, e.g. when the player cancels the civ selection and later comes back to it (maybe browsing the main menu Civilopedia in between).
Just tried these and can confirm that both of them work. (so Leo was right, isFinalInitialized does help )Once the game has started, it seems a bit wasteful to test for equality of m_szTextKey with every civ text key on every getDescription call. A guard
if (getGame().getActivePlayer() != NO_PLAYER)before your code could avoid that. (Checking finalInitialized might also work.)
If a land improvement consumes the worker then the AI will tend not to build them. As far as I know all worker AI is controlled in the dll and none is available for modding through XML.Are there any xml files that control the AI's willingness to improve it's tiles? In my mod the AI is barely building improvements and I don't know why.
Are there any xml files that control the AI's willingness to improve it's tiles? In my mod the AI is barely building improvements and I don't know why.
I'd volunteer to help but have very little time even for my own mod.I have a potentially very cool mod that I want to put together but I'm realizing I do NOT have the time to do the XML and art for it
Actually I knew that - from sour experienceIf a land improvement consumes the worker then the AI will tend not to build them.
Was afraid of that.As far as I know all worker AI is controlled in the dll and none is available for modding through XML.