similar to this which already exist for buildings:
int CvBuildingInfo::getPrereqAndTechs(int i) const
{
FAssertMsg(i < GC.getNUM_BUILDING_AND_TECH_PREREQS(), "Index out of bounds");
FAssertMsg(i > -1, "Index out of bounds");
return m_piPrereqAndTechs ? m_piPrereqAndTechs : -1;
}
only made opposite like so in a way:
int CvTechInfo::getPrereqAndBuildingClass(int i) const
{
FAssertMsg(i < GC.getNUM_TECH_AND_BUILDING_PREREQS(), "Index out of bounds");
FAssertMsg(i > -1, "Index out of bounds");
return m_paiPrereqBuildingClass? m_paiPrereqBuildingClass : -1;
}
Looking in CvInfos.cpp, I already see these functions, but they have been commented out...
You'd probably need the functions above those too:
int CvTechInfo::getNumPrereqBuildingClasses() const
Then you'd setup a loop that calls to getNumPrereqBuildingClasses and then use the index derived from that loop to insert into the parameter for getPrereqBuildingClass to get the buildingclass index stored there in that slot.
Those functions are completely useless, there is no way to identify what buildingclasses are required by knowing the number needed to unlock the tech.
Let's say that I in python have a CvTechInfo type object that contains this ↓ info, call it
CvSomeTechInfo.
<TechInfo>
<Type>TECH_SOME_TECH</Type>
<PrereqBuildingClasses>
<PrereqBuildingClass>
<BuildingClassType>BUILDINGCLASS_X</BuildingClassType>
<iNumBuildingNeeded>1</iNumBuildingNeeded>
</PrereqBuildingClass>
<PrereqBuildingClass>
<BuildingClassType>BUILDINGCLASS_Y</BuildingClassType>
<iNumBuildingNeeded>5</iNumBuildingNeeded>
</PrereqBuildingClass>
<PrereqBuildingClass>
<BuildingClassType>BUILDINGCLASS_Z</BuildingClassType>
<iNumBuildingNeeded>2</iNumBuildingNeeded>
</PrereqBuildingClass>
</PrereqBuildingClasses>
</TechInfo>
Then I use the CvTechInfo specific function:
iNumPrereqBuildingClasses = CvSomeTechInfo.getNumPrereqBuildingClasses()
What does it return, 1, 5, or 2? Or perhaps it returns 3 because there are 3 buildingclasses listed in its <PrereqBuildingClasses>.
From this number there is no way to identify what building class that is in the <BuildingClassType> tag.