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

Caveman 2 Cosmos (ideas/discussions thread)

Discussion in 'Civ4 - Caveman 2 Cosmos' started by strategyonly, Sep 3, 2010.

  1. raxo2222

    raxo2222 Warlord

    Joined:
    Jun 10, 2011
    Messages:
    4,907
    Location:
    Poland
    This variable is in CIV4LeaderHeadInfos in folder: Caveman2Cosmos\Assets\XML\Civilizations
    Look at iBuildUnitProb - this variable dictates how often barbarians will build units.
    LEADER_BARBARIAN - barbarians
    LEADER_NEANDERTHAL - neanderthal.
    Currently iBuildUnitProb is set to 30 for both of them.
     
  2. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    24,891
    Gender:
    Male
    Location:
    Las Vegas
    I'm not sure that there's a specific variable directly for Barbs. I could be wrong. We could use other aspects that impact them to nerf their production rates though, and I don't think that's a bad idea considering what you're seeing IS a bit too much and is likely to be very problematic. I think they might be getting BOOSTS to unit production right now from their traits or a barbarian autobuilding, and reducing that would probably be good.
    Not enough to address things because it only works when they have other options and they don't have all that many buildings and other things to do. Their overall production needs to be decreased, not so much their will to spend their production on units.
     
  3. alberts2

    alberts2 Chieftain

    Joined:
    Aug 16, 2012
    Messages:
    1,637
    Gender:
    Male
    Location:
    Germany
    That ins't a memory leak!
    With the graphic paging option enabled the graphics engine only sees an small part of the map not the whole map and that reduces the memory usage of the graphics engine.
    At some places on a map the the graphics engine needs more memory and other places it needs less memory.

    The graphic paging option has no effect in the word builder, that's why it is impossible to edit big saves.
     
  4. raxo2222

    raxo2222 Warlord

    Joined:
    Jun 10, 2011
    Messages:
    4,907
    Location:
    Poland
    I mean after clicking several times on minimap memory usage doesn't go down if I leave it alone.
    That is memory usage doesn't fluctuate but steadily goes up as I clicked on different places on minimap and it doesn't decrease.
    Try that save, if there wasn't leak, then I would see fluctuating memory usage in task manager depending on place, that I clicked in minimap just like you said.
    Base load with my RAM saving settings on that save was slightly above 2100 MB, and then it slowly consumed 700 MB of ram until it crashed.

    I guess there is too much liberty here - that stuff should be immediately unloaded when I click on different point of minimap and then load stuff in place that I'm currently on.
     
    Last edited: May 6, 2019
  5. Toffer90

    Toffer90 C2C Modder

    Joined:
    Oct 16, 2011
    Messages:
    5,314
    Location:
    Norway
    Nothing wrong with the xml, -1 is the recommended value for those.
    The placement of walrus and sea lions are dealt with in python code which I disabled for the world mapscript. Never got around to making a substitute system for placing them, which is what I intended when I disabled the standard system.
     
  6. JosEPh_II

    JosEPh_II TBS WarLord

    Joined:
    Jun 20, 2007
    Messages:
    15,017
    Gender:
    Male
    Location:
    Western IL. cornfields
    Where would one find the Barbarian autobuildings? RegularCIV4Buildings? SpecialBuildings? ??? Or do they have a special xml file of their own?

    The game set up Options Barb World, Aggressive Barbs, and Raging Barbs maybe even barb Civ should all be using similar tags one would think, just with different Set values. But then I'm only guessing here.

    I know long time ago, when Barb World and Barb Civ were first introduced into RoM thru Rev that what they received a massive set of units when they founded a City.

    I guess I must start some serious digging into the xml files, cause I would have No clue for the Python or C++ files. Way out of my league with those! :( :sad:

    EDIT: Important This game is using No Traits at all.
     
    Last edited: May 6, 2019
  7. Anq

    Anq Chieftain

    Joined:
    Apr 14, 2019
    Messages:
    87
    Gender:
    Male
    Location:
    Anser quadrupedis quackahonkahonk (whaaaaat---)
    The standard system also deals with mangrove placement. And animal placement based on geographic locations. You've simply disabled them all. I have thought this was the official script because raxo2222 adjusted the world size based on your script.
     
  8. JosEPh_II

    JosEPh_II TBS WarLord

    Joined:
    Jun 20, 2007
    Messages:
    15,017
    Gender:
    Male
    Location:
    Western IL. cornfields
    @DH, T-Brd,

    In XML/UNITS/CIV4SpawnInfos this variable is used for almost all Unit spawns even Barbarian unit type spawns like Brute : <iMaxLocalDensity>6</iMaxLocalDensity> .

    Now I take it that this only deals with individual Tiles and probably Not for Main City tile. And that any tile can spawn up to 6 units but at what intervals? Every turn? Or until 6 spawned units of same type is on that particular tile?

    Should this variable be lowered for All Barb units? Changing it to 5 would seemingly lower the number of spawned units on a tile to 5 and reduce Barb units by 1/6 or 16.6667 %. Would this be helpful in the case of Barb Military unit overproduction? Of course every Barb Military Unit would need to be individually reduced to 5 on this tag.

    Also In A_New_Dawn_GlobalDefines the Barb spawn rate is already set at 50 vs 100 :
    <Define>
    <DefineName>BARBARIAN_SPAWN_MODIFIER</DefineName>
    <iDefineIntVal>50</iDefineIntVal>
    </Define>

    Should this define be reduced even more, to say 40?

    Or is this overproduction of Barb Units only specific to the Game Set up Options Of Barb World and Barb Civ?
     
  9. MattCA

    MattCA Chieftain

    Joined:
    Jan 25, 2019
    Messages:
    77
    Gender:
    Male
    are you looking to reduce the barbarian spawning or the number of units they build with their cities? or either?
     
  10. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    24,891
    Gender:
    Male
    Location:
    Las Vegas
    I can't say I'm sure about this... @Toffer90 told me at one point how they get their automatic culture buildings. Not sure where they are located in the xml.

    Not using traits at least it's clear what it's NOT coming from. Might be good to look at the barbarian trait though just to make sure it isn't going to make things even worse. It's not something I redefined in my set - it still uses the core.

    Yes. Spawning is distinct from what they train in a city, though part of the barb AI is sometimes to have their units find the nearest barbarian city or goody hut to gather at.

    I'm not sure it means a tile can spawn up to 6 so much as it's like a density in an area check which might be a bit more complex math to determine slowing down the rate as the density gets higher of those types in a given area (which is usually in code defined as a continent but might, iirc, have something to do with a certain amount of distance from the tile that's making the check.) Every tile makes a spawn check every round for all of its valid potential spawns. A higher number in the odds integer is a reduced chance as it's checking a chance of 1 in that number - which means that basically it's rolling a dice of that many sides every round for every tile that can spawn that type validly that round and hasn't already spawned something in that round yet and if that many hundreds of sides on that dice actually rolls a 1, then the spawn happens there. The density creates an adjustment to make that chance less likely by increasing that die's number of sides, making a 1 less likely to roll, if it finds other units of this spawning type within a certain range and will actually disqualify the roll entirely if there are too many units like it within range of that tile. Again - not sure about what the 'range' is defined as... I'd have to look at the code again to be sure.

    It could help to reduce spawns where barbs are already rather successful at populating.

    Not at all. It would have no effect on how much the city plugs out. That seems to be where we have an issue. Particularly when the barbs are producing cheap units.

    Well... think about games without Barbarian world, where cities aren't so early on. You should probably check the impression you get on those games and consider how that would make an impact there and see if you think it's still worth it. It might be. I don't think spawns are what are imbalancing barb numbers. I'm pretty sure that their cities are simply far more powerful than expected now that they are expanding their cultural reach and improving their tiles for production mostly. Since they pour that production into more production buildings and then into military units as much as possible, they are pretty much rigged to spam as many units as they can, as fast as possible, so they'll have to be slowed somehow now that it's working too well. For games that rely more on spawning or where the cities come into play later and can be more easily quelled, turning down spawning to help with this will probably not be terribly effective and will just make the game a bit less challenging in the early turns. Once the cities get rolling, I doubt the spawning is all that significant in comparison.

    There could well be a production modifier built into Raging Barbs... I seem to recall that there is. That might be something we need to control and I"m not sure if it's hardcoded or not. See if you can find a global that may relate somehow. As for those options, I'm not sure. Probably not Barb Civ... that might be made more likely to get more barbarian cities growing up into minor civs with this happening but I dont' think it makes them more productive. Barb World certainly makes the cities manifest earlier, like immediately, so you're giving them more time to get setup to crank out the units so there's that. But I don't know if there's a direct modifier built into that option. I kinda think it's the pervue of Raging Barbs for that. I KNOW it increases spawning rates but I think it also gives a major production bonus to barb unit training.
     
  11. JosEPh_II

    JosEPh_II TBS WarLord

    Joined:
    Jun 20, 2007
    Messages:
    15,017
    Gender:
    Male
    Location:
    Western IL. cornfields
    Mostly the number they can build from their cities. But the other aspect of spawn from a tile not a city will play a part in it too. But yes the sheer number of units built from a Barb city needs addressed 1st.
     
  12. Dancing Hoskuld

    Dancing Hoskuld Chieftain

    Joined:
    Jul 5, 2004
    Messages:
    22,919
    Gender:
    Male
    Location:
    Canberra, Australia
    The iMaxLocalDensity is not by plot but by group of plots or distance from where the unit is spawning. As I understand it, if a unit was going to spawn on a plot but there are to many other units of this type near that plot it wont spawn. I don't know what the radius is but I suspect it is map size related, being smaller the bigger the map.
     
  13. raxo2222

    raxo2222 Warlord

    Joined:
    Jun 10, 2011
    Messages:
    4,907
    Location:
    Poland
    @JosEPh_II Some stuff you can adjust is in Barbarian trait (that is is disabled in your no traits test) and culture building.
    TRAIT_BARBARIAN is in CIV4TraitInfos (Caveman2Cosmos\Assets\XML\Civilizations).

    BUILDING_CULTURE_NEANDERTHAL_NPC and BUILDING_CULTURE_BARBARIAN is in Cultures_CIV4BuildingInfos (Caveman2Cosmos\Assets\XML\Buildings)
    Food yield increment, commerce modifier and military production modifier can be removed now.

    @Thunderbrd do we even need barbarian trait?

    Code:
            <!-- BEGIN: SPECIAL_TRAIT (MINOR AND BARBARIAN) -->
            <TraitInfo>
                <Type>TRAIT_HUNTER_GATHERER</Type>
                <Description>TXT_KEY_TRAIT_HUNTER_GATHERER</Description>
                <ShortDescription>TXT_KEY_TRAIT_HUNTER_GATHERER_SHORT</ShortDescription>
                <Button>art/Buttons/Traits/TraitHunterGatherer.dds</Button>
                <PromotionLine>PROMOTIONLINE_HUNTER_GATHERER</PromotionLine>
                <bNegativeTrait>1</bNegativeTrait>
                <Flavors>
                    <Flavor>
                        <FlavorType>FLAVOR_GOLD</FlavorType>
                        <iFlavor>1</iFlavor>
                    </Flavor>
                    <Flavor>
                        <FlavorType>FLAVOR_GROWTH</FlavorType>
                        <iFlavor>-1</iFlavor>
                    </Flavor>
                    <Flavor>
                        <FlavorType>FLAVOR_CULTURE</FlavorType>
                        <iFlavor>4</iFlavor>
                    </Flavor>
                </Flavors>
                <iMaxAnarchy>-1</iMaxAnarchy>
                <iUpkeepModifier>10</iUpkeepModifier>
                <ExtraYieldThresholds>
                    <iExtraYieldThreshold>6</iExtraYieldThreshold>
                </ExtraYieldThresholds>
                <TradeYieldModifiers>
                    <iYield>-50</iYield>
                </TradeYieldModifiers>
                <CommerceModifiers>
                    <iCommerce>0</iCommerce>
                    <iCommerce>0</iCommerce>
                    <iCommerce>-20</iCommerce>
                </CommerceModifiers>
                <BuildingProductionModifierTypes>
                    <BuildingProductionModifierType>
                        <BuildingType>BUILDING_GRANARY</BuildingType>
                        <iBuildingProductionModifier>100</iBuildingProductionModifier>
                    </BuildingProductionModifierType>
                    <BuildingProductionModifierType>
                        <BuildingType>BUILDING_MODERN_GRANARY</BuildingType>
                        <iBuildingProductionModifier>-60</iBuildingProductionModifier>
                    </BuildingProductionModifierType>
                </BuildingProductionModifierTypes>
            </TraitInfo>
            <TraitInfo>
                <Type>TRAIT_BARBARIAN</Type>
                <Description>TXT_KEY_TRAIT_BARBARIAN</Description>
                <ShortDescription>TXT_KEY_TRAIT_BARBARIAN_SHORT</ShortDescription>
                <Button>art/Buttons/Traits/TraitBarbarian.dds</Button>
                <PromotionLine>PROMOTIONLINE_BARBARIAN</PromotionLine>
                <bNegativeTrait>0</bNegativeTrait>
                <bImpurePromotions>1</bImpurePromotions>
                <Flavors>
                    <Flavor>
                        <FlavorType>FLAVOR_GROWTH</FlavorType>
                        <iFlavor>-1</iFlavor>
                    </Flavor>
                    <Flavor>
                        <FlavorType>FLAVOR_GOLD</FlavorType>
                        <iFlavor>3</iFlavor>
                    </Flavor>
                    <Flavor>
                        <FlavorType>FLAVOR_MILITARY</FlavorType>
                        <iFlavor>4</iFlavor>
                    </Flavor>
                    <Flavor>
                        <FlavorType>FLAVOR_PRODUCTION</FlavorType>
                        <iFlavor>-3</iFlavor>
                    </Flavor>
                </Flavors>
                <iHealth>1</iHealth>
                <iHappiness>2</iHappiness>
                <iMaxAnarchy>-1</iMaxAnarchy>
                <iLevelExperienceModifier>25</iLevelExperienceModifier>
                <!-- Revolution Trait Effects Begin -->
                <bUpgradeAnywhere>1</bUpgradeAnywhere>
                <!-- Revolution Trait Effects End -->
                <CommerceChanges>
                    <iCommerce>0</iCommerce>
                    <iCommerce>0</iCommerce>
                    <iCommerce>1</iCommerce>
                    <iCommerce>1</iCommerce>
                </CommerceChanges>
                <BuildingProductionModifierTypes>
                    <BuildingProductionModifierType>
                        <BuildingType>BUILDING_CAVE_PAINTING</BuildingType>
                        <iBuildingProductionModifier>100</iBuildingProductionModifier>
                    </BuildingProductionModifierType>
                </BuildingProductionModifierTypes>
                <FreePromotionUnitCombatTypes>
                    <FreePromotionUnitCombatType>
                        <PromotionType>PROMOTION_AGGRESSIVE</PromotionType>
                        <UnitCombatTypes>
                            <UnitCombatType>UNITCOMBAT_MELEE</UnitCombatType>
                        </UnitCombatTypes>
                    </FreePromotionUnitCombatType>
                </FreePromotionUnitCombatTypes>
                <iWorkerSpeedModifier>75</iWorkerSpeedModifier>
                <iBaseFreeUnits>4</iBaseFreeUnits>
                <iFreeMilitaryUnitsPopulationPercent>35</iFreeMilitaryUnitsPopulationPercent>
                <iMilitaryProductionModifier>35</iMilitaryProductionModifier>
            </TraitInfo>
    It seems like barbarians are better off if positive traits is enabled.
    That is this trait can be turned off like any other traits.
     
  14. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    24,891
    Gender:
    Male
    Location:
    Las Vegas
    Well it looks like the worker speed modifier and military production modifier would be unnecessary, as well as the bonus to Cave Painting construction since I don't think they would bother to try to build it to begin with. The Commerce changes are unnecessary. The main thing here with the trait is the promotion which makes barbs a bit stronger. That's about it. I don't care if it gets removed or not but a different one for the various other NPCs might be interesting to explore as well at some point.
     
    raxo2222 likes this.
  15. overmind2000

    overmind2000 Chieftain

    Joined:
    May 15, 2019
    Messages:
    1
    Gender:
    Male
    @Dancing Hoskuld

    I brought this up on the C2C Discord and was told to post it here: Would it make more sense to have a Tamed Ground Sloth unit that can be built after constructing the Mapinguari Compound rather than rely on finding more Megatherium in the wild? Megatherium seem to be one of the rarest megafauna and it's a little frustrating to have to choose between completing the Myth/Story/Stories/Remains chain and getting Mapinguari units when there are so few of them. I really like C2C's system of building tamed versions of various animals based on what myths and enclosures you have and it would be cool to extend that to some of the other megafauna aside from the mammoths.
     
  16. Anq

    Anq Chieftain

    Joined:
    Apr 14, 2019
    Messages:
    87
    Gender:
    Male
    Location:
    Anser quadrupedis quackahonkahonk (whaaaaat---)
    I have a question,

    In the vanilla code and xml, <PrereqBuildingClass> has children <BuildingClassType> and <iNumBuildingNeeded>, and this is how "courthouse * N -> forbidden palace" works

    This tag C2C (or RoM) adds, <PrereqOrBuildingClass>, has children <BuildingClassType> and <bPrereqBuildingClass> (you all know it's redundant from two years ago:

    But the code to parse XML tells it to still read <BuildingClassType> and <iNumBuildingNeeded>? I search for bPrereqBuildingClass, but it's irrelevant in the source codes.
    Even if there's reason for the compound structure to stay, either for testing or to comply with the convention, this was never properly parsed.


    EDIT: Correction. What I looked at belongs to TechInfo code. I didn't realize it until I attempted at changing the code. The <PrereqOrBuildingClass> tag from TechInfo does not see any application.


    I'm trying to figure out a way to reorganize this structure and many other similar ones, though I've not yet known how delayed resolution works... I want this structure to look like:
    Code:
    <PrereqOrBuildingClasses>
        <BuildingClassType>BUILDINGCLASS_A</BuildingClassType>
        <BuildingClassType>BUILDINGCLASS_B</BuildingClassType>
        <BuildingClassType>BUILDINGCLASS_C</BuildingClassType>
    </PrereqOrBuildingClasses>
    That's to flatten out the structure. We can just reuse <element type="BuildingClassType" /> on the inside and the middle layer <ElementType name="PrereqOrBuildingClass"> is not needed anymore.
     
    Last edited: May 23, 2019
  17. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    24,891
    Gender:
    Male
    Location:
    Las Vegas
    The method in place now is an array and IS worth getting rid of for the memory savings ... bigtime. If you're wanting to do this, it would be a very helpful project indeed.

    There's a few other things to consider here but I think the main thing to know is that the data structures using delayed resolution are setup for vectors to go into use as the storage mechanism.

    I'm probably explaining what you already understand here so if this information isn't for you, it's for anyone who wants to understand this as well.

    The array method basically is storing a record of all buildingclasses for each instance of the game object, in this case a building type. It is then storing a corresponding boolean, so you get basically a data structure that has all buildingClass ID#s down one column and a second column with a 1 or 0 next to each of them. 2 columns by some 3000 buildings and you have some 6000 integer sized storages being consumed just in the mod load just for every single building in the game (so 6000 x however many bits that takes x 3000) so you can see how it eats up a lot of memory just to record which buildings are PrereqOrBuildingClasses in this manner.

    The alternative vector method probably has a bit of memory overhead to setup in comparison to a vector, BUT it only has to store in memory the list of buildingclass ID#s that are actually stated in that list.

    Surely, after some 10 buildings being defined, a vector is going to be a savings on RAM use at load. May not be terribly impactful when comparing to the memory being stored on every single unit in the game, but it can't hurt! I also suspect that the calls for information can be much faster when they aren't invoking a loop through every thousand buildings every time.

    So you're definitely in the right direction for helping with our memory and speed issues.

    There are some examples of the way to implement these kinds of vector storages in use on other tags. Sometimes you have to look for those examples in other object types, like perhaps units. But in this case, we have:
    Code:
    
        //Bool vector utilizing delayed resolution
        int getNumEnabledCivilizationTypes() const;
        EnabledCivilizations& getEnabledCivilizationType(int iIndex);
    As a good example right there inside CvBuildingInfos. Basically just copy everything about this tag for getting the tag setup. I would program it as a whole new tag from the beginning then once you have everything done in place you can start to pull out the previous tag implementation. Don't forget the XML in every single BuildingInfo file. Even the ones in the modules. You might be able to get some help from one of the XML modders on this.

    What I often do to get the coding setup in the BuildingInfo.cpp is to search for the storage tag, in this case: m_aEnabledCivilizationTypes

    So that means you'll need to give a new Bool vector utilizing delayed resolution set of lines for the new tag (under getEnabledCivilizationType):
    Code:
        int getNumPrereqORBuildingClassTypes() const;
        BuildingClass& getPrereqORBuildingClassType(int iIndex);
    To set this up further, you'll also have to go to structs and add under:
    Code:
    struct EnabledCivilizations
    { 
        CivilizationTypes eCivilization;
    };
    Code:
    struct BuildingClass
    { 
        BuildingClassTypes eBuildingClass;
    };
    @AIAndy might chuckle at me as it might have been possible to just put BuildingClassTypes& getOurVariable but since I'm not sure, I just build the struct.

    From there, just search through the entire solution for all instances of m_aEnabledCivilizationTypes and add lines and functions analogous to where those calls are found and you should be able to get the infos side of things done properly.

    Then it would be a matter of addressing those functions throughout the code where they should be placed. Following how getPrereqORBuildingClassType(int iIndex) is called throughout the code will give you a concept of how to loop for the information using getNumPrereqORBuildingClassTypes() as the foundation of the loop so as to draw the data from this tag as needed. Keep some notes in a notepad or something that shows you how the syntax is used for that. If you have any questions about that, just ask and I'm very happy to help. Took me a while to sort this out how to use a vector in the code since most code examples from Vanilla are all using these arrays.

    Meanwhile, following the uses in the code for PrereqOrBuildingClasses as it was, will give you the locations you'll need to make sure you address.


    Now, there are a few other things to consider here.
    I was dramatically considering a whole new tagset for building prereqs quite recently. It would use nested tags to offer more data where needed, basically enabling further tags to be absorbed underneath this one as sub-information that could be drawn upon. As you pointed out, <iNumBuildingNeeded> is nested under the primary AND prereq tag in use in the code, <PrereqBuildingClass>.

    With the vector setup, all you'd need to do is check out another vector that isn't just a single Boolean call type - which is really much the same thing but with only one variable in the tag's struct. There are some examples in the code on this as well. One of the best is in the units for poisoning, which hasn't yet been fully put to use but is a good example of building nested tags into a structure based vector.

    I wanted to include the tag that states a building is an extension of a prerequisite building and should thus be destroyed if it is also destroyed... among others. A plan had formed. I'll look for the PM stream on that and see if I can't invite you into that discussion. If you'd be willing to work on all this, it would be invaluable!
     
    Anq likes this.
  18. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    24,891
    Gender:
    Male
    Location:
    Las Vegas
    From that PM (which has too many people in the discussion to add another and I don't see how to remove one so I can add another)


    We've been having a discussion in another group in pms here and we came up with the conclusion that long before working on this, it should be well thought out and a few more folks would be good to get in on the conversation. Some of you may or may not be feeling like you'd want to comment and some may never see this discussion but the respect for your outlook is such that we wanted to bring you in on this too. Others I might hope can comment directly as it will affect you greatly and I want to make sure you understand the plan and feel you can work with it moving forward.

    In essence, this is about BuildingPrerequisites on Building objects. There's a great deal of inefficiency there and some limits we'd like to overcome and ways we'd like to streamline some things. AKA, we are considering reprogramming numerous prereq tags into one simpler, nested structure based vector tag with lots of options than having so many differing tags, particularly costly array tags, as we have now. We're also looking to gradually eliminate the use of BuildingClass for the sake of processing speed efficiency and perhaps eventually get rid of it entirely for additional memory benefits.

    I'm not going to quote everything that's been said in the other thread, just summarize the plan as we've come up with it so far:

    Code:
    <BuildingPrerequisites>
       <BuildingPrerequisite>
           <BuildingType>BUILDING_X</BuildingType>
           <iCaseID>0</iCaseID> (See the summary of how iCaseID and iORGroupID work to enable any combination of And/Or prerequisites.)
           <iORGroupID>0</iORGroupID>
           <bExtensionOf>1</bExtensionOf> (If this prerequisite slot is ever lost for this building, then the building is destroyed.  If this prerequisite slot is ever disabled for this building then the building is disabled.  If this prerequisite slot is ever obsoleted - without having been replaced by a building in the prerequisite building's replacement chain, then this building is also obsoleted.)
           <iAmountNeededInCiv>0</iAmountNeededInCiv> (We don't assume that this prerequisite is talking about a local prerequisite necessarily.  It may be instead referring to an overall need for this many buildings to be constructed anywhere in the civilization.)
           <iAmountNeededAnywhere>0</iAmountNeededAnywhere> (This building prereq sets the requirement of the count of the amount of this building in existence anywhere in any cities game-wide, not just this civilization)
           <bAmountNeededElsewhereIgnoredForFirst><bAmountNeededElsewhereIgnoredForFirst> (Instructs the building to ignore the iAmountNeededInCiv and/or iAmountNeededAnywhere tags when constructing the first building of its kind in your empire.)
           <bAmountNeededAppliesPlanetwide>0</bAmountNeededAppliesPlanetwide> (Changes the iAmountNeededInCiv and/or iAmountNeededAnywhere tags from meaning game-wide to all cities on the same maptype tile - perhaps later upgraded to being map ID specific.)
           <bAmountNeededAppliesContinental>0</bAmountNeededAppliesContinental>  (Changes the iAmountNeededInCiv and/or iAmountNeededAnywhere tags from meaning game-wide to all cities on the same continent.  Can work in tangent with bAmountNeededAnywhereAppliesPlanetwide to also mean on the same continent AND same planet type tile, though shouldn't need to.)
           <bNeededInCity>1</bNeededInCity> (This is what establishes this as a local prerequisite)
       </BuildingPrerequisite>
    </BuildingPrerequisites>

    iCaseID and iORGroupID

    Each case is a unique way to access the building, a doorway.

    Each iORGroupID is required to be met in order to meet the needs of that group in that case to fulfill the prerequisite.

    So
    ( (Ci1 or Ci2, or Ci3) and Cu ) OR ( (Ci1 or Ci2, or Ci3) and ( No1 or No2 ) )
    <BuildingPrereq>
    <Building>Ci1</building>
    <iCaseID>1</iCaseID> no need to confuse ourselves with starting with 0
    <iORGroupID>1</iORGroupID>no need to confuse ourselves with starting with </BuildingPrereq>
    <BuildingPrereq>
    <Building>Ci2</building>
    <iCaseID>1</iCaseID>
    <iORGroupID>1</iORGroupID>
    </BuildingPrereq>
    <BuildingPrereq>
    <Building>Ci3</building>
    <iCaseID>1</iCaseID>
    <iORGroupID>1</iORGroupID>
    </BuildingPrereq>
    <BuildingPrereq>
    <Building>Cu</building>
    <iCaseID>1</iCaseID>
    <iORGroupID>2</iORGroupID>
    </BuildingPrereq>
    <then Case 2...>
    <BuildingPrereq>
    <Building>Ci1</building>
    <iCaseID>2</iCaseID>
    <iORGroupID>1</iORGroupID>
    </BuildingPrereq>
    <BuildingPrereq>
    <Building>Ci2</building>
    <iCaseID>2</iCaseID>
    <iORGroupID>1</iORGroupID>
    </BuildingPrereq>
    <BuildingPrereq>
    <Building>Ci3</building>
    <iCaseID>2</iCaseID>
    <iORGroupID>1</iORGroupID>
    </BuildingPrereq>
    <BuildingPrereq>
    <Building>No1</building>
    <iCaseID>2</iCaseID>
    <iORGroupID>2</iORGroupID>
    </BuildingPrereq>
    <BuildingPrereq>
    <Building>No2</building>
    <iCaseID>2</iCaseID>
    <iORGroupID>2</iORGroupID>
    </BuildingPrereq>


    Quoting from my initial post:

    Addressing the origin of this project:
    You asked me to help enforce that the ExtendsBuildingClass tag also acts as a prerequisite tag. Such a request opens a very large can of worms.

    Because at the same time, I'm seeing that we have a LOT of tags that could be combined into one more complex but far more data efficient tag for handling prereqs, including the PrereqBuildingClass which confusingly labeled is the tag that requires so many of a given type of that building exists throughout the civilization, be it in this city or not.

    There's BuildingClassNeeded, PrereqOrBuildingClass, and the worst part is all of these tags refer to CLASS which would, as Alberts2 noted, be very beneficial to get away from and eventually obsolete the use of given how much memory is being committed to this data structure that could be more efficient if there was just 'Building Types'.

    So since that's also a direction we want to go, it seems silly to do the simple thing (or so it seems) which would be to restructure the existing PrereqOrBuildingClass and/or BuildingClassNeeded (basically or tag for PrereqANDBuildingClass) so that they have a nested boolean for the denotation of ExtendsBuildlngClass (which really means: Is an extension OF BuildingClass).

    And it seems equally as silly to make Extends also count as a second way to establish a Building Prereq (which type??? OR/AND - and how would that then plug in to the text displays seamlessly?) as that can make for easily overlooked requirements on reviewing the xml that can lead to mistakes by modders and can lead to some bugs in the code. It also tacks onto the back of a hopefully soon to be obsoleted method of using building classes and would thus be a step we'd have to undo all over again, making the effort to do this a complete waste of time.

    While I'm at it, I'm going to make a cached system of determining that when a building is replaced, the replacement immediately counts for all these evaluations in place of the building it replaced.

    This should allow us to REALLY streamline things.

    Before I commit to working on this, I want us to consider anything I might be overlooking here or other possibilities for further consolidation.

    At first, I'm not going to immediately REPLACE the tags we have, but rather build this in as an additional optional set of condition definitions, as far as I can anyhow. Once established, we can work on filling out the xml on our buildings using this tag. As we go there we can comment out the old tags to ensure that bugs are not forthcoming. THEN, once all our XML is updated, we can eliminate all the old tags and data and the amount of savings in memory that will ensue should be huge.

    I believe this will also mean a lot of work on the python end to convert any direct calls to the original tags. I won't be much help with that except to work with y'all to report it properly.

    As long as we're all aware of the downsides and potential payoff and we're all ready to come together to make this improvement, then it should be time now to do so.

    We might be able to get some new team members from active commenters like Rmi to help us with the XML here.

    Anyhow, thoughts?




    Then we went on to say the following:
    It's worth expanding these by the way!

    Literally all of this conversation is absolute gold. If you can follow it.
     
    TaylorItaly and Anq like this.
  19. AIAndy

    AIAndy Chieftain

    Joined:
    Jun 8, 2011
    Messages:
    3,392
    Cross references between the XML objects are done by name (e.g. BUILDINGCLASS_A). But while the game is running, we want to avoid expensive name lookups, so internally those cross references are stored by an integer id that refers to where in the storage array for that specific type of object the referenced object can be found.
    The XML files are loaded in a specific order. If you want to refer to an XML object that is earlier in the loading order, you can resolve its name right away. But if it is in the same file or one that is loaded later, the name might not be known yet, so the id can't be resolved at this point. That is what I made the delayed resolution for. You register the name and a pointer to the place in memory where you want the id written later. After all XML files have been loaded, these names are all resolved then and written at the right position.
    The main requirement for this is that if the place in memory where the id is located changes or is deleted, the delayed resolution registration has to be updated. That is why vectors of such ids are first sized correctly before any delayed resolution registration is done as resizing vectors might cause a reallocation and moving of the vector content.
     
  20. Thunderbrd

    Thunderbrd C2C War Dog

    Joined:
    Jan 2, 2010
    Messages:
    24,891
    Gender:
    Male
    Location:
    Las Vegas
    I don't think the team can thank you enough for inventing this process... it's been absolutely invaluable and so few realize it. So I'll thank you for them. I don't think I could've thought this through to this extent and it's taught me a lot I'm still trying to absorb just to have it there to study.
     
    KaTiON_PT and MattCA like this.

Share This Page