phungus420
Deity
- Joined
- Mar 1, 2003
- Messages
- 6,296
I'm still not seeing it. Anyway gotten everything else done. I just need to get this interface issue working correctly and then I can submit the code to be updated to RevDCM.
#phungus canTrain
[b]bFirst = true[/b]
for j in range(gc.getNumCivicInfos()):
if (gc.getUnitInfo(self.iUnit).getPrereqOrCivics(j)):
[b]if !bFirst:
screen.attachLabel(panelName, "", localText.getText("TXT_KEY_OR", ()))[/b]
eCivic = CivicTypes(j)
screen.attachImageButton(panelName, "", gc.getCivicInfo(eCivic).getButton(), GenericButtonSizes.BUTTON_SIZE_CUSTOM, WidgetTypes.WIDGET_PEDIA_JUMP_TO_CIVIC, eCivic, -1, False)
[b]bFirst = false[/b]
#phungus -end
Troubles with Arrays and Arrays of Arrays...
def refreshPlayerTabCtrl(self):
initWBToolPlayerControl()
self.m_normalPlayerTabCtrl = getWBToolNormalPlayerTabCtrl()
self.m_normalPlayerTabCtrl.setNumColumns((gc.getNumUnitInfos()/10)+2);
self.m_normalPlayerTabCtrl.addTabSection(localText.getText("TXT_KEY_WB_UNITS",()));
self.m_iUnitTabID = 0
self.m_iNormalPlayerCurrentIndexes.append(0)
self.m_normalPlayerTabCtrl.setNumColumns((gc.getNumBuildingInfos()/10)+1);
self.m_normalPlayerTabCtrl.addTabSection(localText.getText("TXT_KEY_WB_BUILDINGS",()));
self.m_iBuildingTabID = 1
self.m_iNormalPlayerCurrentIndexes.append(0)
self.m_normalPlayerTabCtrl.setNumColumns((gc.getNumTechInfos()/10)+1);
self.m_normalPlayerTabCtrl.addTabSection(localText.getText("TXT_KEY_WB_TECHNOLOGIES",()));
self.m_iTechnologyTabID = 2
self.m_iNormalPlayerCurrentIndexes.append(0)
addWBPlayerControlTabs()
return
bFirst = true
for <your loop>
if <your test>
if !bFirst: print " or "
bFirst = false
print <your data>
There isn't much. The python exception just says unidefentified C++ exception caused by the last line: addWBPlayerControlTabs(), in the posted function above.It would be easier to make suggestions about your python error in WB if you posted the error itself and the related line numbers.
//These functions value health and happiness the same as regular health
//and happiness, but only if the team has the prereq tech researched
for (iI = 0; iI < GC.getNumTechInfos(); iI++)//Afforess
{
if (kBuilding.getTechHappinessChanges(iI) != 0)
{
if (GET_TEAM(getTeam()).isHasTech((TechTypes)iI))
{
iValue += (std::min(kBuilding.getTechHappinessChanges(iI), iAngryPopulation) * 10) + (std::max(0, kBuilding.getTechHappinessChanges(iI) - iAngryPopulation) * iHappyModifier);
}
}
if (kBuilding.getTechHealthChanges(iI) != 0)
{
if (GET_TEAM(getTeam()).isHasTech((TechTypes)iI))
{
iValue += (std::min(kBuilding.getTechHappinessChanges(iI), iBadHealth) * 12) + (std::max(0, kBuilding.getTechHappinessChanges(iI) - iBadHealth) * iHealthModifier);
}
}
}
for (iI = 0; iI < GC.getNumTechInfos(); iI++)
{
if ((eIgnoreTech == NO_TECH) || (iI != eIgnoreTech))
{
if ((eIgnoreAdvisor == NO_ADVISOR) || (GC.getTechInfo((TechTypes)iI).getAdvisorType() != eIgnoreAdvisor))
{
if (canEverResearch((TechTypes)iI))
{
if (!(kTeam.isHasTech((TechTypes)iI)))
{
if (GC.getTechInfo((TechTypes)iI).getEra() <= (getCurrentEra() + 1))
{
...
for (iJ = 0; iJ < GC.getNumBuildingClassInfos(); iJ++)
{
eLoopBuilding = ((BuildingTypes)(GC.getCivilizationInfo(getCivilizationType()).getCivilizationBuildings(iJ)));
if (eLoopBuilding != NO_BUILDING)
{
CvBuildingInfo& kLoopBuilding = GC.getBuildingInfo(eLoopBuilding);
if (kLoopBuilding.getTechHealthChanges((TechTypes)iI) != 0) //Afforess
{
iValue += (kLoopBuilding.getTechHealthChanges((TechTypes)iI) * 50);
}
if (kLoopBuilding.getTechHappinessChanges((TechTypes)iI) != 0)
{
iValue += (kLoopBuilding.getTechHappinessChanges((TechTypes)iI) * 100);
}
...
The python exception just says unidefentified C++ exception caused by the last line: addWBPlayerControlTabs(), in the posted function above.
Thanks davidallen, I have tracked the cause to the state religion check, and not the array. Will investigate further and start a new thread on this bug if I can't figure it out, as my current problem doesn't seem to be related to arrays..That is odd. This function is inside the game engine, not inside the sdk. If you remove the OrPrereq from your xml only, does WB work then? I guess the function is building the pickbox of all the unit icons. I can't imagine that this step would actually use any of your new code, so it is a mystery why it would crash.
<TechYieldChanges>
<TechYieldChange>
<PrereqTech>TECH_AQUACULTURE</PrereqTech>
<TechYields>
<iYield>0</iYield>
<iYield>0</iYield>
<iYield>1</iYield>
</TechYields>
</TechYieldChange>
</TechYieldChanges>
<PrereqBuildingClasses>
<PrereqBuildingClass>
<BuildingClassType>NONE</BuildingClassType>
<bPrereq>1</bPrereq>
<TechOverride>NONE</TechOverride>
</PrereqBuildingClass>
</PrereqBuildingClasses>
// initialize the boolean list to the correct size and all the booleans to false
FAssertMsg((GC.getNumTechInfos() > 0) && (NUM_YIELD_TYPES) > 0,"either the number of tech infos is zero or less or the number of yield types is zero or less");
pXML->Init2DIntList(&m_ppiTechYieldChanges, GC.getNumTechInfos(), NUM_YIELD_TYPES);
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(),"TechYieldChanges"))
{
if (pXML->SkipToNextVal())
{
iNumSibs = gDLL->getXMLIFace()->GetNumChildren(pXML->GetXML());
if (gDLL->getXMLIFace()->SetToChild(pXML->GetXML()))
{
if (0 < iNumSibs)
{
for (j=0;j<iNumSibs;j++)
{
pXML->GetChildXmlValByName(szTextVal, "PrereqTech");
iIndex = pXML->FindInInfoClass(szTextVal);
if (iIndex > -1)
{
// delete the array since it will be reallocated
SAFE_DELETE_ARRAY(m_ppiTechYieldChanges[iIndex]);
// if we can set the current xml node to it's next sibling
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(),"TechYields"))
{
// call the function that sets the yield change variable
pXML->SetYields(&m_ppiTechYieldChanges[iIndex]);
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
}
else
{
pXML->InitList(&m_ppiTechYieldChanges[iIndex], NUM_YIELD_TYPES);
}
}
if (!gDLL->getXMLIFace()->NextSibling(pXML->GetXML()))
{
break;
}
}
}
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
}
}
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
}
pXML->SetVariableListTagPair(&m_pbPrereqBuildingClass, "PrereqBuildingClasses", sizeof(GC.getBuildingClassInfo((BuildingClassTypes)0)), GC.getNumBuildingClassInfos());
<PrereqBuildingClasses>
<PrereqBuildingClass>
<BuildingClassType>NONE</BuildingClassType>
<bPrereq>1</bPrereq>
<TechOverride>NONE</TechOverride>
</PrereqBuildingClass>
</PrereqBuildingClasses>
iIndexVal = FindInInfoClass(szTextVal);
if (iIndexVal != -1)
{
GetNextXmlVal(&piList[iIndexVal]);
}
<PrereqBuildingClasses>
<PrereqBuildingClass>
<BuildingClassType>BUILDINGCLASS_FORGE</BuildingClassType>
<bPrereq>1</bPrereq>
</PrereqBuildingClass>
<PrereqBuildingClasses>
<PrereqBuildingTechOverrides>
<PrereqBuildingTechOverride>
<BuildingClassType>BUILDINGCLASS_FORGE</BuildingClassType>
<TechOverride>TECH_MACHINERY</TechOverride>
</PrereqBuildingTechOverride>
</PrereqBuildingTechOverrides>
While that's often sensible, in this case it's not. If I don't deal with it now, there are going to be constant logic issues that creep up from having two arrays virtually doing the same thing, especially if the modder enters conflicting info in them. This is one of those places where it's better to just do the work up front and make sure it's working correctly, in my oppinion.It is software, I am sure it is *possible* to add a third child and pass along the field names. I tend to go "around" obstacles like this by using a different xml coding style, rather than going "through" them.