Afforess
The White Wizard
Firaxis made, In CvUnitInfo, a int called "PrereqBuilding" which allows someone to set a Building Type requirement for a unit. Well, in their infinite wisdom, it uses, literally, BUILDINGS, not BUILDINGCLASS's. Which means civilizations that have a UB, and need that unit are SOL. So, I set out to fix this by adding a PrereqBuildingClass. And while I was at it, I was going to make it an array, so units could require more than 1 buildingclass.
Things went fairly smoothly, setting up CvInfos. However, after a search, I found that Firaxis put their CanTrain code in CvPlot (Of all places!) Now, I am having issues getting my code to work. I think it's fairly sound logically, but my compiler disagrees. Here's my addition to CvPlot:
The bolded line is where the compiler is choking. Error message:
I know this means that I'm trying to force the compiler to convert variable types, but I don't see what exactly I did wrong. Hopefully someone can shed some light here.
Things went fairly smoothly, setting up CvInfos. However, after a search, I found that Firaxis put their CanTrain code in CvPlot (Of all places!) Now, I am having issues getting my code to work. I think it's fairly sound logically, but my compiler disagrees. Here's my addition to CvPlot:
Code:
bool CvPlot::canTrain(UnitTypes eUnit, bool bContinue, bool bTestVisible) const
{
CvCity* pCity = getPlotCity();
BuildingClassTypes ePrereqBuildingClass; //Afforess
...
for (int iI = 0; iI < GC.getNumBuildingClassInfos(); iI++) //Afforess
{
if (GC.getUnitInfo(eUnit).getPrereqBuildingClass(iI))
{
ePrereqBuildingClass = ((BuildingClassTypes)(GC.getBuildingClassInfo((BuildingClassTypes)(GC.getUnitInfo(eUnit).getPrereqBuildingClass(eUnit)))));
if (ePrereqBuildingClass != NO_BUILDINGCLASS)
{
return false;
}
}
}
...
}
The bolded line is where the compiler is choking. Error message:
error C2440: 'type cast' : cannot convert from 'CvBuildingClassInfo' to 'BuildingClassTypes'
I know this means that I'm trying to force the compiler to convert variable types, but I don't see what exactly I did wrong. Hopefully someone can shed some light here.