Announcement

Collapse
No announcement yet.

Civ 2 .SAV file structure

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

  • Civ 2 .SAV file structure

    As a few of you may be aware, I have created a supply and demand calculator for Civ 2 (see link in my sig). I am once again taking a look at making this a much more useful tool. As a result I am looking into the Civ 2 .SAV file structure.

    I have downloaded 2 documents that attempt to describe this format, and unfortunately both appear to be incorrect at describing the SAV file format (2.42 and up). Mainly, the offset for the start of the map section is not correct. For all files that I have checked the offset for the begining of the map file (0x00003586 or 13702 in decimal) and for all save files I have looked at (including the latest one from the Green Succession Game) that falls in a vast expanse of 0's. Any help on this would be appreciated.

    Thanks,
    StuporMan
    Man had always assumed that he was more intelligent than dolphins because he had achieved so much - the wheel, New York, wars and so on - whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man - for precisely the same reasons.

    StuporMan's Supply and Demand Calculator
    Supply and Demand Calculator 2.0.1 Beta Now loading savegames!

  • #2
    Originally posted by StuporMan
    I have downloaded 2 documents that attempt to describe this format, and unfortunately both appear to be incorrect at describing the SAV file format (2.42 and up).
    Do you mean hex-edit.rtf of Allard Hofelt? This info is quite old and were corrected in 2 threads named Everything about Hex-Editing in Scenario League Forum. I remember I posted a correction of starts of data blocks and a comparison regarding different Civ2 versions.
    The link to one of them is in the GL index, but it doesn't work now. So I asked in SLeague: Scenario League > Great Library - Important Threads
    Civ2 "Great Library Index": direct download, Apolyton attachment

    Comment


    • #3
      Thanks SlowThinker,
      Yes that is precisely what I was talking about. I also noted that the Everything about Hex-Editing thread in the GL was missing. I will continue my search in the SL Thread.

      Thanks again,
      StuporMan
      Man had always assumed that he was more intelligent than dolphins because he had achieved so much - the wheel, New York, wars and so on - whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man - for precisely the same reasons.

      StuporMan's Supply and Demand Calculator
      Supply and Demand Calculator 2.0.1 Beta Now loading savegames!

      Comment


      • #4
        Check Mercator's site - he had some documentation on SAV (and MP) file formats.

        Comment


        • #5
          Elephant,

          I have checked his site, unfortunately all the documentation I could find, (including one I got from AGRICOLA which is version 1.7) all say that the map header begins at byte offset 13702 (or 3586 in hex). Unfortunately, when I check the .SAV files I have this is not the case, all I find is a vast expanse of 0's for values.

          So unless I am reading the files improperly (possible), am doing something wrong (also possible), or have not found the latest version of the file (yet again is possible), then the .SAV file has changed formats since that document has been released.

          Anyone willing to help me find the Map offsets?

          Edit: Well I may have figured out what is wrong, but I do not know how to fix it. I failed to read a line in the document that said the file format was for Fantastic Worlds only, and that offsets may be different for different versions. Unfortunately the document does not give any advice on HOW to find these differing offsets.

          So again I ask, anyone interested in helping me find the Map offsets for 2.42, MGE, etc?

          Edit part Deux:

          I have done a small amount of work and believe for 2.42 the map header offset is 0x3478 (13432 Decimal). More to come hopefully, just wanted to give a small update.

          Thanks,
          StuporMan
          Last edited by StuporMan; December 9, 2005, 16:18.
          Man had always assumed that he was more intelligent than dolphins because he had achieved so much - the wheel, New York, wars and so on - whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man - for precisely the same reasons.

          StuporMan's Supply and Demand Calculator
          Supply and Demand Calculator 2.0.1 Beta Now loading savegames!

          Comment


          • #6
            Yes, in 2.42 the map header starts at offset 13432. Depending on what you want to do with the map info from the savegame, you should read the "Civ2 map structure" doc on my website. It also contains a description of the map format in savegames (though not mentioning offsets). It's a bit more complicated than in plain Civ2 maps.

            So unless I am reading the files improperly (possible), am doing something wrong (also possible), or have not found the latest version of the file (yet again is possible), then the .SAV file has changed formats since that document has been released.


            Yes, .sav files have changed, not dramatically, but enough to create differences. The sav format version is at offset 10 in a savegame (2 bytes).

            The hex editing doc won't ever be mentioning anything about Civ2 2.42. I worked on a different more structured document for a while that would give a complete overview for all versions, but I haven't worked on that in a long time. It used to be a thread in the SLeague Hints, Tips & Guides subforum, which would have given you the info, but that subforum is still in limbo and awaiting reconstruction after a forum crash (which was also why that other thread mentioned here was missing).

            So again I ask, anyone interested in helping me find the Map offsets for 2.42, MGE, etc?


            Oh? You suddenly want offsets for all versions now?

            For 2.42 and CiC it's the same: 13432
            For FW and MGE it's: 13702
            ToT has a variable offset. For ToT 1.0, go to offset 29728, read the number at that offset (4 bytes long) and jump forward that many bytes to get to the map (e.g. if it's zero, the map starts at 29732). For ToT 1.1, go to offset 29896 and then do the same as with ToT 1.0.

            And if you're wondering how to identify the different versions, you can do that with the sav format version number I mention earlier. Up to and including CiC the number is 39, for FW it's 40, for MGE 1.3 it's 44 (!, not checked for unpatched MGE), for ToT 1.0 it's 49, for ToT 1.1 it's 50.
            Civilization II: maps, guides, links, scenarios, patches and utilities (+ Civ2Tech and CivEngineer)

            Comment


            • #7
              This is a part of my source code:
              (I am a bit out now, if you need some explanation I will have to study it a bit)

              function ClassicVersion: true - 2.42 and CiC, false - others
              function MultiplayerVersion: true - MGE
              (so I differentiate three groups: 2.42+CiC, FW, MGE)
              but I don't have ToT, so I ignored it completely

              $ stands for a hex value in Pascal/Delphi



              {constants that affect position of blocks}
              {they depend on the version}
              SizeOfVarious:=$10A; if ClassicVersion(Civ2Version) then SizeOfVarious:=$FC;
              SizeOfUnit:=26; if MultiplayerVersion(Civ2Version) then SizeOfUnit:=32;
              SizeOfCity:=84; if MultiplayerVersion(Civ2Version) then SizeOfCity:=88;
              SizeOfCivEntry:=$594; if ClassicVersion(Civ2Version) then SizeOfCivEntry:=$574;

              {fixed values}
              PosVarious:=0;
              PosWonders:=PosVarious+SizeOfVarious;
              PosTribes:=PosWonders+$13E;
              PosCivs:=PosTribes+$69E;
              PosMap:=PosCivs+8*SizeOfCivEntry;
              PosMapBlock1:=PosMap+$E;

              PosNrOfUnits:=58;
              PosNrOfCities:=60;
              PosMapSurface:=PosMap+4;
              PosMapQuarterWidth:=PosMap+10;
              PosMapQuarterHeigth:=PosMap+12;

              FileStream.Seek(PosNrOfUnits,soFromBeginning); FileStream.Read(NrOfUnits,sizeof(NrOfUnits));
              FileStream.Seek(PosNrOfCities,soFromBeginning); FileStream.Read(NrOfCities,sizeof(NrOfCities));
              FileStream.Seek(PosMapSurface,soFromBeginning); FileStream.Read(MapSurface,sizeof(MapSurface));
              FileStream.Seek(PosMapQuarterWidth,soFromBeginning ); FileStream.Read(MapQuarterWidth,sizeof(MapQuarterW idth));
              FileStream.Seek(PosMapQuarterHeigth,soFromBeginnin g); FileStream.Read(MapQuarterHeight,sizeof(MapQuarter Height));

              {next part requires "fixed values" and MapSurface,MapQuarterHeight,MapQuarterWidth,NrOfUn its,NrOfCities}
              PosMapBlock2:=PosMapBlock1+7*MapSurface;
              PosMapBlock3:=PosMapBlock2+6*MapSurface;
              PosUnits:=PosMapBlock3+2*MapQuarterHeight*MapQuart erWidth+1024;
              PosCities:=PosUnits+SizeOfUnit*NrOfUnits;
              PosCitiesTXT:=PosCities+SizeOfCity*NrOfCities;
              PosCursor:=PosCitiesTXT+1+3*21;
              PosScenarioAppendix:=PosCursor+$6EF; {normally points to (potential) EOF marker}

              {position of selected information}
              PosTurn:=28; PosYear:=30;
              PosMapUsed:=40; PosCivUsed:=41;


              {sizes of blocks}
              SizeOfTribeEntry:=$F2;
              SizeOfLeaderAndTribeName:=22;
              Last edited by SlowThinker; December 10, 2005, 15:33.
              Civ2 "Great Library Index": direct download, Apolyton attachment

              Comment


              • #8
                Thanks for the help!

                This will go a long way to helping me get my Calculator to read the .SAV files to get its information.

                It will take me a while to digest this information, so I may have more questions for you guys later.

                Thanks again for the help!

                StuporMan:
                Man had always assumed that he was more intelligent than dolphins because he had achieved so much - the wheel, New York, wars and so on - whilst all the dolphins had ever done was muck about in the water having a good time. But conversely, the dolphins had always believed that they were far more intelligent than man - for precisely the same reasons.

                StuporMan's Supply and Demand Calculator
                Supply and Demand Calculator 2.0.1 Beta Now loading savegames!

                Comment


                • #9
                  I edited one comment in the source.
                  Civ2 "Great Library Index": direct download, Apolyton attachment

                  Comment

                  Working...
                  X