Menu

LEX File Exchange
EA Support Files
SC4 Wikipedia
Network Addon Mod
Dependencies
Chat
Welcome, Guest. Please login or register.
Did you miss your activation email?

June 14, 2021, 04:55:00 AM

Login with username, password and session length

Author Topic: SC4Parser - Library for loading data from SimCity 4 savegames  (Read 450 times)

0 Members and 1 Guest are viewing this topic.

Offline B100D5H0T

SC4Parser - Library for loading data from SimCity 4 savegames
« on: February 25, 2021, 08:37:22 AM »
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 library 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.

Offline flann

  • NAM Team
  • Forums Inhabitant
  • *
  • Posts: 30
  • Total likes: 131
  • Reputation: 5
  • Your slogan here
Re: SC4Parser - Library for loading data from SimCity 4 savegames
« Reply #1 on: February 25, 2021, 09:08:21 AM »
Excellent work, thank you for sharing!