1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

The BuildingClass and UnitClass elimination project

Discussion in 'Civ4 - Caveman 2 Cosmos' started by Thunderbrd, Jul 21, 2019.

  1. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    25,686
    Gender:
    Male
    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.
     
  2. raxo2222

    raxo2222 Warlord

    Joined:
    Jun 10, 2011
    Messages:
    5,744
    Location:
    Poland
    I think you meant to tag @billw2015 :p
    And looks like its result of automatic "replace in files..." stuff.
     
  3. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    25,686
    Gender:
    Male
    Location:
    Las Vegas
    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?
     
  4. Toffer90

    Toffer90 C2C Modder

    Joined:
    Oct 16, 2011
    Messages:
    5,872
    Location:
    Norway
    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. ^^
     
  5. raxo2222

    raxo2222 Warlord

    Joined:
    Jun 10, 2011
    Messages:
    5,744
    Location:
    Poland
    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.
     
  6. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    25,686
    Gender:
    Male
    Location:
    Las Vegas
    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.
     
  7. raxo2222

    raxo2222 Warlord

    Joined:
    Jun 10, 2011
    Messages:
    5,744
    Location:
    Poland
    @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: Jul 21, 2019
    Anq likes this.
  8. billw2015

    billw2015 Chieftain

    Joined:
    Jun 22, 2015
    Messages:
    278
    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.
     
    Anq and raxo2222 like this.
  9. raxo2222

    raxo2222 Warlord

    Joined:
    Jun 10, 2011
    Messages:
    5,744
    Location:
    Poland
    Adjusting like 8250 enties by hand would be bit annoying lol
     
  10. Dancing Hoskuld

    Dancing Hoskuld Warlord

    Joined:
    Jul 5, 2004
    Messages:
    23,168
    Gender:
    Male
    Location:
    Canberra, Australia
    The animals ones are because I wrote the text but have not built the buildings yet.
     
    raxo2222 and Anq like this.
  11. raxo2222

    raxo2222 Warlord

    Joined:
    Jun 10, 2011
    Messages:
    5,744
    Location:
    Poland
    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.
     
  12. raxo2222

    raxo2222 Warlord

    Joined:
    Jun 10, 2011
    Messages:
    5,744
    Location:
    Poland
    @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: Jul 22, 2019
  13. Dancing Hoskuld

    Dancing Hoskuld Warlord

    Joined:
    Jul 5, 2004
    Messages:
    23,168
    Gender:
    Male
    Location:
    Canberra, Australia
    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.
     
    raxo2222 likes this.
  14. raxo2222

    raxo2222 Warlord

    Joined:
    Jun 10, 2011
    Messages:
    5,744
    Location:
    Poland
    So I guess I have to revert that one where I deleted commented out animal class infos.
     
  15. JosEPh_II

    JosEPh_II TBS WarLord

    Joined:
    Jun 20, 2007
    Messages:
    15,441
    Gender:
    Male
    Location:
    Western IL. cornfields
    @raxo2222

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

    Misspelled
     
  16. Toffer90

    Toffer90 C2C Modder

    Joined:
    Oct 16, 2011
    Messages:
    5,872
    Location:
    Norway
    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 likes this.
  17. raxo2222

    raxo2222 Warlord

    Joined:
    Jun 10, 2011
    Messages:
    5,744
    Location:
    Poland
    Oops, will fix that on my next commit.

    Well Catacombs wonder has help text denoting its python effects.
     
  18. JosEPh_II

    JosEPh_II TBS WarLord

    Joined:
    Jun 20, 2007
    Messages:
    15,441
    Gender:
    Male
    Location:
    Western IL. cornfields
    Already fixed it and committed.
     
    raxo2222 likes this.
  19. Anq

    Anq Chieftain

    Joined:
    Apr 14, 2019
    Messages:
    350
    Gender:
    Male
    Location:
    Anser (geese) HQ
    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, '', '', '')
    
     
    raxo2222, Toffer90 and billw2015 like this.
  20. MattCA

    MattCA Chieftain

    Joined:
    Jan 25, 2019
    Messages:
    94
    Gender:
    Male
    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: Jul 22, 2019

Share This Page