Stadtplan-Dateien (*.sgs) Map File FormatContribution by Paul Spooner
November 17, 2012
So you may have seen an old program kicking around called “Roleplaying City Map Generator 5.4” which is pretty useful for making city maps. There are a few problems with it, like you can’t edit the map once it’s been generated, but it works well for what it does. There’s an importer into the excellent “NBOS fractal mapper” that can be found here.
But I wanted to figure out how to read and edit the save file itself. It turns out the map result save file (.sgs extension) is in plaintext, and easily decoded. It’s a vector format, editable in notepad++ or whatever text editing tool you prefer.
The file is newline delimited (each line holds a “piece” of data), so I’ll be going through each line describing what it is (as far as I can tell). For this guide each bulletpoint is a line of text, with an example in parenthesies. Values that you can safely edit are preceeded by a pound symbol (#like this). Values I don’t know what they are are preceeded by a question mark (?like this). Some values have a single space preceeding them. I’ve marked these with an underscore (_like this). I don’t know if the space is important, but it makes the file easier to read. Repeated values, or arrays of data are inside brackets [like this]. Evertrhing is located as X and Y coordinates, from the top-left corner, x = horizontal (right), y = vertical (down).
Now we get to the fun stuff. The following is the “line” data format. There is one of these entries for each of the roads and rivers (and lakes). If you add or remove one of these sets of data, remember to change the “number of “line” type objects” value above.
After the “line” type objects come the buildings.
And then all the building data.
If the type is 0, or square
But if the type is 1, or round
Okay. Got roads, rivers, and buildings. Next is a bit more confusing, and involves squares, parks, walls, towers, etc. Try and keep up…trees are last and they are super straightforward.
And then the data for the squares. “Squares” in this case are areas enclosed by dotted lines on roads. The x-y coordinates mark out where the dots go.
As a note, the last “square” data will look like this:
and, since the number of data pairs is zero (the second zero) it will be followed by no pairs. These blank entries can also be found elsewhere.
Then the data for the parks. This is exactly the same as for the squares.
After all that data is the “are there walls and towers?” entry.
If 0, skip straight to trees. If 1, it is followed by…
And then all the wall points, in series (this makes a loop)
And then the towers.
If Type = 2
If Type = 1
We’ve made it! Now there’s a bajillion trees!
The file ends with a blank line, or a newline character, depending on how you look at it.