The BuildingClass and UnitClass elimination project

Thunderbrd

C2C War Dog
Joined
Jan 2, 2010
Messages
29,813
Location
Las Vegas
@Anq, @alberts2, @BillW

And anyone else who cares to contribute to this project.

I finally got the branch repository up and running on my end, in part to practice how to work with branches. I wanted to review the project and add any insights I can into the mix. I'm not sure how much I will directly apply any efforts to this because I don't want to step on toes.

So this is now our place to discuss this subject in all the deepest of depth it can get so that the more generic threads aren't conquered by these discussions which can get detailed.


My first observation in a recent compare is this:

upload_2019-7-21_11-46-20.png

If we are getting rid of BuildingClass, we shouldn't need a tag for <Building> in the BuildingInfos at all. That's basically what <Type> IS at this point, right?

I'll be looking into more here but that's my first 'huh?' moment. I realize some of this might be mostly due to automatic find/replace actions at the moment.
 
I think you meant to tag @billw2015 :p
And looks like its result of automatic "replace in files..." stuff.
Yes, and fair enough, but I also want to catch some things before it ends up being a major waste of a lot of time if it is costing any.

For example:
upload_2019-7-21_12-6-32.png

I'm thinking that we won't have a buildingclassinfos file at all after this is complete, right? And those tags that are located here need to be relocated over to the original building xmls.

So that I understand the process in action here, the planned steps for that migration is at a later point here I take it?
 
So that I understand the process in action here, the planned steps for that migration is at a later point here I take it?
I'm guessing that is the case, that it's a jury rigging that is only the first step in removing buildinclasses entirely.
Anq mentioned something about changing it so that buildingclasses are seen as buildings by a part of the dll as a first step in tackling this stuff. Or something like that...

Like an extra step that will be removed in the end when the stairs are complete.
Like a temporary girder that holds the structure up while the walls are being teared down and built up differently again.
Like the jack that keeps the car up while the tires get changed.
That's enough Toffer, you gotta stop. ^^
 
Yes, and fair enough, but I also want to catch some things before it ends up being a major waste of a lot of time if it is costing any.

For example:
View attachment 530267
I'm thinking that we won't have a buildingclassinfos file at all after this is complete, right? And those tags that are located here need to be relocated over to the original building xmls.

So that I understand the process in action here, the planned steps for that migration is at a later point here I take it?
Yeah, it seems like those will be relocated to building/unit infos.
<buildinginfo> looks like good nesting tag for this stuff.
<defaultbuilding> should be gone, as only that one was used to make unique buildings and units.
 
Reviewing the changes in the first commit he did, it does look like the tags are being migrated properly so that's awesome. I get it. Just trying to follow along the process here.
 
@Anq take note that following items are commented out in building and unit class infos:
@Dancing Hoskuld I found one commented out religious building and some animal related stuff
Spoiler :

BUILDING_CHOQUEQUIRAO - Only art and text exists
BUILDING_ANTELOPE_STORY - Only text exists
BUILDING_BIRD_STORY - Class defined twice
BUILDING_BOAR_STORY - Class defined twice
BUILDING_BULL_STORY - Only text exists
BUILDING_CAMEL_STORY - Only text exists
BUILDING_CRAB_STORY - Class defined twice
BUILDING_DEER_STORY - Only text exists
BUILDING_ELEPHANT_STORY - Only text exists
BUILDING_FISH_STORY - Class defined twice
BUILDING_GOAT_STORY - Only text exists
BUILDING_LLAMA_STORY - Class defined twice
BUILDING_LION_STORY - Class defined twice
BUILDING_MARSUPIAL_STORY - Only text exists
BUILDING_OLD_MAN_STORY - Only text exists
BUILDING_RAY_STORY - Only text exists
BUILDING_SCAVENGER_STORY - Only text exists
BUILDING_SPOTTED_CAT_STORY - Only text exists
BUILDING_TIGER_STORY - Only text exists
BUILDING_TUNA_STORY - Class defined twice
BUILDING_WEASEL_STORY - Only text exists
UNIT_NEANDERTHAL_WARDOG - I commented out that one - it was too far in tech tree, as I made all neanderthal units forceobsolete at Copper Working
BUILDING_CATACOMBS - Looks fully functional but this wonder is disabled (faulty Python?)
BUILDING_ZIZKOV - Looks fully functional but this wonder is disabled (faulty Python?)
BUILDING_CANCER - Probably it was Project <-(OR)-> Wonder conversion, that wasn't fully cleaned
BUILDING_SMELTER_BRONZE - Only art and text exists
BUILDING_CRIME_TPING - Only text exists
BUILDING_CRIME_FLASHING - Only text exists
BUILDING_CRIME_CARCHASE - Only text exists
BUILDING_CRIME_ROGUEMERCENARIES - Only text exists
BUILDING_CRIME_POWERSTRUGGLES - Only text exists
BUILDING_CRIME_STOCKMARKETRIGGING - Only text exists
BUILDING_CRIME_CORPORATEMANSLAUGHTER - Only text exists
BUILDING_CRIME_PONZISCHEMING - Only text exists
BUILDING_HOLIDAY_HALLOWEEN - Meant to be series of holidays, nothing was done for 5 years and was commented out
BUILDING_KNOWLEDGE_BASE_INDUSTRIAL - Industrial and later knowledge bases were commented out due to insufficient education output in later eras.
BUILDING_KNOWLEDGE_BASE_MODERN
BUILDING_KNOWLEDGE_BASE_INFORMATION
BUILDING_KNOWLEDGE_BASE_NANOTECH
BUILDING_KNOWLEDGE_BASE_TRANSHUMAN
BUILDING_KNOWLEDGE_BASE_GALACTIC
BUILDING_KNOWLEDGE_BASE_COSMIC
BUILDING_KNOWLEDGE_BASE_TRANSCENDENT
BUILDING_JOUSTING_ARENA - Probably meant to be separate building
BUILDING_OUTDOOR_RECREATION_CENTER - Only art and text exist
BUILDING_OLYMPICS - Only art and text exist
BUILDING_NIVKH_EMBASSY - Only art and text exist


So looks like mostly animals and special buildings.
 
Last edited:
  • Like
Reactions: Anq
FYI Anq or I are going to write a script to do the XML transform, so if there are problems with it we can re-run it after changing the rules. It is pretty simple thus far, just renaming some variables and copying some non-default variables from the associated building class.
 
FYI Anq or I are going to write a script to do the XML transform, so if there are problems with it we can re-run it after changing the rules. It is pretty simple thus far, just renaming some variables and copying some non-default variables from the associated building class.
Adjusting like 8250 enties by hand would be bit annoying lol
 
@Anq take note that following items are commented out in building and unit class infos:
@Dancing Hoskuld I found one commented out religious building and some animal related stuff
Spoiler :

BUILDING_CHOQUEQUIRAO - Only art and text exists
BUILDING_ANTELOPE_STORY - Only text exists
BUILDING_BIRD_STORY - Class defined twice
BUILDING_BOAR_STORY - Class defined twice
BUILDING_BULL_STORY - Only text exists
BUILDING_CAMEL_STORY - Only text exists
BUILDING_CRAB_STORY - Class defined twice
BUILDING_DEER_STORY - Only text exists
BUILDING_ELEPHANT_STORY - Only text exists
BUILDING_FISH_STORY - Class defined twice
BUILDING_GOAT_STORY - Only text exists
BUILDING_LLAMA_STORY - Class defined twice
BUILDING_LION_STORY - Class defined twice
BUILDING_MARSUPIAL_STORY - Only text exists
BUILDING_OLD_MAN_STORY - Only text exists
BUILDING_RAY_STORY - Only text exists
BUILDING_SCAVENGER_STORY - Only text exists
BUILDING_SPOTTED_CAT_STORY - Only text exists
BUILDING_TIGER_STORY - Only text exists
BUILDING_TUNA_STORY - Class defined twice
BUILDING_WEASEL_STORY - Only text exists
UNIT_NEANDERTHAL_WARDOG - I commented out that one - it was too far in tech tree, as I made all neanderthal units forceobsolete at Copper Working
BUILDING_CATACOMBS - Looks fully functional but this wonder is disabled (faulty Python?)
BUILDING_ZIZKOV - Looks fully functional but this wonder is disabled (faulty Python?)
BUILDING_CANCER - Probably it was Project <-(OR)-> Wonder conversion, that wasn't fully cleaned
BUILDING_SMELTER_BRONZE - Only art and text exists
BUILDING_CRIME_TPING - Only text exists
BUILDING_CRIME_FLASHING - Only text exists
BUILDING_CRIME_CARCHASE - Only text exists
BUILDING_CRIME_ROGUEMERCENARIES - Only text exists
BUILDING_CRIME_POWERSTRUGGLES - Only text exists
BUILDING_CRIME_STOCKMARKETRIGGING - Only text exists
BUILDING_CRIME_CORPORATEMANSLAUGHTER - Only text exists
BUILDING_CRIME_PONZISCHEMING - Only text exists
BUILDING_HOLIDAY_HALLOWEEN - Meant to be series of holidays, nothing was done for 5 years and was commented out
BUILDING_KNOWLEDGE_BASE_INDUSTRIAL - Industrial and later knowledge bases were commented out due to insufficient education output in later eras.
BUILDING_KNOWLEDGE_BASE_MODERN
BUILDING_KNOWLEDGE_BASE_INFORMATION
BUILDING_KNOWLEDGE_BASE_NANOTECH
BUILDING_KNOWLEDGE_BASE_TRANSHUMAN
BUILDING_KNOWLEDGE_BASE_GALACTIC
BUILDING_KNOWLEDGE_BASE_COSMIC
BUILDING_KNOWLEDGE_BASE_TRANSCENDENT
BUILDING_JOUSTING_ARENA - Probably meant to be separate building
BUILDING_OUTDOOR_RECREATION_CENTER - Only art and text exist
BUILDING_OLYMPICS - Only art and text exist
BUILDING_NIVKH_EMBASSY - Only art and text exist


So looks like mostly animals and special buildings.
The animals ones are because I wrote the text but have not built the buildings yet.
 
The animals ones are because I wrote the text but have not built the buildings yet.
What about BUILDING_CHOQUEQUIRAO - it was Andean religious building, it had default tags before getting removed when you modularized this religion.
Can be this deleted completely - that is art define, class building and text?

Also animal class building that exists twice (is in two different module) can be removed - that one which was commented out.
 
@Toffer90 I'm going to reenable Zizkov and Catacombs - two Platyping wonders, can you check them python side?

Check their game text for supposed Python abilities.

Following class buildings are not being removed:
Spoiler :

BUILDING_ANTELOPE_STORY - Only text exists
BUILDING_BULL_STORY - Only text exists
BUILDING_CAMEL_STORY - Only text exists
BUILDING_DEER_STORY - Only text exists
BUILDING_ELEPHANT_STORY - Only text exists
BUILDING_GOAT_STORY - Only text exists
BUILDING_MARSUPIAL_STORY - Only text exists
BUILDING_OLD_MAN_STORY - Only text exists
BUILDING_RAY_STORY - Only text exists
BUILDING_SCAVENGER_STORY - Only text exists
BUILDING_SPOTTED_CAT_STORY - Only text exists
BUILDING_TIGER_STORY - Only text exists
BUILDING_WEASEL_STORY - Only text exists

BUILDING_CATACOMBS - Looks fully functional but this wonder is disabled (faulty Python?)
BUILDING_ZIZKOV - Looks fully functional but this wonder is disabled (faulty Python?)

BUILDING_KNOWLEDGE_BASE_INDUSTRIAL - Industrial and later knowledge bases were commented out due to insufficient education output in later eras.
BUILDING_KNOWLEDGE_BASE_MODERN
BUILDING_KNOWLEDGE_BASE_INFORMATION
BUILDING_KNOWLEDGE_BASE_NANOTECH
BUILDING_KNOWLEDGE_BASE_TRANSHUMAN
BUILDING_KNOWLEDGE_BASE_GALACTIC
BUILDING_KNOWLEDGE_BASE_COSMIC
BUILDING_KNOWLEDGE_BASE_TRANSCENDENT

Animals - DH is going add story building to these, now text and building class are placeholders.
Catacombs/Zizkov - were almost complete wonders except for python side as most likely reason.
Knowledge Base - were disabled due to insufficient education generation in later eras.

Others were removed for being duplicate, for being soft renamed - most likely they exist under different names or for being abandoned so long ago.
 
Last edited:
Also animal class building that exists twice (is in two different module) can be removed - that one which was commented out.
The commented out ones are there to remind me that more buildings are needed in some cases. I am old and need reminders. Besides commented out code is not used.
 
The commented out ones are there to remind me that more buildings are needed in some cases. I am old and need reminders. Besides commented out code is not used.
So I guess I have to revert that one where I deleted commented out animal class infos.
 
@raxo2222

<Type>BUILDING_TOURNAMENT</Type>
<Description>TXT_KEY_BUILDING_TOURNAMRNT</Description>
<Civilopedia>TXT_KEY_BUILDING_TOURNAMENT_PEDIA</Civilopedia>

Misspelled
 
@Toffer90 I'm going to reenable Zizkov and Catacombs - two Platyping wonders, can you check them python side?
I'm pretty sure I rewrote the zizkov wonder python effect in PPIO as it was nonsense the way it was. I'll look at it again, don't remember catacombs having a python effect, though that may mean that I didn't see any problems with the code it have.
 
@raxo2222

<Type>BUILDING_TOURNAMENT</Type>
<Description>TXT_KEY_BUILDING_TOURNAMRNT</Description>
<Civilopedia>TXT_KEY_BUILDING_TOURNAMENT_PEDIA</Civilopedia>

Misspelled
Oops, will fix that on my next commit.

I'm pretty sure I rewrote the zizkov wonder python effect in PPIO as it was nonsense the way it was. I'll look at it again, don't remember catacombs having a python effect, though that may mean that I didn't see any problems with the code it have.
Well Catacombs wonder has help text denoting its python effects.
 
Oops, will fix that on my next commit.


Well Catacombs wonder has help text denoting its python effects.
Already fixed it and committed.
 
I've done the BuildingClass part with a little python script to make it right. Now let me think of how to reenable civilization unique Native Cultures and disable Barbarians from advanced buildings and wonders....

Spoiler my little python script :
invoke with
Code:
processClass.py *BuildingClassInfos.xml *BuildingInfos-xml-list.txt
Code:
import sys
import os
import xml.dom.minidom as DOM

mappings = dict()
Base = DOM.parse(sys.argv[1])
for Tag in Base.getElementsByTagName("Civ4BuildingClassInfos")[0].getElementsByTagName("BuildingClassInfos")[0].getElementsByTagName("BuildingClassInfo"):
    Type = Tag.getElementsByTagName("Type")[0].childNodes[0].wholeText
    if Tag.getElementsByTagName("bNoLimit"):
        tagE = Tag.getElementsByTagName("bNoLimit")[0].childNodes[0].wholeText
        if tagE != "0":
            if not mappings.get(Type):
                mappings[Type] = dict()
            mappings[Type]["bNoLimit"] = tagE
    if Tag.getElementsByTagName("iExtraPlayerInstances"):
        tagD = Tag.getElementsByTagName("iExtraPlayerInstances")[0].childNodes[0].wholeText
        if tagD != "-1":
            if not mappings.get(Type):
                mappings[Type] = dict()
            mappings[Type]["iExtraPlayerInstances"] = tagD
    if Tag.getElementsByTagName("iMaxPlayerInstances"):
        tagC = Tag.getElementsByTagName("iMaxPlayerInstances")[0].childNodes[0].wholeText
        if tagC != "-1":
            if not mappings.get(Type):
                mappings[Type] = dict()
            mappings[Type]["iMaxPlayerInstances"] = tagC
    if Tag.getElementsByTagName("iMaxTeamInstances"):
        tagB = Tag.getElementsByTagName("iMaxTeamInstances")[0].childNodes[0].wholeText
        if tagB != "-1":
            if not mappings.get(Type):
                mappings[Type] = dict()
            mappings[Type]["iMaxTeamInstances"] = tagB
    if Tag.getElementsByTagName("iMaxGlobalInstances"):
        tagA = Tag.getElementsByTagName("iMaxGlobalInstances")[0].childNodes[0].wholeText
        if tagA != "-1":
            if not mappings.get(Type):
                mappings[Type] = dict()
            mappings[Type]["iMaxGlobalInstances"] = tagA
if mappings.keys():
    with open(sys.argv[2], "r") as Filestxt:
        for xmlfile in [x.strip() for x in Filestxt.readlines()]:
            Target = DOM.parse(xmlfile)
            TargetHead = DOM.parse(xmlfile)
            TargetHead.removeChild(TargetHead.getElementsByTagName("Civ4BuildingInfos")[0])
            modified = 0
            for Tag in Target.getElementsByTagName("Civ4BuildingInfos")[0].getElementsByTagName("BuildingInfos")[0].getElementsByTagName("BuildingInfo"):
                if Tag.getElementsByTagName("BuildingClass") and Tag.getElementsByTagName("BuildingClass")[0].childNodes[0].wholeText in mappings:
                    ID = Tag.getElementsByTagName("BuildingClass")[0].childNodes[0].wholeText
                    OldType = Tag.getElementsByTagName("Type")[0]
                    TypeTag = Target.createElement("Type")
                    TypeTag.appendChild(Target.createTextNode(OldType.childNodes[0].wholeText))
                    for NewTag in mappings[ID].keys():
                        MyTag=Target.createElement(NewTag)
                        MyTag.appendChild(Target.createTextNode(mappings[ID][NewTag]))
                        Tag.insertBefore(MyTag,Tag.getElementsByTagName("Type")[0])
                        Tag.removeChild(Tag.getElementsByTagName("Type")[0])
                        Tag.insertBefore(TypeTag,Tag.getElementsByTagName(NewTag)[0])
                        Tag.insertBefore(Target.createTextNode("\n\t\t\t"),Tag.getElementsByTagName(NewTag)[0])
                    modified = 1
            newxml = os.path.dirname(xmlfile)+os.path.sep+os.path.splitext(os.path.basename(xmlfile))[0]+"-processed.xml"
            if modified == 1:
                with open(xmlfile, "w") as Out:
                    TargetHead.writexml(Out, '', '\t', '\n', 'UTF-8')
                    Target.documentElement.writexml(Out, '', '', '')
 
Now let me think of how to reenable civilization unique Native Cultures
single int?
Code:
//infos.h
 int getNativeCultureGroup() const;
 void setNativeCultureGroup(int i);

 int m_iNativeCultureGroup;

//city.cpp
//new code
  setNumRealBuilding((BuildingTypes)GC.getCivilizationInfo(getCivilizationType()).getNativeCultureGroup(), 1);

//current code
 
   for (iI = 0; iI < GC.getNumBuildingClassInfos(); iI++)
      {
          if (GC.getCivilizationInfo(getCivilizationType()).isCivilizationFreeBuildingClass(iI))
          {
               eLoopBuilding = ((BuildingTypes)(GC.getCivilizationInfo(getCivilizationType()).getCivilizationBuildings(iI)));

              if (eLoopBuilding != NO_BUILDING)
              {
                   setNumRealBuilding(eLoopBuilding, 1);
              }
        }
   }
or something like that?
I got more code if u want me to copy paste to a file. I can also rename stuff if the team wants while im at it.
I quit makin this after seeing how fast you go Anq, haha ur way too fast for me to be any help. you probly got this part all done already.
Oh and there's a few more things that don't seem necessary to me
Code:
 int* m_piCivilizationFreeUnitsClass;
 int* m_piCivilizationInitialCivics;
 bool* m_pbCivilizationFreeTechs;
 bool* m_pbCivilizationDisableTechs;
top 1 u guys will probly take care of with unitClass
bottom 2 are an array of true/false, one per tech for each civ.
 
Last edited:
Top Bottom