Loading an enum from xml.

Joined
Sep 15, 2006
Messages
511
I'm trying to add a new feature to my mod.

In enums.cpp I added this.
Code:
//ClassicThunder
enum DllExport UnitElementType
{
	NO_ELEMENT = -1,
	EARTH_ELEMENT = 0,
	FIRE_ELEMENT = 1,
	WATER_ELEMENT = 2,
};

And where I load the xml I added this.
Code:
	//ClassicThunder
	pXML->GetChildXmlValByName(szTextVal, "ElementType");
	m_ePossibleElementTypes = pXML->FindInInfoClass(szTextVal);
	//ClassicThunder

Which gives me this error
Code:
c:\Users\Scott Franks\AppData\Roaming\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Rise from Ashes\CvGameCoreDLL\CvInfos.cpp(2318): error C2440: '=' : cannot convert from 'int' to 'UnitElementType'

So how do go from szTextVal to the corresponding enumeration I created?
 
Try casting like this:

Code:
//ClassicThunder
pXML->GetChildXmlValByName(szTextVal, "ElementType");
m_ePossibleElementTypes = (UnitElementType) pXML->FindInInfoClass(szTextVal);
//ClassicThunder
 
Thanks that worked. Just one more thing. Where does it load the enums from GlobalTypes in the SDK?
 
Back
Top Bottom