Does getNumUnitClassInfos include modular units?

Joined
Jul 5, 2004
Messages
23,562
Location
Canberra, Australia
I am maintaining some code that adds a number of religions to Rise of Mankind. RoM uses a variation on Sevopedia for its pedia. This variation displays the unique units for a religion on the pedia page ie religion missionary.

However it is not doing so for the added religions. They are modular and RoM uses the WoC standard for XML.

As far as I can see the code fragment everything should work fine unless getNumUnitClassInfos is not also counting the modular units. Is this so? If so is there something I should be using instead?

Code fragment is:-
Code:
	def placeUnit(self):
		...
		for iUnit in [B]range(gc.getNumUnitClassInfos())[/B]:
			iPrereq = gc.getUnitInfo(iUnit).getPrereqReligion()
			iPrereq2 = gc.getUnitInfo(iUnit).getReligionType()
			iPrereq3 = gc.getUnitInfo(iUnit).getStateReligion()
			if (iPrereq == self.iReligion or iPrereq2 == self.iReligion or iPrereq3 == self.iReligion):
				screen.attachImageButton(panelName, "", gc.getUnitInfo(iUnit).getButton(), ...)

Whatever problem is happening here it is also happening with the extra corporate executives also. It has very similar code.
 
Once loading is finished, modular units are the same as non-modular units are. So it does see them. The error must lie in the prereqs not being set properly, which sometimes happens with modules when the loading mechanism is not done quite right. Check the pedia for your units to ensure that they show the proper prereqs as being required.


One thing I notice that is a bit of an issue though is that the loop is over UnitCLASSES, and it is getting info for UNITS. Those are VERY different things, so this function is honestly quite broken as pasted here. If that is the actual code in the python (which I would imagine it must be), you might want to fix it.

Code:
	def placeUnit(self):
		...
		for iUnit in range(gc.getNumUnit[COLOR="Red"][s]Class[/s][/COLOR]Infos()):
			iPrereq = gc.getUnitInfo(iUnit).getPrereqReligion()
			iPrereq2 = gc.getUnitInfo(iUnit).getReligionType()
			iPrereq3 = gc.getUnitInfo(iUnit).getStateReligion()
			if (iPrereq == self.iReligion or iPrereq2 == self.iReligion or iPrereq3 == self.iReligion):
				screen.attachImageButton(panelName, "", gc.getUnitInfo(iUnit).getButton(), ...)
 
Once loading is finished, modular units are the same as non-modular units are. So it does see them. The error must lie in the prereqs not being set properly, which sometimes happens with modules when the loading mechanism is not done quite right. Check the pedia for your units to ensure that they show the proper prereqs as being required.


One thing I notice that is a bit of an issue though is that the loop is over UnitCLASSES, and it is getting info for UNITS. Those are VERY different things, so this function is honestly quite broken as pasted here. If that is the actual code in the python (which I would imagine it must be), you might want to fix it.

Code:
	def placeUnit(self):
		...
		for iUnit in range(gc.getNumUnit[COLOR="Red"][s]Class[/s][/COLOR]Infos()):
			iPrereq = gc.getUnitInfo(iUnit).getPrereqReligion()
			iPrereq2 = gc.getUnitInfo(iUnit).getReligionType()
			iPrereq3 = gc.getUnitInfo(iUnit).getStateReligion()
			if (iPrereq == self.iReligion or iPrereq2 == self.iReligion or iPrereq3 == self.iReligion):
				screen.attachImageButton(panelName, "", gc.getUnitInfo(iUnit).getButton(), ...)

I forgot to say that the units (missionaries) are showing up correctly in the units part of the pedia which is why I was originally thinking there was another XML file to define unique units to religions and corporations.

I will try your suggestion but I think it was changed to Class because using the equivilent for buildings didn't work and you needed to look at buildingclass not buildings. But I may be remembering wrong.
 
Top Bottom