I've been trying to add an building property that allows buildings to produce commerce and/or yields from resources, but this version would allow different amounts of resources to be produced for different bonuses. The additions at the moment aren't working (I'm testing using a capital building with these properties, and either the game crashes when the capital is founded, or doesn't do anything, depending on how I try it), and thus, this thread to try and sort out the issues.
Starting with CvInfos, does the code written below appear right, and when using a "getNumber(number 1, number 2)" function, are bonuses the first number and the type of commerce the second number, or the reverse? (I do kind of see what this function is doing in general, but by specifics it is harder to tell.). the code was just copied and adjusted from specialist yield changes on buildings.
Starting with CvInfos, does the code written below appear right, and when using a "getNumber(number 1, number 2)" function, are bonuses the first number and the type of commerce the second number, or the reverse? (I do kind of see what this function is doing in general, but by specifics it is harder to tell.). the code was just copied and adjusted from specialist yield changes on buildings.
Spoiler :
Code:
pXML->Init2DIntList(&m_ppiCommerceFromBonus, GC.getNumBonusInfos(), NUM_COMMERCE_TYPES);
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(),"CommercesFromBonus"))
{
iNumChildren = gDLL->getXMLIFace()->GetNumChildren(pXML->GetXML());
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(),"CommerceFromBonus"))
{
for(j=0;j<iNumChildren;j++)
{
pXML->GetChildXmlValByName(szTextVal, "BonusConsumed");
k = pXML->FindInInfoClass(szTextVal);
SAFE_DELETE_ARRAY(m_ppiCommerceFromBonus[k]);
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(),"iCommerce") && (k > -1))
{
pXML->SetCommerce(&m_ppiCommerceFromBonus[k]);
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
}
else
{
pXML->InitList(&m_ppiCommerceFromBonus[k], NUM_COMMERCE_TYPES);
}
if (!gDLL->getXMLIFace()->NextSibling(pXML->GetXML()))
{
break;
}
}
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
}
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
}
pXML->Init2DIntList(&m_ppiYieldFromBonus, GC.getNumSpecialistInfos(), NUM_YIELD_TYPES);
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(),"YieldsFromBonus"))
{
iNumChildren = gDLL->getXMLIFace()->GetNumChildren(pXML->GetXML());
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(),"YieldFromBonus"))
{
for(j=0;j<iNumChildren;j++)
{
pXML->GetChildXmlValByName(szTextVal, "BonusConsumed");
k = pXML->FindInInfoClass(szTextVal);
SAFE_DELETE_ARRAY(m_ppiYieldFromBonus[k]);
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(),"iCommerce") && (k > -1))
{
pXML->SetCommerce(&m_ppiYieldFromBonus[k]);
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
}
else
{
pXML->InitList(&m_ppiYieldFromBonus[k], NUM_YIELD_TYPES);
}
if (!gDLL->getXMLIFace()->NextSibling(pXML->GetXML()))
{
break;
}
}
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
}
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
}