xienwolf
Deity
OK, here is what I came up with. It compiles, but that means nothing now, as I know enough to make it compile, but not enough to ensure it is doing what I need it to do; and as I say I don't understand the XML parsing functions, this is purely based on guesswork:
Please let me know if you see any problems with it.
Stealing the code out of the quote and commenting within it. Will color all comments so they stand out. Also will color the code I think you added so you can tell if I missed something in review.
Code:
void CvXMLLoadUtility::SetVariableListTagPair(int **ppiList, const TCHAR* szRootTagName,
int iInfoBaseSize, int iInfoBaseLength[COLOR=MediumTurquoise],
const TCHAR* szValueTagName, int iValueInfoBaseLength[/COLOR], int iDefaultListVal)
{
int i;
int iIndexVal;
int iNumSibs;
TCHAR szTextVal[256];
int* piList;
if (0 > iInfoBaseLength)
{
char szMessage[1024];
sprintf( szMessage, "Allocating zero or less memory in CvXMLLoadUtility::SetVariableListTagPair \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Error");
}
InitList(ppiList, iInfoBaseLength, iDefaultListVal);
if (gDLL->getXMLIFace()->SetToChildByTagName(m_pFXml,szRootTagName))
{
if (SkipToNextVal())
{
iNumSibs = gDLL->getXMLIFace()->GetNumChildren(m_pFXml);
piList = *ppiList;
if (0 < iNumSibs)
{
if(!(iNumSibs <= iInfoBaseLength))
{
char szMessage[1024];
sprintf( szMessage, "There are more siblings than memory allocated for them in CvXMLLoadUtility::SetVariableListTagPair \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Error");
}
[COLOR=SandyBrown]//This next line is in the WRONG place. You need to be inside the NumSibs loop.[/COLOR]
[COLOR=MediumTurquoise] if (gDLL->getXMLIFace()->SetToChildByTagName(m_pFXml,szValueTagName))
{[/COLOR]
for (i=0;i<iNumSibs;i++)
{
if (GetChildXmlVal(szTextVal))
{
iIndexVal = FindInInfoClass(szTextVal);
if (iIndexVal != -1)
{
GetNextXmlVal(&piList[iIndexVal]);
[COLOR=SandyBrown]//HERE is where you want to add your code, this is what just read the boolean.[/COLOR]
}
[COLOR="SandyBrown"]//This is actually sorta gibberish. You are comparing the BuildingClass enum (iIndexVal) against the number of Techs (iValueInfoBaseLength)[/COLOR]
[COLOR="MediumTurquoise"] if( (iIndexVal > iValueInfoBaseLength) || (iIndexVal < -1) )
{
char szMessage[1024];
sprintf( szMessage, "A defined value for an array is outside of the accepted size of the infoclass!\n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Error");
}
[/COLOR]
gDLL->getXMLIFace()->SetToParent(m_pFXml);
}
if (!gDLL->getXMLIFace()->NextSibling(m_pFXml))
{
break;
}
}
gDLL->getXMLIFace()->SetToParent(m_pFXml);
}
}
}
gDLL->getXMLIFace()->SetToParent(m_pFXml);
}
}
Also note that while you do set yourself to the new tag (techs) that you are adding and wanting to read, you never do actually read the value of that tag, nor look it up to convert to an INT.