XML tag issue in SDK

OrionVeteran

Deity
Joined
Dec 25, 2003
Messages
2,443
Location
Newport News VA
I have a new tag in CIV4BuildingInfos.xml named: PrereqCivic. Unfortunately, the tag refers to and displays the data from the Civic Option Type: <CivicOptionType>, instead of the Civic type: <Type>

<CivicOption>NONE</CivicOption>
<PrereqCivic>CIVIC_DESPOTISM</PrereqCivic>

How can I change the SDK so that the field data is from the Civic type and not the Civic Option Type.
This is what I have currently in the SDK:

pXML->GetChildXmlValByName(szTextVal, "PrereqCivic");
m_iPrereqCivic = pXML->FindInInfoClass(szTextVal);
 
Code:
LoadGlobalClassInfo(GC.getBuildingClassInfo(), "CIV4BuildingClassInfos", "Buildings", "Civ4BuildingClassInfos/BuildingClassInfos/BuildingClassInfo", false);
LoadGlobalClassInfo(GC.getBuildingInfo(), "CIV4BuildingInfos", "Buildings", "Civ4BuildingInfos/BuildingInfos/BuildingInfo", false, &CvDLLUtilityIFaceBase::createBuildingInfoCacheObject);
for (int i=0; i < GC.getNumBuildingClassInfos(); ++i)
{
    GC.getBuildingClassInfo((BuildingClassTypes)i).readPass3();
}
LoadGlobalClassInfo(GC.getSpecialUnitInfo(), "CIV4SpecialUnitInfos", "Units", "Civ4SpecialUnitInfos/SpecialUnitInfos/SpecialUnitInfo", false);
LoadGlobalClassInfo(GC.getProjectInfo(), "CIV4ProjectInfo", "GameInfo", "Civ4ProjectInfo/ProjectInfos/ProjectInfo", true);
LoadGlobalClassInfo(GC.getCivicInfo(), "CIV4CivicInfos", "GameInfo", "Civ4CivicInfos/CivicInfos/CivicInfo", false, &CvDLLUtilityIFaceBase::createCivicInfoCacheObject);
That's the load code from CvXMLLoadUtilitySet.cpp and that's where the problem is.
Code:
pXML->FindInInfoClass(szTextVal);
This line works as intended, but only on files already read. Since civics are read after buildings, buildings can't refer to civics with the standard code.

Solution 1:
Read civics before buildings. This may or may not mess up something else as you reorder the load code.
Assuming loading civics earlier will fail, it would be possible to load civics twice. Load it before buildings, accept that the loaded contents is a mess, load buildings (the civic types are now available) and then load civics again, which will overwrite the first civic load. The latter load should contain the right data.

Solution 2:
add readPass3 for buildings and call it after loading civics. Use buildingClass as template for this approach.

Solution 3:
Read all xml files twice. I got so fed up with this issue that I wrote code to read the basic info for all files and then read all the files. This way order will not matter as all types are available to all files. It's not a trivial rewrite though and while I planned a modcomp for it, I never actually made it.
 
Solution 3:
Read all xml files twice. I got so fed up with this issue that I wrote code to read the basic info for all files and then read all the files. This way order will not matter as all types are available to all files. It's not a trivial rewrite though and while I planned a modcomp for it, I never actually made it.


I ended up using solution 2: readPass4. This SDK readPass4 solution was really a big pain to deal with. When ever you get around to it, I'd be most interested to see your finished mod comp for solution 3, as I consider solution 2 to be a temporary work around..
 
Back
Top Bottom