Nightinggale
Deity
- Joined
- Feb 2, 2009
- Messages
- 5,378
Not directly, but with a bit of coding, yes.in Civ4CivilizationInfos.xml (from the top of my head, haven't checked it in the files) you do not add, but exclude certain professions.
Should read like this:
Does your new code cope with that as well?Code:<ProfessionType>PROFESSION_BRAVE</ProfessionType> <bValid>0</bValid>
What InfoArrays does when set to bool reading is that it goes to the array name (FreeBuildingClasses in the example). Here it reads the value of each child (FreeBuildingClass). If the child has children, it will enter the first child recursively until it reaches a value and then it goes back to looking at the next FreeBuildingClass. As a result, it will never look at bValid since it isn't the first child.
The InfoArray converts the strings to ints (just like vanilla arrays does that). It will then assign 1 to the indexes present and 0 to those not present.
The way I would read valid professions from CivilizationInfo is this:
Replace the current array with a JIT array of length numProfessionTypes (PermArray). Set the default value to 1.
Make a temp InfoArray (TempArray) and read the XML data, which can then be written in the short format.
Next subtract TempArray from PermArray. THis will be 1-0=1 for not mentioned professions and 1-1=0 for mentioned professions, precisely the same result as we get with the current code.
The XML reading code will then have to replaced from
Code:
pXML->SetVariableListTagPair(&m_abValidProfessions, "Professions", GC.getNumProfessionInfos(), true);
Code:
InfoArrayBool TempInfo;
TempInfo.read(pXML, "Professions");
m_ja_iValidProfessions.add(TempInfo, -1);
We can then assign the JIT array into an InfoArray if we like. JIT/Bool/Info arrays are aware of each other and can copy data between them with one line commands. (not 100% done with BoolArray implementation for that though)
So a bit more coding, but certainly within the doable range of recoding. TempInfo can be reused for other arrays as well.
Alternatively we can invert the setting to disallow where 1 is disallow and 0 is allow. That mean the InfoArray can read the XML directly, but it will have to invert the answer in the function to read the array data.