Jump to content
smf_16

discovery Modifying .sc4 savegames: It IS possible!

smf_16

Information

For updating to the latest version package, remember to run the following command:

npm install -g sc4@latest

Message added by smf_16

230 posts in this topic Last Reply

Highlighted Posts

  • Original Poster
  • Posted:
    Last Online:  
     

    Looking at the code, it looks like the error originates here, indicating that the tool somehow can't find the SimGrid where the zone data is stored. This is required to allow the lot to be redeveloped later on - which wasn't possible with the initial version of the tool.

    What do you see when you open the ZoneView in game? Does it show something strange there?

    • Like 2
    • Thanks 2

    Visit www.growifier.com for ploppable residentials

    Love playing hearts and other card games? Have a look at www.whisthub.com!

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    21 hours ago, smf_16 said:

    What do you see when you open the ZoneView in game? Does it show something strange there?

    Thanks for looking into this. The zone view looks to me the same as in the other cities. I see no RCI colours at all as I plopped 100% of the buildings and none was growified, so it just shows the transport network and all blank terrain which is what I see on plopped zones in the other maps. 

    • Like 1

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Well, my guess then is that the required SimGrid entry hasn't been created yet by the game because it didn't need it yet in the simulation. I would run a single game month, save again and then see if it works now. Make sure to keep a copy of the old city where the simulation has not run yet though in case something goes wrong!

    It should be possible to modify the program so that it adds the SimGrid file if it does not exist yet, but that would require a bit of efforts, for which I currently don't have the time unfortunately.

    • Like 2
    • Thanks 2

    Visit www.growifier.com for ploppable residentials

    Love playing hearts and other card games? Have a look at www.whisthub.com!

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    18 hours ago, smf_16 said:

    I would run a single game month, save again and then see if it works now.

    Done it, and unfortunately I got the very same error message. :(  It's weird because the train station is being used. 

    • Like 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    @justforfun What about zone something like a 1 x 2 industrial, grow it, then save, and try again?

    • Like 1
    • Thanks 1

    Chance favors the prepared mind. ― Louis Pasteur  
    Remember, a few hours of trial and error can save you several minutes of looking at the README. -- I Am Devloper (on Twitter)

    Clickable ---> The Best of Cori's Posts  (scroll down a wee bit there)    Something fun: MySimtropolis - Invitation to become a SimCity 4 MySim

    Are you new here? Check out the Introduction and Guide to Simtropolis.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    26 minutes ago, CorinaMarie said:

    @justforfun What about zone something like a 1 x 2 industrial, grow it, then save, and try again?

    Hi, sure I can try however I growified with no problems other maps that had never been run and only featured a few plopped residentials. I can't fathom what the problem might be with this one.

    UPDATE: done that too, and still the same error as I feared. 

    • Like 2

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    I think this might be the point where we send the city in and compare the internal data.

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    19 hours ago, Wiimeiser said:

    I think this might be the point where we send the city in and compare the internal data.

    I can send it to anyone kind enough to analyse it *:lol:

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Here's an interesting little growify experiment. You may be familiar with Reddonquixote's Eureka Tower. There are two versions of Eureka Tower on the STEX: A ploppable residential and a non-functional landmark. You may also remember that this was among his early BATs and he didn't realize that a plopped residential building would inevitably abandon (he would later upload the landmark version as a separate download). I plopped the ploppable residential version and growified it. A residential zone now appears beneath the building and Sims are able to leave the building and find jobs. This is a building that was specifically modded as a ploppable residential building. Amazing! The only strangeness: When you hover the route query tool over the building, the query is still the usual landmark orange and it says "Workers" instead of "Commuters."

    -Blade

    Untitled.jpg.5ed9558fb18c7db698266ffe30b19b4f.jpg

    • Like 7

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Ok, here I am with a new bug!

    This time the central map of my region no longer opens. When I click on it to run it, I get a CTD.  In the past I sometimes had CTDs as soon as the city opened, and the problem was due to my tinkering with some building exemplars. But now the CTD happens from the region view just a couple of seconds after the city starts loading. When I try and open it through SC4 Startup Manager, the program just freezes. 

    So I tried growifying the city to check whether there was something unusual about it, and indeed this is the message I got:

    error.jpg.582f49282ffe124c6f3b6bac6d295b75.jpg

    Perhaps this gives hints as to why I can't open it? Thanks in advance to @smf_16 or anyone with insights. 

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    3 hours ago, justforfun said:

    and indeed this is the message I got

    So why not make a Backup (I'd do this for the entire Region at this point), then see if running that function helps, worth a shot right?


    Head over to my Lot and Mod Shack to keep abreast of my latest developments.

    Do you like custom textures, but don't like all the work involved creating them?, take a look at the Texture Automation options here. Change the look and feel of your transit networks, with the minimum of effort, for example customised versions of my Sidewalk NAM (SWN) and Terrain Grass NAM (TGN) mods, and much more besides.

    New to the NAM? Check out my tutorials on YouTube. Latest upload: How to: RHW - MHO Roundabout Interchanges. (Nov 25).

    p.s. - I'm MGB over on SC4D and a member of the NAM team.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Based on the error, it looks like the game has somehow corrupted one of the SimGrid entries when saving. It errors on the decompression stage which indicates that the compressed input is malformed. I'm not sure which version you're running of the tool, but in later versions I've rewritten the qfs decompression algorithm and ported it to JavaScript. You could try using the newest version and see if the error is a bit more specific. However, if I'm not mistaken, the newest version requires a Node version that doesn't run anymore on Windows 7 iirc, so before that make sure you know your current version by running sc4 --version so you can downgrade again later to that version using npm install -g sc4@0.0.x.

    • Like 2
    • Thanks 2

    Visit www.growifier.com for ploppable residentials

    Love playing hearts and other card games? Have a look at www.whisthub.com!

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    50 minutes ago, rsc204 said:

    So why not make a Backup (I'd do this for the entire Region at this point), then see if running that function helps, worth a shot right?

    Hi, which function should I run then?

    @smf_16 I have node 13.14.0   x64

    Suppose I manage to growify the city with the newest version, do you think this would fix the savefile so that I could then open the city? 


      Edited by justforfun  

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    7 minutes ago, justforfun said:

    Suppose I manage to growify the city with the newest version, do you think this would fix the savefile so that I could then open the city? 

    Theoretically yes, but the new version doesn't really do anything different, it just doesn't use compiled C++ code anymore to decompress, but a pure JS implementation that I wrote. In the most optimistic scenario there was a bug in the original C++ decompression which is no longer present in the JS implementation, but I'm 99.99% sure that won't be the case since you're experiencing CTD's both in the game and the SC4 Startup Manager, meaning those algorithms would be bugged as well.

    That said, trying to decompress with the pure JS implementation may provide a more detailed error of where the decompression exactly fails and maybe that points somewhere.

    • Like 3
    • Thanks 2

    Visit www.growifier.com for ploppable residentials

    Love playing hearts and other card games? Have a look at www.whisthub.com!

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    1 hour ago, smf_16 said:

    However, if I'm not mistaken, the newest version requires a Node version that doesn't run anymore on Windows 7 iirc, so before that make sure you know your current version by running sc4 --version so you can downgrade again later to that version using npm install -g sc4@0.0.x.

    You are right that I have Windows 7, so how do I run the Node version that your newest upgrade requires? Running the command you indicated gives me 0.0.24

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Apparently v0.0.24 is the latest version already - glad to know that it still runs on Windows 7. Unfortunately, it means that there's no more detailed error message, so it's not clear how it got corrupted.

    • Like 1
    • Thanks 3

    Visit www.growifier.com for ploppable residentials

    Love playing hearts and other card games? Have a look at www.whisthub.com!

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    wow I go download your program and see if it works for my project, did you also make any programs that can modify the map files / savegame files?

    • Like 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    I've been working on breaking the CRC algorithm, and got success!!

    The method seems to be named CRC32 Unreflected, this method was used in late 90s and early 2000's for doing integrity checks in game data to make sure they are correct.
    Also online sources citate that only the first 250 000 bytes of a section are calculated and the CRC is calculated over the Memory address + data field.

    Now, a python script has been put together which can commit edits to each section in the savegame file!!!

     

     

    def crc32_unreflected(data_bytes, poly=0x04c11db7, init=0xffffffff, xor=0): crc = init for byte in data_bytes: crc ^= (byte
    
    # Example: Insert your memory + data hex string here (no spaces) hex_string = "1C18E01C0C00020000000000B206C20500000000010000003600000001000000360000005F8C2B0001000500000054524F4245080000004E657720436974790D0000005448494A53204C55494B454E530500000054524942450000000000000000B81EF442D7A317420000384200000000000080450000804500008041000080410000803D0000803D00010000000100009C17002836A5EF89DC67F01C8AC390099C9F012893BD90491887CD1C4D968F095C14002810BD90A91C14E01C2D9B8F2920860928019B8F4920860928019B8F491C140028C06290294456A40F478FC4891C050A2F3BCDA6E99C27AB2AAED409EA2028AB2AA14920AAA028AB2A280A23EAE46D761FBCE63FAA1CF8CA2AE0BF90A91CF8062842C1902918FC0628E5C190291CCEA90FD8BD90098C36A10F01BE90E9204D07287ABE90899C1E002880C0908920F6CA2A9AC090891C590728F2BF902924F606285AC090291C060A2F45C090E91C58072834C090C95C503F2D22C090A91C070A2F8EC190E91C29AB2AA4C090C99C29AB2A8EC090A91CCCA90F75C0900924F4CA2A4FC09069201CE01C65C090891C04E01C05C090091C10E01C13C09049BC3F8C03AAC1906920FA0628BCC190291C4874298134410A20A509284E661B4A20030A2F03CA14CA78DA8E03B2820F6AD4F48B033B9D8FA9FC62160F179D8FC96C368E034A9D8FC9D437130F289D8FA92488092816D60D4A242AAB2AFB3638AA1CF4062825958FE91C080A2F29F9E7A7B85A3F2D36BAD4EA68E690038143B10B1C090A2F46BD90C901" # From your new dump data_bytes = bytes.fromhex(hex_string) new_crc = crc32_unreflected(data_bytes) print(f"New CRC: 0x{new_crc:08X} (Little-endian bytes: {' '.join(f'{byte:02X}' for byte in [(new_crc >> (i*8)) & 0xFF for i in range(4)])})")
    

    with this code I changed my city name from TRIBE to TROBE!! wohooo, next thing Im gonna do is making edits to the map size, as that was my inspiration

    • Like 2

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    so what I try to do next is make a blank city and shift the dimensions from 64x64 to 63x65, this is a trick I used in the past to shift map sizes without needing to edit the data size

    • Like 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    I will provide a step by step tutorial how to make the program work:
    Step 1: Install etc. python if necessary
    Step 2: Save this code as python file named CRCCALCULATORRAW.py 
     

    import sys
    
    def crc32_unreflected(data_bytes, poly=0x04c11db7, init=0xffffffff, xor=0):
        crc = init
        for byte in data_bytes:
            crc ^= (byte << 24)
            for _ in range(8):
                if crc & 0x80000000:
                    crc = ((crc << 1) ^ poly) & 0xffffffff
                else:
                    crc = (crc << 1) & 0xffffffff
        return crc ^ xor
    
    def main():
        if len(sys.argv) != 2:
            print("Usage: python sc4_crc_calculator_raw.py <binary_file_path>")
            sys.exit(1)
        
        file_path = sys.argv[1]
        try:
            with open(file_path, 'rb') as f:  # Binary mode for raw data
                data_bytes = f.read()
        except FileNotFoundError:
            print(f"Error: File '{file_path}' not found.")
            sys.exit(1)
        
        # Cap at 250,000 bytes
        if len(data_bytes) > 250000:
            data_bytes = data_bytes[:250000]
            print("Warning: Input truncated to 250,000 bytes.")
        
        crc_value = crc32_unreflected(data_bytes)
        
        print(f"Computed CRC: 0x{crc_value:08X}")
        little_endian_bytes = ' '.join(f'{byte:02X}' for byte in [(crc_value >> (i*8)) & 0xFF for i in range(4)])
        print(f"Little-Endian Bytes: {little_endian_bytes}")
    
    if __name__ == "__main__":
        main()

    Step 3: Go with a hex editor inside your savegame file after you made backups of them and select the data you want to compute the CRC on and save the file named as RAWHEXDUMP.HEX
    Note: Be sure to select the data part where the memory index number begins right after the block size and crc.

    Step 4: If you are in windows, make a windows batch file called "Run Calculator.bat"

    Step 5: Put inside the following lines:
    python CRCCALCULATORRAW.py RAWHEXDUMP.HEX
    PAUSE
    CRCCALCULATORRAW.py Should call your saved python file
    RAWHEXDUMP.HEX Should open your saved hex data
    PAUSE is just to prevent the window from automatically closing so that you see the computed CRC
    image.png.3a662d29c657c1cc8b2384cdffb59f2e.png
    The little endian bytes are the output crc code.

    Step 6: You can make updates to the hex dump and/or savegame file to update the new crc, please note that if the size of the data changes, that you must also update the size header also. 

    Info: the code in my previous post directly calculates the crc checksum of a ascii string hex dump in the input field.

    Hopefully someone can incorporate this method into the SimCity exemplar reader program, then we can make REAL edits to savegames haha!!
    For now I have to do with the manual mode, well after 22 years I feel happy to have publicly shared a way how to edit savegames in SimCity!! wohoooo

    • Like 5

    Share this post


    Link to post
    Share on other sites

    Sign In or register to comment...

    To comment in reply, you must be a community member

    Sign In  

    Already have an account? Sign in here.

    Sign In Now

    Create an Account  

    Sign up to join our friendly community. It's easy!  

    Register a New Account


    ×

    Thank You for the Continued Support!

    Simtropolis depends on donations to fund site maintenance costs.
    Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

    But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

    Make a Donation, Get a Gift!

    Expand your city with the best from the Simtropolis Exchange.
    Make a Donation and get one or all three discs today!

    STEX Collections

    By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

    Each donation helps keep Simtropolis online, open and free!

    Thank you for reading and enjoy the site!

    More About STEX Collections