SC4 Devotion Forum Archives

Sim City 4 Devotion Tools => Tools - General Discussion => Topic started by: B100D5H0T on February 25, 2021, 06:37:22 AM

Title: SC4Parser - Library for loading data from SimCity 4 savegames
Post by: B100D5H0T on February 25, 2021, 06: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 (https://github.com/Killeroo/SC4Parser/tree/master/SC4Parser), documentation (https://github.com/Killeroo/SC4Parser/blob/master/DOCUMENTATION.md) (with examples (https://github.com/Killeroo/SC4Parser/blob/master/DOCUMENTATION.md#example)) and the pre-built library (https://github.com/Killeroo/SC4Parser/releases) over on GitHub (https://github.com/Killeroo/SC4Parser).


Hi, for the past few months I have been working a tool that creates pictures of maps from SimCity 4 save games (https://sc4devotion.com/csxlex/lex_filedesc.php?lotGET=4019). 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 (https://github.com/sebamarynissen/sc4/blob/master/src/decompress.cpp) file (https://github.com/wouanagaine/SC4Mapper-2013/blob/master/Modules/qfs.c) 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 (https://wiki.sc4devotion.com/index.php?title=Savegame) to build a parsing library of my own, which may save some people some pain and time. It has the following features:


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:


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 (https://github.com/Killeroo/SC4Parser). 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.
Title: Re: SC4Parser - Library for loading data from SimCity 4 savegames
Post by: flann on February 25, 2021, 07:08:21 AM
Excellent work, thank you for sharing!