Troubles with Arrays and Arrays of Arrays...

isBuildingClassRequiredToTrain() has an error. The second array is indexed by building class--not techs--and it holds a TechTypes--not booleans. Same applies to the era override array. You are looping over all techs and eras which is not necessary.

Code:
bool CvPlayer::isBuildingClassRequiredToTrain(BuildingClassTypes eBuildingClass, UnitTypes eUnit) const
{
	if (GC.getUnitInfo(eUnit).getPrereqBuildingClass(eBuildingClass))
	{
		TechTypes eOverrideTech = (TechTypes) kUnit.getPrereqBuildingClassOverrideTech(eBuildingClass);
		if (eOverrideTech != NO_TECH && GET_TEAM(getTeam()).isHasTech(TechTypes(eOverrideTech))
		{
			return false;
		}
		EraTypes eOverrideEra = (EraTypes) kUnit.getPrereqBuildingClassOverrideTech(eBuildingClass);
		if (eOverrideEra != NO_ERA && GET_TEAM(getTeam()).getEra() >= eOverrideEra)
		{
			return false;
		}
		return true;
	}
	return false;
}
 
To check if the data is loaded without going to the Civilopedia, run your debug with breakpoints, and do a "Step Out" move from your CvXMLLoadUtility file. It should land you in CvInfos a line after loading your new tags. Look in your Locals and you should be able to find m_piPrereqBuildingClassOverrideTech and check the actual values contained within.

I had run into an issue with the functions I wrote to load some special XML styles I use similar to what you think you are seeing (in CvXMLLoad everything was great, but once you get back to CvInfos no data is actually returned). So if it isn't an error in the pedia display pieces, I'll show you the workaround I designed for my problem. It was something I couldn't understand the need for, as it appeared to be redundant, but it fixed things, so I was happy enough.

EDIT: Also, does CvUnitInfo::getPrereqBuildingClass(eBuildingClass) return a boolean, or an enumerator int? Get usually implies an INT type of return, and I think I recall you having it return the Tech Enum earlier. If so, then your IF statement logic is flawed (if the first tech is an override, you would get a 0, so fail the IF check, if NONE is listed, you get a -1, so pass the IF check)
 
Thanks much, the problem was one of logic, EF's code fixed it. Because I had been plagued by the loading issues for most of this, I just failed to realize that the actual implementation was the culprit.

Edit:

EF, do you know how to get the Era override to show up in the civilopedia? There is no button for eras. I have this, but get a python exception. Tech override displays correctly, just can't figure out how to put an Era up there without a button to use.
Code:
...
if bTechOverride:
	screen.attachLabel(panelName, "", localText.getText("TXT_KEY_UNTIL", ()))
	screen.attachImageButton(panelName, "", gc.getTechInfo(iTech).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_TECH, iTech, -1, False)
if bEraOverride:
	screen.attachLabel(panelName, "", localText.getText("TXT_KEY_UNTIL", (iEra)))
 
I'm not sure I understand your question. Are you asking for a suggestion to use instead of a button since you don't have one? Short of putting the text itself, I'd find an artist to draw some buttons. ;)
 
My problem is I can't figure out how to get the text to display.

For instance this results in a python exception:

Code:
if bEraOverride:
	eraDescription = gc.getEraInfo(iEra).getDescription()
	screen.attachLabel(panelName, "", localText.getText("TXT_KEY_UNTIL", ()))
	screen.attachLabel(panelName, "", localText.getText(eraDescription, ()))
So how can I get the name of the era to print after "Until" does?
 
Because gc.getEraInfo(iEra).getDescription() already returns a string, you don't need the localtext.getText... Just place the eraDescription instead of it.
Code:
	screen.attachLabel(panelName, "", eraDescription)

A far as I know localtext.getText() is only used when you need to get the string out of TXT_KEY.
 
NotSoGood is correct, but that shouldn't cause a Python exception. If the string you pass in doesn't match a <Text> entry, it returns the same string. Always post the stacktrace; we can't help much otherwise.
 
It just said that the signature didn't match, something about a string being passed where a tupple should be, or vice versa; can't remember exactly.

Looks like I'll need to put some more detail into this to get it to look right in the civilopedia. But functionally everything is working perfectly now thanks guys; this forum rocks.
 
Back
Top Bottom