Cities: Skylines

Cities: Skylines

Evaluări insuficiente
Manipulate networks with a Hex editor
De către Orchid
Understanding how network data are stored in a save file. Fine tune your intersection assets without fiddling with the asset editor.
   
Premiază
Adaugă la preferate
Preferat
Elimină din preferate
Introduction
To be able to edit the save file, you need a hex editor, like HxD: http://mh-nexus.de/en/hxd/

In this tutorial, I will describe:
  • Structure of the serialized data stored in the field m_paths, and
  • Coordinate system used in the game.

CAUTION when you edit your asset with a hex editor:
Changing the file size will break your asset. This means you cannot add paths to or remove them from the path stack. What is available is to replace a path with another one having the same name length.
Structure of path stack
Under the section where m_paths is defined, a stack of paths is found. Immediately after the key word, there is a 32-bit integer describing the size of the stack; that is, how many paths are stored. Be sure to check this number; the file won't load if this number is wrong.
 
Note: Integers and floats, which we will see later, are stored with the least significant byte first[en.wikipedia.org]. For example, a 32-bit unsigned integer 2 is expressed as 00 00 00 02 but stored as 02 00 00 00.
 
Structure of each path
Each path begins with its type name. Before the name string, there is an integer describing how many characters, or how many bytes, the name uses. It's also important to check the character count, or it will cause the file to fail to load up in the game.
 
After the name is the section describing the position of the path in a 3D space. There are three key points controlling the length and direction of the path, and whether it is straight or curved. Similarly, before these points there are also integers that reflect the number of the stack, but these integers are constant. First two points are the start and end positions. The third point defines the control node of the curve or does nothing if it lies on the straight line between two nodes.
 
The three coordinates of each point are stored as 32-bit floating-point numbers, with the least significant byte first. Their values are difficult to calculate manually; you might want to use a converter[www.h-schmidt.net] instead, but be careful – these bytes should be written in the reverse order to successfully convert them.
 
The last variable is a boolean which determines if the direction of the path goes reverse. This is the basis of the tool for switching directions. It also offers great convenience if we want to do this manually.

The last four bytes, not captioned in the image below, are another float called m_maxSnapDistance. Its default for virtually all networks is 0.1, which means they will snap to existing network if within a 0.1 meters' distance. It can also be edited.

Map coordinate system
In the default view, the three axes are laid out as: X pointing to the left, Y toward the top, and Z forward.
 
The unit length in this system is 1 meter, which equals 1/8 a cell length. The origin is at the center of the map.
 
From the origin, the map extends 1080 cells, or 8640 meters along X and Z directions. The asset editor provides an editable area that extends as far as 32 cells, or 256 meters in one direction. From the default height, one can go down at most 60 meters, or go up at most (1024 - 60 = 964) meters.

Reference 1: List of float representations of common numbers
From 0 to 32 meters (4 cells):
Meters | Cells | Float in Little Endian (least significant byte first) 0 | 0 | 00 00 00 00 1, -1 | 1/8 | 00 00 80 3F, 00 00 80 BF 2, -2 | 1/4 | 00 40, 00 C0 3, -3 | 3/8 | 40 40, 40 C0 4, -4 | 1/2 | 80 40, 80 C0 6, -6 | 3/4 | C0 40, C0 C0 8, -8 | 1, -1 | 00 41, 00 C1 12, -12| 1 1/2 | 40 41, 40 C1 16, -16| 2, -2 | 80 41, 80 C1 24, -24| 3, -3 | C0 41, C0 C1 32, -32| 4, -4 | 00 42, 00 C2
From 4 cells upwards until 16:
Cells | Float in Little Endian (least significant byte first) 4, -4 | 00 00 00 42, 00 00 00 C2 5, -5 | 20 42, 20 C2 6, -6 | 40 42, 40 C2 7, -7 | 60 42, 60 C2 8, -8 | 80 42, 80 C2 9, -9 | 90 42, 90 C2 10 | A0 42, A0 C2 11 | B0 42, B0 C2 12 | C0 42, C0 C2 13 | D0 42, D0 C2 14 | E0 42, E0 C2 15 | F0 42, F0 C2 16 | 00 43, 00 C3
 
Use the converter for the rest of the numbers:
http://www.h-schmidt.net/FloatConverter/IEEE754.html
But be careful: In the converter you need to write the most significant byte first, which is the reverse from those listed here.
A common mistake is to break up a byte into two hexes. Don't just write the hexes in reverse.
Reference 2: Types of paths
Notice that most of them have spaces in their names, while HighwayRamp and HighwayRampElevated are the exceptions.
[Common Types] | Length | Hex representation of length Gravel Road                    | 11 | 0B Basic Road | 10 | 0A Basic Road Decoration Grass | 27 | 1B Basic Road Decoration Trees | 27 | 1B Basic Road Elevated | 19 | 13 Oneway Road | 11 | 0B Oneway Road Decoration Grass | 28 | 1C Oneway Road Decoration Trees | 28 | 1C Oneway Road Elevated | 20 | 14 Medium Road | 11 | 0B Medium Road Decoration Grass | 28 | 1C Medium Road Decoration Trees | 28 | 1C Medium Road Elevated | 20 | 14 Large Road | 10 | 0A Large Road Decoration Grass | 27 | 11 Large Road Decoration Trees | 27 | 11 Large Road Elevated | 19 | 13 Large Oneway | 12 | 0C Large Oneway Decoration Grass | 29 | 1D Large Oneway Decoration Trees | 29 | 1D Large Oneway Elevated | 21 | 15 Highway | 7 | 07 Highway Elevated | 16 | 10 Highway Barrier | 15 | 0F HighwayRamp | 11 | 0B HighwayRampElevated | 19 | 13 Train Track | 11 | 0B Train Track Elevated | 20 | 14 Pedestrian Pavement | 19 | 13 Pedestrian Gravel | 17 | 11 Pedestrian Elevated | 19 | 13 [For Stations, Airport, Harbor] (not buildable nor bulldozable) Pedestrian Connection | 21 | 15 Pedestrian Connection Inside | 28 | 1C Train Station Track | 19 | 13 Airplane Stop                  | 13 | 0D Airplane Runway | 15 | 0F Airplane Taxiway | 16 | 10 Ship Dock | 9 | 09 Ship Dockway | 12 | 0C [For Metro Stations exclusively] (not buildable nor bulldozable) Metro Station Track | 19 | 13 Pedestrian Connection Surface | 29 | 1D Pedestrian Connection Underground | 33 | 21
10 comentarii
boformer 10 sept. 2015 la 15:12 
Hey again: I found a much more powerful tool to edit networks:

The mod tools script command line.

I posted a guide for elevated train stations here, but the script can also be used for many other things: http://community.simtropolis.com/forums/topic/68906-i-think-i-found-a-way-to-create-elevated-train-stations/#comment-1590036
boformer 7 sept. 2015 la 13:30 
Hey!

I think I found a way to create elevated train stations. I'm planning to make a mod for it. This is the first prototype: http://community.simtropolis.com/forums/topic/68906-i-think-i-found-a-way-to-create-elevated-train-stations/

I am facing a problem with the creation of the train station track. It is always split into 2 segments when it is longer than 12 cells. Do you know how to prevent that?

Also, do you know how to modify the existing station track of the template?
LottoTheKing 28 iul. 2015 la 12:48 
I'm not so lucky that i just missed it but is there a bulldozable replacement for the "Ship Dock" pathway? Would really like to get rid of it so i can place my own. (:

Very useful guide btw!
templeofdoom 24 iul. 2015 la 12:32 
Hey @Sims firehouse - this is incredible guide you've made. Does this variable, "m_path" and others you noted on affect the way Cims walk through your asset in regards to how the mesh is laid out etc? I'm having issues with Cims "walking through" my mesh and I wonder if this is something I could research and learn more about to correct this. IYHO do you think this could be a solution? I'm reading your detailed guide right now but I'm not a coding master or anything so some of this stuff I'm having to research about at the same time I'm reading it. Thanks in advance for your advice, you are a super knowledgeable person who's helped me in the past so no worries if this is out of your knowledge base etc.
cab1995 6 iul. 2015 la 12:16 
@Sims firehouse 8m would probably be enough if i could get rid of the terraforming.
Orchid  [autor] 30 iun. 2015 la 5:14 
@cab1995, Well, if you want your station track elevated, you're out of luck, because there is a limit to its height, say 8m. There isn't an elevated variant of it either.
cab1995 29 iun. 2015 la 5:55 
Very nice guide! It helped me out alot! I have one question though... Is there a posibility to keep for exaple the "train station track" from terraforming? I need this to make a elevated trainstation over another street.
Orchid  [autor] 8 mai 2015 la 18:20 
To add a path to an asset, first you need to find the path with the same name length which you are able to place in the Asset Editor. For example, I want to add a "Pedestrian Connection" path. I look it up in the reference of available names and find that a "Large Oneway Elevated" has the same name length of 21 characters.
I placed a Large Oneway Elevated in the Asset Editor and then changed the name to Pedestrian Connection in the Hex editor.
This is the hard way.

Here's the easier way:
The mod "Advanced Building" by rollo has extended the ability to place paths in the Asset Editor. It allows any path, or any NetInfo from the game repository, to be placed.
http://steamproxy.net/sharedfiles/filedetails/?id=422797220&searchtext=advanced+building
Katalepsis 1 mai 2015 la 12:51 
Fantastic guide Sims firehouse, thank you for bringing it over to Steam as well.
Vip 27 apr. 2015 la 8:31 
A good guide and will greatly assist any moderator.