Cybah
Emperor
- Joined
- Jun 22, 2007
- Messages
- 1,481
I've added SpecialistYieldChanges and SpecialistCommerceChanges to TraitInfos.
I know, TraitInfos are loaded before BuildingInfos.
This results in a "Allocating Zero or Less Memory in CvXMLLoadUtility..." error.
What to do?
I've read several postings about readpass3 and I don't get it, I'm not a c++ geek. What's the easiest way to get this work?
Here is my CvInfos.cpp:
I am very confused why this is working in "The History of Three Kingdoms", the modder did not change the CVXMLLoadUtility and I've not found any readPass3 or something like this which is declared with "Civilization Trait".
Who can help me please?
I know, TraitInfos are loaded before BuildingInfos.
This results in a "Allocating Zero or Less Memory in CvXMLLoadUtility..." error.
What to do?
I've read several postings about readpass3 and I don't get it, I'm not a c++ geek. What's the easiest way to get this work?
Here is my CvInfos.cpp:
PHP:
CvTraitInfo::CvTraitInfo()
(...)
// Sanguo Mod Civilization Trait, Start, by poyuzhe 11.20.08
// Cao Cao, TRAIT_TALENTED
m_ppaiSpecialistYieldChange(NULL),
m_ppaiSpecialistCommerceChange(NULL),
CvTraitInfo::~CvTraitInfo()
(...)
//Sanguo Mod Civilization Trait, Start, by poyuzhe 11.20.08
//Cao Cao, TRAIT_TALENTED
if (m_ppaiSpecialistYieldChange != NULL)
{
for(int i=0;i<GC.getNumSpecialistInfos();i++)
{
SAFE_DELETE_ARRAY(m_ppaiSpecialistYieldChange[i]);
}
SAFE_DELETE_ARRAY(m_ppaiSpecialistYieldChange);
}
if (m_ppaiSpecialistCommerceChange != NULL)
{
for(int i=0;i<GC.getNumSpecialistInfos();i++)
{
SAFE_DELETE_ARRAY(m_ppaiSpecialistCommerceChange[i]);
}
SAFE_DELETE_ARRAY(m_ppaiSpecialistCommerceChange);
}
// Arrays
(...)
// Sanguo Mod Civilization Trait, Start, by poyuzhe 11.20.08
// Cao Cao, TRAIT_TALENTED
int CvTraitInfo::getSpecialistYieldChange(int i, int j) const
{
FAssertMsg(i < GC.getNumSpecialistInfos(), "Index out of bounds");
FAssertMsg(i > -1, "Index out of bounds");
FAssertMsg(j < NUM_YIELD_TYPES, "Index out of bounds");
FAssertMsg(j > -1, "Index out of bounds");
return m_ppaiSpecialistYieldChange ? m_ppaiSpecialistYieldChange[i][j] : -1;
}
int* CvTraitInfo::getSpecialistYieldChangeArray(int i) const
{
FAssertMsg(i < GC.getNumSpecialistInfos(), "Index out of bounds");
FAssertMsg(i > -1, "Index out of bounds");
return m_ppaiSpecialistYieldChange[i];
}
int CvTraitInfo::getSpecialistCommerceChange(int i, int j) const
{
FAssertMsg(i < GC.getNumSpecialistInfos(), "Index out of bounds");
FAssertMsg(i > -1, "Index out of bounds");
FAssertMsg(j < NUM_COMMERCE_TYPES, "Index out of bounds");
FAssertMsg(j > -1, "Index out of bounds");
return m_ppaiSpecialistCommerceChange ? m_ppaiSpecialistCommerceChange[i][j] : -1;
}
int* CvTraitInfo::getSpecialistCommerceChangeArray(int i) const
{
FAssertMsg(i < GC.getNumSpecialistInfos(), "Index out of bounds");
FAssertMsg(i > -1, "Index out of bounds");
return m_ppaiSpecialistCommerceChange[i];
}
CvTraitInfo::read
(...)
// Sanguo Mod Civilization Trait, Start, by poyuzhe 11.20.08
// Cao Cao, TRAIT_TALENTED
int j=0; //loop counter
int k=0; //loop counter
int iNumSibs=0; // the number of siblings the current xml node has
int iNumChildren; // the number of children the current node has
pXML->Init2DIntList(&m_ppaiSpecialistYieldChange, GC.getNumSpecialistInfos(), NUM_YIELD_TYPES);
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(),"SpecialistYieldChanges"))
{
iNumChildren = gDLL->getXMLIFace()->GetNumChildren(pXML->GetXML());
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(),"SpecialistYieldChange"))
{
for(j=0;j<iNumChildren;j++)
{
pXML->GetChildXmlValByName(szTextVal, "SpecialistType");
k = pXML->FindInInfoClass(szTextVal);
if (k > -1)
{
// delete the array since it will be reallocated
SAFE_DELETE_ARRAY(m_ppaiSpecialistYieldChange[k]);
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(),"YieldChanges"))
{
// call the function that sets the yield change variable
pXML->SetYields(&m_ppaiSpecialistYieldChange[k]);
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
}
else
{
pXML->InitList(&m_ppaiSpecialistYieldChange[k], NUM_YIELD_TYPES);
}
}
if (!gDLL->getXMLIFace()->NextSibling(pXML->GetXML()))
{
break;
}
}
// set the current xml node to it's parent node
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
}
// set the current xml node to it's parent node
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
}
pXML->Init2DIntList(&m_ppaiSpecialistCommerceChange, GC.getNumSpecialistInfos(), NUM_COMMERCE_TYPES);
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(),"SpecialistCommerceChanges"))
{
iNumChildren = gDLL->getXMLIFace()->GetNumChildren(pXML->GetXML());
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(),"SpecialistCommerceChange"))
{
for(j=0;j<iNumChildren;j++)
{
pXML->GetChildXmlValByName(szTextVal, "SpecialistType");
k = pXML->FindInInfoClass(szTextVal);
if (k > -1)
{
// delete the array since it will be reallocated
SAFE_DELETE_ARRAY(m_ppaiSpecialistCommerceChange[k]);
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(),"CommerceChanges"))
{
// call the function that sets the yield change variable
pXML->SetCommerce(&m_ppaiSpecialistCommerceChange[k]);
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
}
else
{
pXML->InitList(&m_ppaiSpecialistCommerceChange[k], NUM_COMMERCE_TYPES);
}
}
if (!gDLL->getXMLIFace()->NextSibling(pXML->GetXML()))
{
break;
}
}
// set the current xml node to it's parent node
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
}
// set the current xml node to it's parent node
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
}
I am very confused why this is working in "The History of Three Kingdoms", the modder did not change the CVXMLLoadUtility and I've not found any readPass3 or something like this which is declared with "Civilization Trait".
Who can help me please?