An open API service indexing awesome lists of open source software.

https://github.com/redned235/simreader

A Java reader for game data from the Sim* Franchise.
https://github.com/redned235/simreader

game java sc4 sim-city simcity simcity4 sims

Last synced: 4 months ago
JSON representation

A Java reader for game data from the Sim* Franchise.

Awesome Lists containing this project

README

        

# SimReader

A Java parser for game data from the Sim* Franchise.

At the moment, this project only supports SimCity 4, but since many other Maxis games also use a similar format, it could be expanded to support those games too.

There are likely things missing, so pull requests are certainly welcome!

## Usage
You can parse a .sc4 Savegame file by doing the following:
```java
SC4File file = new SC4File(Paths.get("my_city.sc4"));
```

Often, SimCity 4 stores much of its data inside of Exemplar files, found inside the game directory (usually with file extension `.dat`). Lots of data stored inside Savegame files make references to this data in these Exemplars through it's `PersistentResourceKey`.

Here is an example that prints the name of each building:
```java
SC4File file = new SC4File(Paths.get("my_city.sc4"));
ExemplarFile exemplarFile = new ExemplarFile(Paths.get("exemplar/SimCity_1.dat"));

for (Building building : file.getBuildingFile().getBuildings()) {
IndexEntry indexEntry = exemplarFile.getEntry(building.getResourceKey());
byte[] bytes = exemplarFile.getBytesAtIndex(indexEntry);

ExemplarSubfile exemplar = ExemplarSubfile.parse(ExemplarSubfile::new, new FileBuffer(bytes));
System.out.println("Building name: " + exemplar.getProperty(ExemplarPropertyTypes.EXEMPLAR_NAME).getValue());
}
```

**Note:** This project may have issues reading data from files generated by the SimCity 4 macOS port. While efforts have been made to support the encoding differences where possible, none of these differences are documented so while the data may parse in some cases, it may be jumbled. Please open an issue if you notice any problems!

## Repository

### Gradle
```kotlin
repositories {
maven("https://jitpack.io")
}

dependencies {
implementation("com.github.Redned235:SimReader:master-SNAPSHOT")
}
```

### Maven:
```xml


jitpack
https://jitpack.io


com.github.Redned235
SimReader
master-SNAPSHOT
compile

```

## Credits
Much of this project would not be possible without the following resources & repositories:
- [SC4Devotion Wiki](https://wiki.sc4devotion.com/)
- [SC4Mapper](https://github.com/wouanagaine/SC4Mapper-2013/)
- [SC4Parser](https://github.com/Killeroo/SC4Parser)