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

SVE file format

Discussion in 'Civ1 - General Discussions' started by darkpanda, Apr 15, 2013.

  1. Whelkman

    Whelkman Phantom Taxman

    Joined:
    Mar 16, 2007
    Messages:
    524
    Congratulations! May your Future Tech be plentiful and lacking pollution bugs.
     
  2. darkpanda

    darkpanda Dark Prince

    Joined:
    Oct 28, 2007
    Messages:
    600

    Those 2 "unknown" city bytes must be split into 2 bytes (unknown27 and unknown28), that have a seemingly identical role, yet still quite obscure...

    The only thing I discovered so far, is that each byte's 8 bits are used as follows:
    Code:
        unknown27 :  7 6  |  5 4 3 2 1 0
        unknown28 :  7 6  |  5 4 3 2 1 0
            usage : flags | 6-bit-encoded Unit Type
    
    The flags specify whether the unit is fortified (bit 6) and/or veteran (bit 7).
    The Unit Type, obviously, specify the type of the unit...

    But of course, the big question is: what are those units?

    I am currently going through one of the biggest subroutine of CIV (City processing routine) and hope to discover more, but my guesses point somewhere between "units that protect the city", "units that count for happiness or unhappiness" or "units that where just built last turn" ... Although none of them are satisfying.

    Another problem is that in most gamesaves I have, those bytes have value 0xFF... I only have a single SVE where only 1 city has the value of unknown27 set to 0x45, which codes for 01000101 = fortified, non-veteran, Riflemen. And indeed the city contains a fortified non-veteran Riflemen, but so do many other cities, and their unknown27 and 28 bytes are still 0xFF.

    Well, I'll keep looking...
    But if anyone has a gamesave with other values as well, I'm interested!
     
  3. darkpanda

    darkpanda Dark Prince

    Joined:
    Oct 28, 2007
    Messages:
    600

    While pursuing a clean-up the remaining mysteries of SVE format - including the obscure byte -, I spent the last few days porting the "unit path finding" code from CIV.EXE, and I can now confirm that this byte codes for the next square direction in order to reach the GoTo destination. Its possible value follows the first list proposed by Gowron:
    • 1 = north
    • 2 = north-east
    • 3 = east
    • 4 = south-east
    • 5 = south
    • 6 = south-west
    • 7 = west
    • 8 = north-west

    On a side note, I made many discoveries while browsing this code, most notably I found out why GoTo moves ignore the effect of RailRoad... Maybe a patch on the way? ;)
     
  4. kirkham7

    kirkham7 Warlord

    Joined:
    Dec 22, 2012
    Messages:
    288
    Location:
    Hayward, CA
    I was wondering about that. Also, I noticed in one of my previous threads that railroad is only for ground units, is there a way to allow water units to use them as well?
    One more thing, I noticed that if you change the number of moves a unit can move, the goto doesn't use the new value. I don't remember which save I did it on, so I'll go figure that out later.
     
  5. darkpanda

    darkpanda Dark Prince

    Joined:
    Oct 28, 2007
    Messages:
    600
    Having a second look at it, the part of the GoTo code that ignores railroad is only the part that selects the next square to move to, not the code that actually decrements the number of remaining moves: when selecting the next square, Civ computes a score (a 'cost' actually) for each neighbour square, based on distance to destination, roads on the square, unit's total moves, change of direction (yes indeed, CIV thinks it is more costly to make a right angle turn that continue straight ahead...), etc. This is where I saw that presence of RailRoad doesn't matter, the neighbour will be considered to consume 1/3 of move even if there is railroad.
     
  6. darkpanda

    darkpanda Dark Prince

    Joined:
    Oct 28, 2007
    Messages:
    600
    It seems that bit 7 is related to nuclear power or nuclear threats: when the Diplomatic screen routine starts, CIV sets this bit value to 1 if the foreign Civ possesses more than 1 active Nuclear.
     
  7. darkpanda

    darkpanda Dark Prince

    Joined:
    Oct 28, 2007
    Messages:
    600
    Finally, these 2 unknown bytes, very much look like an additional way to store units... Typically, if a city contains 1 or 2 fortified units whose the city is the Home city, then those units are removed from the Units slots and stored inside those 2 city bytes instead, using up only 1 byte per unit: 2 bits coding for veteran / fortified, and 6 bits for the unit type id.

    These 2 unknown bytes are named "unknown 27" and "unknown 28" in JCivED's city screen.

    For example, if you change the value from 255 to 5, you get a fortified Riflemen, and 3 gives a fortified Legion, without changing anything to the Units data...
     
  8. illepokok

    illepokok Chieftain

    Joined:
    Sep 13, 2015
    Messages:
    6
    It seems very typical for both the War and Peace flags to be true. What does this translate to? Is it possible that one of these is simply an indicator of having made contact with the other civilization?
     
  9. illepokok

    illepokok Chieftain

    Joined:
    Sep 13, 2015
    Messages:
    6


    • Looks like there might be 2 bytes missing... 21x2 = 42. Are there actually 22 wonders?
     
  10. illepokok

    illepokok Chieftain

    Joined:
    Sep 13, 2015
    Messages:
    6
    Question for you guys... Are the continent IDs stored somewhere in the MAP or SVE files? Or are they recalculated after opening the map? I assume it would be something like an 80x50 matrix where each value is a continent ID (or ocean ID).
     
  11. darkpanda

    darkpanda Dark Prince

    Joined:
    Oct 28, 2007
    Messages:
    600

    Only 21 wonders but for some reason CIV starts wonder indices at 1 instead of 0... So bytes 0 and 1 are unused afaik.
     
  12. MaoTseKev

    MaoTseKev Chieftain

    Joined:
    Feb 25, 2016
    Messages:
    1
    Location:
    Winnipeg, Canada
    This sort of thing (file format reverse-engineering) has always fascinated me. Awesome work, everyone! I like playing CivNet, though. Has anyone looked at the format for that? I've been poking around some CivNet save-game files a bit and learned some things, but I don't want to reinvent the wheel. Is there a thread discussing that? The content must be very similar, but the format looks different. The biggest change I've noticed is that there is some sort of run-length encoding going on, and variable-length fields.
     
  13. hannurabi

    hannurabi Warlord

    Joined:
    Aug 29, 2005
    Messages:
    173
    Maybe just I didn't see it but have you discovered tile improvement visibility data bits? Or is that in MAP file?

    Or do I remember wrong and and improvements are always visible on seen terrain?
     
  14. darkpanda

    darkpanda Dark Prince

    Joined:
    Oct 28, 2007
    Messages:
    600
    They are in the MAP file, 1 block for actual improvements, 1 block for visible improvements
     
  15. tupi

    tupi Chieftain

    Joined:
    Jun 25, 2011
    Messages:
    26
    Wow, I finally found this info! (of course I read this thread before but I totally forgot about it!). I used approximate numbers from many tests. It was almost right. Almost.

    At the start of the game there's should be additional component, I guess 80. 80+random(50). Values from tests vary from 80 to 127 (from 25 tests).
     

Share This Page