While working on the Specialized Cities modmod, I stumbled upon a very weird behavior from the XML. It's not easy describing it so I'll try to be as precise as possible.
In my BuildingInfo.xml file, I wrote the following properties (among others) for a new object type BUILDING_SPECIALIZED_COMMERCE (and class BUILDINGCLASS_SPECIALIZED_COMMERCE):
As you can see, the idea is to give a -20% penalty to building other specialties in the same city and to give a -2% to building the same specialty in other cities.
Now, here's how it is displayed in the Pedia:
It looks like the game somehow mixed the order of the <BuildingClassProductionModifier> tags between <BuildingClassProductionModifiers> and <GlobalBuildingClassProductionModifiers>, leading to the "all cities effect" to be applied on BUILDINGCLASS_SPECIALIZED_MILITARY while the "same-city effect" is applied to every other (including BUILDINGCLASS_SPECIALIZED_COMMERCE).
The same thing happens for every other specialty:
Pedia entry for BUILDINGCLASS_SPECIALIZED_PRODUCTION:
Pedia entry for BUILDINGCLASS_SPECIALIZED_FOOD:
Pedia entry for BUILDINGCLASS_SPECIALIZED_MILITARY:
It looks like whatever I put in <BuildingClassProductionModifiers> and <GlobalBuildingClassProductionModifiers>, all <BuildingClassProductionModifier> are treated in the same order:
BUILDINGCLASS_SPECIALIZED_PRODUCTION
then BUILDINGCLASS_SPECIALIZED_FOOD
then BUILDINGCLASS_SPECIALIZED_COMMERCE
then BUILDINGCLASS_SPECIALIZED_MILITARY
which is incidentally the same order they are declared in the BuildingClassInfo file (don't know if that's a coincidence - EDIT: I tried changing the order in my BuildingClassInfo.xml file and it does indeed change the above order). The "all cities" effect is then applied to the last "batch" of <BuildingClassType> with the same <iProductionModifier>.
The display for BUILDING_SPECIALIZED_MILITARY is the only one which seems correct - which is consistent with this behavior since BUILDINGCLASS_SPECIALIZED_MILITARY is the last one in the abovementioned order.
Edit: Another test, if I put -20 everywhere (including in the <GlobalBuildingClassProductionModifiers>), all buildingclasses production modifiers are interpreted as "to all cities"...
Do you have any idea what's causing this? Is it really a bug from the XML or am I blind to an obvious mistake?
In my BuildingInfo.xml file, I wrote the following properties (among others) for a new object type BUILDING_SPECIALIZED_COMMERCE (and class BUILDINGCLASS_SPECIALIZED_COMMERCE):
Code:
<BuildingClassProductionModifiers>
<BuildingClassProductionModifier>
<BuildingClassType>BUILDINGCLASS_SPECIALIZED_PRODUCTION</BuildingClassType>
<iProductionModifier>-20</iProductionModifier>
</BuildingClassProductionModifier>
<BuildingClassProductionModifier>
<BuildingClassType>BUILDINGCLASS_SPECIALIZED_FOOD</BuildingClassType>
<iProductionModifier>-20</iProductionModifier>
</BuildingClassProductionModifier>
<BuildingClassProductionModifier>
<BuildingClassType>BUILDINGCLASS_SPECIALIZED_MILITARY</BuildingClassType>
<iProductionModifier>-20</iProductionModifier>
</BuildingClassProductionModifier>
</BuildingClassProductionModifiers>
<GlobalBuildingClassProductionModifiers>
<BuildingClassProductionModifier>
<BuildingClassType>BUILDINGCLASS_SPECIALIZED_COMMERCE</BuildingClassType>
<iProductionModifier>-2</iProductionModifier>
</BuildingClassProductionModifier>
</GlobalBuildingClassProductionModifiers>
As you can see, the idea is to give a -20% penalty to building other specialties in the same city and to give a -2% to building the same specialty in other cities.
Now, here's how it is displayed in the Pedia:
It looks like the game somehow mixed the order of the <BuildingClassProductionModifier> tags between <BuildingClassProductionModifiers> and <GlobalBuildingClassProductionModifiers>, leading to the "all cities effect" to be applied on BUILDINGCLASS_SPECIALIZED_MILITARY while the "same-city effect" is applied to every other (including BUILDINGCLASS_SPECIALIZED_COMMERCE).
The same thing happens for every other specialty:
Pedia entry for BUILDINGCLASS_SPECIALIZED_PRODUCTION:
Pedia entry for BUILDINGCLASS_SPECIALIZED_FOOD:
Pedia entry for BUILDINGCLASS_SPECIALIZED_MILITARY:
It looks like whatever I put in <BuildingClassProductionModifiers> and <GlobalBuildingClassProductionModifiers>, all <BuildingClassProductionModifier> are treated in the same order:
BUILDINGCLASS_SPECIALIZED_PRODUCTION
then BUILDINGCLASS_SPECIALIZED_FOOD
then BUILDINGCLASS_SPECIALIZED_COMMERCE
then BUILDINGCLASS_SPECIALIZED_MILITARY
which is incidentally the same order they are declared in the BuildingClassInfo file (don't know if that's a coincidence - EDIT: I tried changing the order in my BuildingClassInfo.xml file and it does indeed change the above order). The "all cities" effect is then applied to the last "batch" of <BuildingClassType> with the same <iProductionModifier>.
The display for BUILDING_SPECIALIZED_MILITARY is the only one which seems correct - which is consistent with this behavior since BUILDINGCLASS_SPECIALIZED_MILITARY is the last one in the abovementioned order.
Edit: Another test, if I put -20 everywhere (including in the <GlobalBuildingClassProductionModifiers>), all buildingclasses production modifiers are interpreted as "to all cities"...
Do you have any idea what's causing this? Is it really a bug from the XML or am I blind to an obvious mistake?