Announcement

Collapse
No announcement yet.

how are maps saved?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • how are maps saved?

    The title says it all,is there anyone out here who knows how civ II(2.42) maps are saved?
    Let me explain what I mean:
    In my own mapeditor I save maps as binaries and the information is stored like this:
    First line: map_x,map_y dimensions,kind of map(round(1) or flat(0))
    rest:for each tile an 8-bit number(bit1=huts,bit2&3=special,bit4=river,bit5... 8=number for terraintype)and the tiles are stored left to right,top to bottom
    end.

    I hope there is someone who can help with this problem.
    (if so I will be supplying a new mapeditor that builds random-maps that give continents/islands when asked for,it could be a solution for generated worlds )

    Shade
    ex-president of Apolytonia former King of the Apolytonian Imperium
    "I have not failed. I've just found 10,000 ways that won't work." --Thomas Alva Edison (1847-1931)
    shameless plug to my site:home of Civ:Imperia(WIP)

  • #2
    Originally posted by Gothmog

    MAP INFORMATION:

    The map header is at a fixed location depending on file format.
    Offset 3586 in FW and later
    Offset 3478 in CIC and earlier

    The map header is 14 bytes long
    ~ Map X dimension : integer (2 bytes).
    ~ Map Y dimension : integer (2 bytes). A 50 by 80 map will show up as 100 by 80 here.
    ~ Map Area: integer (2 bytes) or X times Y divided by 2.
    ~ Flat Earth Flag: integer (2 bytes). 1 = flat, 0 = round.
    ~ Map Seed: integer (2 bytes). I haven’t fooled around with this yet to see if it might change the resource pattern in an active game.
    ~ Locator Map X dimension : integer (2 bytes): equals ‘Map X’ divided by 4 rounded up.
    ~ Locator Map Y dimension : integer (2 bytes): equals ‘Map Y’ divided by 4 rounded up. The locator map is the small map in the corner.

    THE MAP BLOCKS:
    These begin immediately after the header.
    ~ Block 1 contains terrain improvement data, such as irrigation. This block is 7 times the ‘Map Area’ bytes long.
    ~ Block 2 Contains the basic terrain type data. This block is 6 times the ‘Map Area’ bytes long.
    ~ Block 3 is the locator map. It's stored in 2 pieces, each piece being ‘locator map x’ times ‘locator map y’ bytes long.
    ~ Note: Viewing the save file in graphical mode in the hex editor is what allowed me to figure out what these map blocks lengths were. When I oriented the hex editor to start viewing at the beginning of map block 3 and made the width of the display the same as the ‘locator map X dimension’, I could see two little maps! So when you’re looking around a save file, you might want try graphical mode to see the big picture.
    I strongly suggest that you read Hex Editing by Allard Höfelt

    Comment


    • #3
      thank you very much this is just what I needed.

      shade
      ex-president of Apolytonia former King of the Apolytonian Imperium
      "I have not failed. I've just found 10,000 ways that won't work." --Thomas Alva Edison (1847-1931)
      shameless plug to my site:home of Civ:Imperia(WIP)

      Comment


      • #4
        thx, it gives the same info as the link keenan provided
        (something both forget to mention is that in the map the 4th integer(i think) the one that holds width/4 this is the width you use in the first integer(ie:width*2))(this crashed my computer 3 times before i figured it out)

        btw those .mp files are a nightmare(try opening with word ,close,save changes(although you didn't do a thing) and voila your file just increased 25% in size and became worthless)
        as you can see I had my fun

        shade
        ex-president of Apolytonia former King of the Apolytonian Imperium
        "I have not failed. I've just found 10,000 ways that won't work." --Thomas Alva Edison (1847-1931)
        shameless plug to my site:home of Civ:Imperia(WIP)

        Comment


        • #5
          For maps you´d better have a look at some more recent info on this @ http://gene.wins.uva.nl/~jvermeir/savmaps.htm
          It contains info about the encoding of maps in both map files and savegames.
          Civilization II: maps, guides, links, scenarios, patches and utilities (+ Civ2Tech and CivEngineer)

          Comment


          • #6
            thx, it gives the same info as the link keenan provided
            Well, most of it is the same, of course. I believe I made a few additions to the explanation of the encoding in savegames, though. Nothing short of Allard´s doc and William´s reference to it, of course.

            Originally posted by shade
            btw those .mp files are a nightmare(try opening with word ,close,save changes(although you didn't do a thing) and voila your file just increased 25% in size and became worthless)
            as you can see I had my fun
            That´s because there are a lot of appearances of the hex code 0A, which is the code for either a line-feed or a carriage return. In Windows a return this is encoded with a combination of both 0D 0A (or was it the other way around?), so when Word opens the file, it finds all the invalid occurences of returns, and replaces them by the above mentioned combination.
            But you knew this, right? Since you appear to be a programmer, or so I hope if you´re creating a game! .
            But why use Word at all on binaries, you surely have some hex-editor?

            I´m rather puzzled why your post seems to be posted half an hour before mine though. Not only that, it couldn´t even post for a while, always getting the you-can-only-post-once-every-30-seconds message.
            Civilization II: maps, guides, links, scenarios, patches and utilities (+ Civ2Tech and CivEngineer)

            Comment


            • #7
              Mercator: I thought it would be something like that.
              btw I 'm no real programmer in the sence I did study for it.It's just a hobby of mine.Yes, I am trying(and i really mean trying) to make my own Civ-game.(You can read all about it on my webpage)
              Hex-editor
              no don't have one(and don't need one for the moment)

              Grtz Shade
              ex-president of Apolytonia former King of the Apolytonian Imperium
              "I have not failed. I've just found 10,000 ways that won't work." --Thomas Alva Edison (1847-1931)
              shameless plug to my site:home of Civ:Imperia(WIP)

              Comment


              • #8
                Well, good luck with creating that game
                Civilization II: maps, guides, links, scenarios, patches and utilities (+ Civ2Tech and CivEngineer)

                Comment

                Working...
                X