Announcement

Collapse
No announcement yet.

Civilization III SAV file format

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

  • Civilization III SAV file format

    Hey Savegame-Editor-Programmers!

    I would like to have all available infos or sourcecode about accessing and manipulating the SAV-files, please.

  • #2
    What would you use it for?

    The reason why I haven't given anything out, other then to other programmers, is that there are competitive games, and the fact that most of what I have are really hard to understand.
    Creator of the Civ3MultiTool

    Comment


    • #3
      I want to know, if it´s possible to program a kind of email-multiplayer: Player1 saves the game, sends it to a friend (player2), player2 alters the savegame (switching the human-controlled civ), loads the savegame, makes the turn, saves the game and so on...

      Comment


      • #4
        Originally posted by hot-bandito
        I want to know, if it´s possible to program a kind of email-multiplayer: Player1 saves the game, sends it to a friend (player2), player2 alters the savegame (switching the human-controlled civ), loads the savegame, makes the turn, saves the game and so on...
        This might get implemented in a future patch by Firaxis, a feature called PBEM and already in use in Alpha Centauri and Call To Power.

        Comment


        • #5
          Nothing of want I know could be used for this. (I don't know where it stores what civ is human controlled)
          Creator of the Civ3MultiTool

          Comment


          • #6
            Originally posted by Gramphos
            What would you use it for?

            The reason why I haven't given anything out, other then to other programmers, is that there are competitive games, and the fact that most of what I have are really hard to understand.
            If it´s written in VB, I will understand. If it´s written in C, it will take some time...

            Comment


            • #7
              It is reasonable to release the format of the file because then it is useful for any programming language: VB, C, C++, asm, Java, Pascal, Haskell, etc. Rather than wade through someone else's source, the format lays it all out and shows what we know and don't know.

              Release of source is always at the descretion of the author. Having said that I think cooperative enterprises like civ3 prosper more from opensource style arrangements.
              Last edited by Merp; December 17, 2001, 20:03.
              Ut sementem feceris ita metes.
              ~ As you sow so will you reap.
              ----Cicero

              Comment


              • #8
                Well, but I don't know very mush about the format, and it is mostly the source code that makes the job. If I ever get an understandable description of the format I might publish it. As far as source code I'm more restrictive, not that this is anything to protect, but there might be other code that I don't want to get out. And if something doesn't work properly I don't want to tell everyone what changes to make.

                So, you have to wait until I know more about the format myself.
                Creator of the Civ3MultiTool

                Comment


                • #9
                  havent done alot of work into this but...

                  heres what ive got

                  In the file theres a string TILE that marks the beginning of each one

                  then a long int of 28(havent seen this vary at all)

                  then another long int which I do not know what it means

                  The next long int is the resource one
                  0-21 means the resources and ff ff ff ff means no resource
                  (thats all the resources 0-7 strategic, 8-15 luxury,16-21 bonus)

                  then 2 more long ints that i dont know about

                  then the terrain and enhancement controllers long int
                  The first one is a bitwise operator with each of the bits meaning
                  road RR Mine irrigation fort goodie-hut pollution camp
                  or lemme try out the other way of writing it i saw
                  first byte 0 0 0 0 0 0 0 0
                  road 1 0 0 0 0 0 0 0
                  RailRoad 0 1 0 0 0 0 0 0
                  Mine 0 0 1 0 0 0 0 0
                  Irrigation 0 0 0 1 0 0 0 0
                  Fort 0 0 0 0 1 0 0 0
                  Goodie-Hut 0 0 0 0 0 1 0 0
                  Pollution 0 0 0 0 0 0 1 0
                  Barbarian Camp 0 0 0 0 0 0 0 1

                  The second and third bytes arent bitwise as far as i can tell, they control terrain
                  2nd byte 3rd byte value
                  Desert
                  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

                  Plains
                  1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 17 0
                  Grassland
                  0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 34 0
                  Grassland_Bonus
                  0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 0 34 1
                  Flood PLains
                  0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 64 0
                  Hills
                  0 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 82 0
                  Mountains
                  0 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 98 0
                  Forest_Grassland
                  0 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 114 0
                  Jungle_Grassland
                  0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 130 0
                  Coast
                  1 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 153 0
                  Snow-Tipped Mountains
                  0 1 0 0 0 1 1 0 0 0 0 0 1 0 0 0 98 16
                  Pine Forests_Grassland
                  0 0 1 0 1 1 1 0 0 0 0 0 0 1 0 0 114 32
                  Ocean
                  1 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 187 0
                  Forest_Plains
                  1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 97 0

                  I dont know about the forest plains one, im just assuming thats what it is, also i havent checked what sea squares are yet.
                  I also dont know what the 4th byte here means.

                  Also I understand that the tiles are marked in this particular way:
                  say you have a 4x4 map, heres the order in the file the tiles would appear the the isometeric nature of the map makes this alittle difficult to understand at first.

                  1 2 3 4
                  5 6 7 8
                  9 10 11 12
                  13 14 15 16

                  Also tiles dont contain unit info, thats stored later under strings marked unit

                  Comment


                  • #10
                    doh cant edit it

                    sorry about the spacing

                    Comment


                    • #11
                      Yes, that is the map format, the easiest thing in the SAVs. The first part of it is almost the same as the one in the BIC.

                      However there is a few things that is in another way then you stated.:
                      that first long int is the remaining length of the section.
                      After that comes one byte of riverinfo. (I don't know exactly how it works yet)
                      Then one byte with the ingame id of the civ that has that tile in its border (-1 = NO CIV)
                      the two next bytes are unknown for me.

                      then, as you said the Resource# and 2 unknown long values.

                      For the terrain it is as you said first a bitwise byte of overlays.
                      After that is however two nibbles with the terraininfo. The first nibble is the actual terrain, and the second nibble the base terrain (used with mountains and forests). After that there is a short int that is bitwise for the bonuses. I see the BIC-format for more info on what the meaning of the bits are.
                      Then there are an unknown short (-1 = nothing, 75 = barbarian camp), an long, and then a short with the continent ID
                      Creator of the Civ3MultiTool

                      Comment


                      • #12
                        Here's some info from CTYSON on structures in the save files. While I start by searching for the "packet IDs", you can't rely on them alone because they are often repeated with different meanings...e.g. there are at least 3 "WRLD" packets, and each city has 5 "CITY" packets. Also, the save files are full of random junk data which sometimes imitates packet IDs.

                        World...search for "WRLD"

                        Pos Len
                        0: 4: "WRLD" packet ID
                        4: 4: data-length of packet (always $0002?)
                        8: 2: unknown
                        10: 4: "WRLD" packet ID (but I continue to count from the 1st)
                        14: 4: data-length of packet
                        22: 4: Y-size of world
                        42: 4: X-size of world


                        Players...search for "LEAD"

                        Pos Len
                        0: 4: "LEAD" packet ID
                        4: 4: data-length of packet (always $1174?)
                        8: 4: player number (range 0-31, in ascending order. 0 is
                        always
                        Barbarian; human is currently always 1)
                        12: 4: race of player's civilization (range 0-16)
                        232: 4: current research project


                        Units...search for "UNIT"

                        Pos Len
                        0: 4: "UNIT" packet ID
                        4: 4: data-length of packet (always $0121?)
                        8: 4: unique unit number, in ascending order. First unit is 0
                        12: 4: X-position
                        16: 4: Y-position
                        20: 4: previous X-position, -1 if unit never moved
                        24: 4: previous Y-position
                        28: 4: owner (by player number, NOT race number)
                        40: 4: unit type (index into list of units)
                        44: 4: level (0 = conscript, 1 = regular, etc.)
                        52: 4: damage taken (0 = full strength)

                        Cities...search for "CITY"

                        Note there are several data packets labelled "CITY" for each city...
                        I am oversimplifying by counting from the first.

                        Pos Len
                        0: 4: "CITY" packet ID
                        4: 4: data-length of packet (always $0088?)
                        8: 4: unique index number of city?
                        12: 2: X-position
                        14: 2: Y-position
                        16: 1: owner (by player number)
                        44: 4: shields collected for construction
                        52: 4: what city is constructing (index into list of either
                        units or buildings, see next entry)
                        56: 4: type of construction ( 1 = building, 2 = unit)
                        384: 28: city name

                        After the city name there are several packets relating to population and citizens, followed by a "BINF" packet which relates to improvements:

                        Pos Len
                        0: 4: "BINF" packet ID
                        4: 4: data-length of packet (always $0004?)
                        8: 4: number of possible buildings

                        This is followed by 12 bytes for each building. To discover which
                        building is meant, you have to index into the building list:

                        Pos Len
                        0: 4: year of construction, 0 if not built
                        4: 4: number of player who constructed building (?), -1 if
                        not built
                        8: 4: accumulated cultural value of building (??)

                        Comment


                        • #13
                          Good, as you have gotten started, I think that there is no need to keep what I know secret any longer.

                          For the CITY sections:

                          60: 4 year founded

                          384: 24: city name
                          408: 4 numbers of queue slots used
                          412: 9 * 8 Build data (4 Index and 4 type) for each of the 9 slots


                          The BITM section:
                          0: BITM Section starter
                          4: 4 length (40)
                          8: 32 bitwise building info. One bit foe each building type
                          40: 4 Number of bits used (74 with default rules)
                          44: 4 Unknown


                          For the UNITS:
                          32: Nationality
                          56: Movements used (stored in number of road movements used (default rules 3* movements))
                          72: Loaded on (Ingame Unit ID of unit that holds this unit. (used with ships and armies))


                          But remember that the hardest is to find the right Section. (If you make a tool)
                          Creator of the Civ3MultiTool

                          Comment


                          • #14
                            I'll remind everyone about that the X and Y value for cities only is the name, and where units from the city are created.

                            The location on the map is stored among the TILE-sections. However there are to many places where the Citynumber appear to be able to tell what all mean.
                            (Many of the unknown values are citynumbers. (some are for the city that work on that tile, others for the actual city.))

                            I think I managed to create a tile that teleported you directly to a city once, but I don't remember how I did it .
                            Creator of the Civ3MultiTool

                            Comment


                            • #15
                              Up
                              HW

                              Comment

                              Working...
                              X