Announcement

Collapse
No announcement yet.

Everything about Hex-Editing - UPDATED

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Do you see any obvious mistakes in this part of code? (handle is a java RandomAccessFile-object). After some testing, at least it does remove the huts and it doesn't have any side-effects as obvious as turning the whole map into river (which was the result of my first attempt ).
    Code:
    int fertility;
    final int owner=0;//240 = no owner;  0 = barbarians;
    
    for(int i=0; i < SURFACE ; i++){
      handle.seek( OFFSET_MAP_BLOCK2+6*i+5 );
      fertility = handle.read() % 16;
      handle.seek( OFFSET_MAP_BLOCK2+6*i+5 );
     handle.write( owner + fertility );
    }
    Civilization Webring Forum

    Comment


    • #17

      Yikes, I'm stupid.

      Comment


      • #18
        Originally posted by SCDARS
        Do you see any obvious mistakes in this part of code? (handle is a java RandomAccessFile-object). After some testing, at least it does remove the huts and it doesn't have any side-effects as obvious as turning the whole map into river (which was the result of my first attempt ).
        Code:
        int fertility;
        final int owner=0;//240 = no owner;  0 = barbarians;
        
        for(int i=0; i < SURFACE ; i++){
          handle.seek( OFFSET_MAP_BLOCK2+6*i+5 );
          fertility = handle.read() % 16;
          handle.seek( OFFSET_MAP_BLOCK2+6*i+5 );
         handle.write( owner + fertility );
        }
        Hi! I'm also using Java for my Civ2 related utility, Civ2PBEM Diplomacy, and in the first version, I also used RandomAccessFile! If you are interested, we can share code or whatever you want ...

        (BTW, a good idea would be issue the handle.write when owner<0 && owner>7. This way, you can use this program in any turn of the game, without changing the civ's owner of the tile. For example, if there is a city, I think that your code put the owner city's tile to barbarian, and I'm not sure if that makes sense )
        Trying to rehabilitateh and contribuing again to the civ-community

        Comment


        • #19
          SCDARS, did you finish the program that removes huts?
          Civ2 "Great Library Index": direct download, Apolyton attachment

          Comment


          • #20
            You can get it here: http://www.civ2.de/pages/liga/misc2....tachmentid=581 Since I did not expect much interest, I have not written any documentation. It should be fairly easy to use, though. For installation (java required), simply unzip it into some new folder.
            For use, put your save into that folder, rename it to "save.net" and run the batch file.
            Last edited by SCDARS; November 22, 2003, 08:47.
            Civilization Webring Forum

            Comment


            • #21
              Browsing cities

              You need to know number of units (to get the size of 'unit information block') and number of cities if you want to be able to browse cities by a program.
              I found nothing in the 'Hex-edit.rtf' document...
              Yaroslav, Xin Yu, you probably know it?
              Civ2 "Great Library Index": direct download, Apolyton attachment

              Comment


              • #22
                It is even worse, becuase in order to reach the beginning of the 'city information block' you need not only to know the size of the 'unit information block' but also the size of the 'map information block'!

                You can get the number of units from the 58-59th bytes: multiply this number by 26 (or 32 in MGE) and you'll have the size in bytes of the 'unit information block'.

                The size (in bytes) of the 'map information block' is

                13 * short int starting in 0x0000358A [surface]
                + 2 * short int starting in 0x00003590 * short int starting in 0x00003592
                + 1024
                + 14

                starting to count from the map header (byte 0x00003586).

                So, you can say that, in MGE the 'city block information' starts in:

                0x00003586 + 13 * short int starting in 0x0000358A
                + 2 * short int starting in byte 0x00003590 * short int starting in 0x00003592
                + 1024
                + 14
                + 32 * short int starting in byte 58
                Trying to rehabilitateh and contribuing again to the civ-community

                Comment


                • #23
                  work of Settlers

                  Yaroslav, thank you very much.

                  Another question:
                  Does anybody know where is agglomerate work of settlers stored? I would like a utility that shows that...
                  Civ2 "Great Library Index": direct download, Apolyton attachment

                  Comment


                  • #24
                    I don't know exactly. However, I will do a little research tomorrow/the next day and I will tell you what I founded
                    Trying to rehabilitateh and contribuing again to the civ-community

                    Comment


                    • #25
                      Research done.

                      The agglomerate work of settlers is stored in the 15th byte of the unit (starting to count in 1). I believe that a 0 in the 15th stands for 0 turns of agglomerate work, 1 stands for 1 turn of agglomerate work and so on...

                      With that info, the utility you were speaking about should be easy to programm

                      I've done two others interesting discoverments that I'm gonna post in the SL-Scenario Creation Forum
                      Trying to rehabilitateh and contribuing again to the civ-community

                      Comment


                      • #26
                        Thank you, yaroslav.
                        I am inclined to believe there are 'units of work' stored in that byte. So Settlers increase the value stored in this byte by 1 every turn of work, but Engineers by 2. Reason: a Leonardo upgrade don't double the aggregate work.
                        I plan to incorporate aggregate work of settlers in 'Beakers counter'. After that I will confirm or deny my hypothesis.
                        Civ2 "Great Library Index": direct download, Apolyton attachment

                        Comment


                        • #27
                          Originally posted by Hex-edit.rtf
                          Enemy ... units that are lost out of sight, will remain marked on their last seen location (?),
                          Only until they move. The move is seen, but then they are lost of sight completely.

                          Originally posted by SCDARS
                          If you use "turn huts off", obviously in the 2nd data block of the map 0F is replaced by 00 in one entry each 6 bytes. My first uneducated guess is: All tiles are set to have been owned by the Barbarians and a hut is considered tipped if one civ owns its tile (in the 6th byte).
                          Moving a roman warrior to one tile changes its respective value to 10, using a Babylonian unit switches it to 20 etc. -- which seems to support this theory.
                          Can someone more experienced comfirm this?
                          Nooo...
                          You confuse two different bytes. The sixth byte is the byte that controls huts:

                          Originally posted by Originally posted by Hex-edit.rtf
                          The fifth byte represents "visibility", indicating which of the civilizations have explored
                          that particular square. 00 means none of the civilizations (including the barbarians,
                          who are the "0th" (red) civilization) have uncovered that square so far
                          ...
                          E.g. A square discovered by the Barbarians, Romans, Germans and Sioux will have the
                          code:
                          20 + 21 + 23 + 27 = 1 + 2 + 8 + 128 = 139 = 8B

                          The sixth byte is generally F0, not always though. I strongly believe that this byte has
                          to do with fertility. Normally all squares end with F0, except Plains and Grassland,
                          which mostly (if not always) end with something else.
                          But I don't know which values clear huts and which don't. 00H clears them, F0H don't, but others should be tested.
                          Civ2 "Great Library Index": direct download, Apolyton attachment

                          Comment


                          • #28
                            I'm sorry, but SCDARS is right, and you're wrong.

                            The 6th byte controls which civs see the tile, and tile fertility. As SCDARS said, the 5th byte controls ownership, and that's what's used to clear the huts.
                            Civilization II: maps, guides, links, scenarios, patches and utilities (+ Civ2Tech and CivEngineer)

                            Comment


                            • #29
                              Hm. So how do you set huts ON using the 5th byte?
                              Civ2 "Great Library Index": direct download, Apolyton attachment

                              Comment


                              • #30
                                You can't just turn them on. The hut pattern is fixed, just like the terrain resources.

                                Terrain resources can only be hidden by the method Civ2 uses to hide them in mid-Ocean (and MapEdit can do that anywhere).

                                Similarly, huts can only be hidden, not put in any place you want.
                                Civilization II: maps, guides, links, scenarios, patches and utilities (+ Civ2Tech and CivEngineer)

                                Comment

                                Working...
                                X