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

Work with XML

Discussion in 'Orbis Modmod' started by Zeleniy, Sep 11, 2011.

  1. Zeleniy

    Zeleniy Chieftain

    Joined:
    Jul 16, 2011
    Messages:
    16
    Location:
    Krasnoyarsk, Siberia
    Greetings!
    First of all I want to thanks author about this incredible mod!
    Now question: In xml file from Civ4, node consists of all posible subnodes. Here is an example (CIV4ImprovementInfos.xml):
    Spoiler :
    <ImprovementInfo>
    <Type>IMPROVEMENT_LAND_WORKED</Type>
    <Description>TXT_KEY_IMPROVEMENT_LAND_WORKED</Description>
    <Civilopedia>TXT_KEY_IMPROVEMENT_LAND_WORKED_PEDIA</Civilopedia>
    <ArtDefineTag>ART_DEF_IMPROVEMENT_LAND_WORKED</ArtDefineTag>
    <bActsAsCity>0</bActsAsCity>
    <bHillsMakesValid>0</bHillsMakesValid>
    <bFreshWaterMakesValid>0</bFreshWaterMakesValid>
    <bRiverSideMakesValid>0</bRiverSideMakesValid>
    <bNoFreshWater>0</bNoFreshWater>
    <bRequiresFlatlands>0</bRequiresFlatlands>
    <bRequiresRiverSide>0</bRequiresRiverSide>
    <bRequiresIrrigation>0</bRequiresIrrigation>
    <bCarriesIrrigation>0</bCarriesIrrigation>
    <bRequiresFeature>0</bRequiresFeature>
    <bWater>0</bWater>
    <bGoody>0</bGoody>
    <bPermanent>0</bPermanent>
    <iAdvancedStartCost>-1</iAdvancedStartCost>
    <iAdvancedStartCostIncrease>0</iAdvancedStartCostIncrease>
    <iTilesPerGoody>0</iTilesPerGoody>
    <iGoodyRange>0</iGoodyRange>
    <iFeatureGrowth>0</iFeatureGrowth>
    <iUpgradeTime>0</iUpgradeTime>
    <iAirBombDefense>-1</iAirBombDefense>
    <iDefenseModifier>0</iDefenseModifier>
    <iHappiness>0</iHappiness>
    <iPillageGold>0</iPillageGold>
    <bOutsideBorders>0</bOutsideBorders>
    <TerrainMakesValids/>
    <FeatureMakesValids/>
    <ImprovementPillage/>
    <ImprovementUpgrade/>
    <TechYieldChanges/>
    <RouteYieldChanges/>
    <WorldSoundscapeAudioScript/>
    <bGraphicalOnly>1</bGraphicalOnly>
    </ImprovementInfo>
    Much of them have default values and i think better not to write a lines that rubbish a code.
    In Orbis's xml files, rubbish lines not used, so I tried to clear files in my mode like this too:
    Spoiler :

    <ImprovementInfo> <Type>IMPROVEMENT_LAND_WORKED</Type>
    <Description>TXT_KEY_IMPROVEMENT_LAND_WORKED</Description>
    <Civilopedia>TXT_KEY_IMPROVEMENT_LAND_WORKED_PEDIA</Civilopedia>
    <ArtDefineTag>ART_DEF_IMPROVEMENT_LAND_WORKED</ArtDefineTag>
    <bGraphicalOnly>1</bGraphicalOnly>
    <iAdvancedStartCost>-1</iAdvancedStartCost>
    </ImprovementInfo>
    , and get errors when start Civ. What should I do to fix a problem?
     
  2. arcticnightwolf

    arcticnightwolf Emperor

    Joined:
    Jun 8, 2008
    Messages:
    1,301
    Location:
    Prague, Czech Republic
    what error exactly ?
    ( and i think that you shouldn't use two different tags on same line )
     
  3. Zeleniy

    Zeleniy Chieftain

    Joined:
    Jul 16, 2011
    Messages:
    16
    Location:
    Krasnoyarsk, Siberia
    It's not an error. I just want to improve my xml code. I want to delete tags with default values. Look: parameter bActsAsCity have '1' as value only at fortifications, other improvements have default value ('0'). In Orbis, if improvement have parameter with def. value, it's not used at code. I want to do such sings at my xml files. But I couldn't find where dll sources was changed. Could you help me?:please:
     
  4. arcticnightwolf

    arcticnightwolf Emperor

    Joined:
    Jun 8, 2008
    Messages:
    1,301
    Location:
    Prague, Czech Republic
    emm ... uh ... ok ...
    uh ... errr ... i'm not sure if i understand it right ...
    if you omit a non-mandatory parameter (which I believe are all except the "Type") in xml, the property should automatically have default value
    default values are defined in CvInfos.cpp file in function CvImprovementInfo::CvImprovementInfo():
     
  5. Zeleniy

    Zeleniy Chieftain

    Joined:
    Jul 16, 2011
    Messages:
    16
    Location:
    Krasnoyarsk, Siberia
    I delete non-mandatory parameter and catch an error. Orbis work fine without parameters having default values. Other mods such FFH2 use xml files with full stack of parameters. I want do xml files in my mod like in Orbis
     
  6. Valkrionn

    Valkrionn The Hamster King

    Joined:
    May 23, 2008
    Messages:
    14,450
    Location:
    Crestview FL
    There are two ways to do this. The first way would be to add " minOccurs="0" " to each tag definition in the schema.

    The far better way is to add "order="many" " to the section definitions. Faster, and even better, allows you to list tags in any order you wish, above and beyond simply not having to list them.


    As an example...

    Before: <ElementType name="PromotionInfo" content="eltOnly">

    After: <ElementType name="PromotionInfo" content="eltOnly" order="many">
     
  7. Zeleniy

    Zeleniy Chieftain

    Joined:
    Jul 16, 2011
    Messages:
    16
    Location:
    Krasnoyarsk, Siberia
    Ho-ho-ho! It works! :beer: Could you hint where I can get tutorial about xml Schema's?
    P.S. In Orbis schema's they used syntax
    <ElementType name="PromotionInfo" content="eltOnly">
    <ElementType name="ImprovementInfo" content="eltOnly">
    It's strange..:)
     
  8. Valkrionn

    Valkrionn The Hamster King

    Joined:
    May 23, 2008
    Messages:
    14,450
    Location:
    Crestview FL
    Yeah, Orbis used the first variant I mentioned, which both takes longer to set up and is less versatile (tags still have to be in a set order, you just don't have to use them). The second one is better. ;)

    I don't know of any real guides though.
     
  9. Zeleniy

    Zeleniy Chieftain

    Joined:
    Jul 16, 2011
    Messages:
    16
    Location:
    Krasnoyarsk, Siberia

Share This Page