Jump to content
Killeroo

.NET library for reading and loading data from SimCity 4 savegames

3 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 

TLDR; I created an open source .NET library that you can use to easily load data and subfiles from SimCity 4 games. It's called SC4Parser, you can find the source code, documentation (with examples) and the pre-built library over on GitHub.

 

Hi, for the past few months I have been working a tool that creates pictures of maps from SimCity 4 save games. As part of the project I needed a way to load and read data and some subfiles from the SimCity 4 savegames. Unfortunately, dispite the format of SimCity 4 savegames being well documented, I could not find any libraries that did what I wanted and would work with C#. Additionally, most code that I did find also relied the same old C source file to decompress items within the save games, which was a pain to get working with .NET. So in the end I decided to use the excellent research and information on the SC4 Wikipedia to build a parsing library of my own, which may save some people some pain and time. It has the following features:

  • Find and load data/files from save game using TypeID or TypeGroupInstance (TGI)
  • Methods to load common subfiles from a save game (Zone, Building, Transport and Terrain files)
  • Automatic QFS decompression

As mentioned above, the library contains a few implementations of common subfiles found in SimCity 4 savegames, some of these implementations are fully complete and others are partially completed but can still be used:

  • Buildings Subfile (Fully Implemented) - Contains a list of all buildings in a city
  • TerrainMap Subfile (Fully Implemented) - Height map for a city
  • Network Subfile 1 (Fully Implemented) - Contains all ground level network tiles (roads, rail, streets etc)
  • Network Subfile 2 (Fully Implemented) - Contains all underground network tiles (subways etc)
  • Bridge Network Subfile (Partially Implemented) - Contains all bridge tiles in the game (decoded during development)
  • Lots Subfile (Partially Implemented) - Contains a list of zones in a city
  • RegionView Subfile (Partially Implemented) - Contains general city information

If you are interested, you can find more info about what is implemented, along with documentation and prebuilt versions of the libary as well as the source code over on GitHub. I hope that this provides a useful framework for others to build small tools, scripts and other programs using data found in SimCity 4 savegames and even if you don't use C# I hope that you find the code useful for working out how SimCity 4 save games are put together. Pull requests, issues and features are always welcome. Enjoy.

  • Like 4

Share this post


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

Nice job. It would be interesting if we can modify the budget subfiles etc. Imagine we can borrow money interest-free or imagine we can doing what the US etc doing by endlessly taking debt for city development or whatever you like. Or, we could raise all the tax to value higher than 20%. Or, having a negative debt, or basically just a free monthly income for us from supposedly, SimNation. So, SimNation is apparently borrowing money from us, not the conventional otherwise. Free money! Not only that but also we can adjust how much they borrow from us and how much money we can get from them. We could technically set their borrowed money from us to basically unlimited and we set the monthly income to us to let's say $10,000 per month. Goodbye magic tree and business deals!

Share this post


Link to post
Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    9 hours ago, chfzdn said:

    Nice job. It would be interesting if we can modify the budget subfiles etc. Imagine we can borrow money interest-free or imagine we can doing what the US etc doing by endlessly taking debt for city development or whatever you like. Or, we could raise all the tax to value higher than 20%. Or, having a negative debt, or basically just a free monthly income for us from supposedly, SimNation. So, SimNation is apparently borrowing money from us, not the conventional otherwise. Free money! Not only that but also we can adjust how much they borrow from us and how much money we can get from them. We could technically set their borrowed money from us to basically unlimited and we set the monthly income to us to let's say $10,000 per month. Goodbye magic tree and business deals!

    The library is built around reading and loading data from save games, not writing data back to the save file. Although it is now conceptially possible to do so, it would be a quite a bit of work, but definitely possible. If someone would like to take on the task I wouldn't stop them.

    In terms of reading the contents of the budget subfiles, the structure of the subfiles are apparently known, so an implementation could be added (pull requests are always welcome ;)).

    • Like 1

    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