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

Cleaned Up Formations.XML file

Discussion in 'Civ4 - Modding Tutorials & Reference' started by n003lb, Nov 27, 2005.

  1. n003lb

    n003lb Chieftain

    Joined:
    Oct 24, 2005
    Messages:
    153
    Location:
    Air Capitol - Wichita, KS, USA
    Well, I had a look at the "CIV4FormationInfos.xml" file and, whoa, what a garbeled up looking mess. I just spent the last 4 hours going through and cleaning it up with notepad, spacing it out so it's clearer to read. Makes it a lot easier to find a specific unit or bit of information in my opinion. I haven't had a chance to truly playtest it yet, so I don't know if it will cause any problems or not.

    I know the game gives no errors at startup or when starting a new game. After I first did this, I had about a dozen errors to fix, all of which appeared when I tried to start a new game. Mostly, the errors were spots where I put whitespace between brackets, which XML apparently doesn't like. After I fixed those, it seems to work just fine.

    I am providing it here as an aid to anyone else that feels completly overwhelmed by the clutter of this file originally. I am not an XML programmer, so I don't really know what anything in this file does. I just spaced it so that it is clearer and each formation is seperated out.

    I have changed none of the original code, just cleaned it up to make it easier to read. I don't hold any rights to it, but I wouldn't think there would be any problems with me uploading it.

    As with anything you download, use it at your own risk. I am not responsible for any damage done to your computer or your game as a result of using this file.

    DON'T MODIFY YOUR ORIGINAL GAME FILES!

    Put this file in the "My Documents\My Games\Sid Meier's Civilization 4\CustomAssets\xml\units" folder for now (use the Shortcut provided in the Civ IV main folder), until you know it will not adversly affect your game. Make sure to clear your cache after installing this file. Otherwise, Civ will not load it and you won't know if it is causing a problem or not. If you do wish to replace your original file with this one, BACKUP THE OLD FILE FIRST!

    Anyway, I hope someone finds it useful. If anyone has serious problems with it, there ain't much I can do to help. If a lot of people have trouble, please post here and let me know. It may be a fluke that it works on my system. If that's the case, I'll take it offline so as not to cause problems for anyone else.


    BTW To Moderators: I don't really know where to put this. If it is not in the right place, please move it. Thanks.

    [EDIT July 5, 2006] Download removed because of superceding files below. They are better than what I did.
     
  2. Fireb

    Fireb Chieftain

    Joined:
    Nov 20, 2005
    Messages:
    40
    I had started to do the same thing myself, as I wasn't happy about using the 'replace all' function blindly. I gave up after about 30 mins though. Good work!
     
  3. KingTux

    KingTux Ruler of the Free World

    Joined:
    May 30, 2003
    Messages:
    253
    Location:
    somewhere REALLY out there
    Yeah, I thought about doing this at one point or another, but I never was thinking about doing it by hand. I was thinking more along the lines of just making a simple script and having it do all the hard work for me. The only problem with that is that I never put any time towards doing it because I've been busy with other stuff. ;)

    So, it's nice to see that someone decided to do it the insane way. Now, I don't think that I'll even bother doing it my way (besides, I don't think that I would have scrounged up the time for this as it isn't something high on my own priorities). Just thought I'd let you know that it could have been done with a lot less effort.
     
  4. n003lb

    n003lb Chieftain

    Joined:
    Oct 24, 2005
    Messages:
    153
    Location:
    Air Capitol - Wichita, KS, USA
    Well, I ain't a programmer, and it really didn't take that long. Yes I spent 4 hours on it, but that was intermixed with a few other things I had going at the time. Time spent on this was really only maybe an hour or so.

    Glad it's helpfull
     
  5. The Great Apple

    The Great Apple Big Cheese

    Joined:
    Mar 24, 2002
    Messages:
    3,361
    Location:
    Oxford, England
    I've cleaned it up a bit further. Now it looks like a Firaxis standard xml file:
     

    Attached Files:

  6. anhu

    anhu Chieftain

    Joined:
    Nov 21, 2005
    Messages:
    21
    Thanks! Now the lines are no longer jumbled up into intimidating blocks of words and numbers. The nice formatting will go far in possible edits later on (maybe when more patches come). :goodjob:
     
  7. Déja

    Déja Beyond the Mod

    Joined:
    Dec 19, 2005
    Messages:
    353
    In case anyone is curious, or they update the formationinfo file again without fixing the formatting, if you're using any of the Microsoft Visual Studio Express programs (free download, they all have excellent XML editors (the same one, really), and they're useful for other things), all you need to do is hit:

    Edit > Format Document

    and lo, he beheld that it was clean
     
  8. Agent 009

    Agent 009 Civ 4 Addict

    Joined:
    Mar 28, 2006
    Messages:
    346
    Location:
    In a virtual Civ 4 Environment.
    well this is most certainly a great job. :goodjob:

    Kudos to you guys. I really needed to edit this file myself to include the new units in my mod. This will make the job go alot quicker. :D
     
  9. woodelf

    woodelf Bard

    Joined:
    Jun 12, 2003
    Messages:
    15,036
    Location:
    Gallery
    Bugger, I wish I had noticed this before......
     
  10. primordial stew

    primordial stew Chieftain

    Joined:
    Sep 1, 2005
    Messages:
    1,219
    Location:
    a puddle
    I did this in vim so I could read the TAM version. It only takes a few commands:
    %s/></>\r</g <-- put dos newline between each ><
    %s/^<UnitType/^I^I^I<UnitType/ <-- indent to allign.. (^I = hit tab)
     
  11. hr_oskar

    hr_oskar Deity

    Joined:
    Jun 21, 2002
    Messages:
    598
    Location:
    Iceland
    Good job guys :goodjob:! I couldn't believe the formatting of that file when I first saw it, why did Firaxis release it that way and never change it through what, 4 patches?
     
  12. Agent 009

    Agent 009 Civ 4 Addict

    Joined:
    Mar 28, 2006
    Messages:
    346
    Location:
    In a virtual Civ 4 Environment.
    good question. :p
     

Share This Page