• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

pbox

Private
Nov 7, 2017
17
0
I'm about to write myself a binary template for .crp, since some things don't seem to work in the editors as they should (e.g. editing existing map themes; changing the asset name of roads). Most of it works fine but there are two things (so far) that I can't figure out:

-- How is the length of mesh data defined? (UnityEngine.Mesh) .. most everything else -- images, strings, etc -- seems to have length data right before the actual data starts, but for meshes I don't see anything like that, and I can't find an index or terminator either.

-- BuildingInfo+Prop[] seems to have a list of entries which contain the prop name and then 22 bytes almost all of the time, but sometimes it's 23 bytes (screenshot). I assume this is positioning data? I don't really need to know what it is, but I need to figure out how to determine correctly where the next entry starts. Anyone have a clue on that?


Edit, another question:

-- Are the strings always null terminated? I'm a bit unsure since they all seem to have those length fields in front ..

E2: nvm, no they're not.
 
Last edited:

Samson1971

Second Lieutenant
21 Badges
Apr 6, 2015
194
11
  • Cities: Skylines Deluxe Edition
  • Cities in Motion 2
  • Cities: Skylines - Natural Disasters
  • Cities: Skylines - Campus
  • Surviving Mars: First Colony Edition
  • Cities: Skylines Industries
  • Surviving Mars: First Colony Edition
  • Cities: Skylines - Parklife
  • Cities: Skylines - Parklife Pre-Order
  • Surviving Mars: Digital Deluxe Edition
  • Cities: Skylines - Green Cities
  • Surviving Mars
  • Cities: Skylines - Mass Transit
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris
  • Cities: Skylines - Snowfall
  • Cities: Skylines - After Dark
  • Magicka 2
  • Cities: Skylines
Sorry, either I don't understand the problem or you misunderstood.

How so has one entry 22 and another 23?

struc ListEntryProps props[18] is the 18 Prop, your benchmark

ubyte data[22] that says, it follows a data field with a length of 22 in ubyte format
....
....
struc ListEntryProps props[19], the 19 prop starts here, it has 22 data fields in ubyte format.

Where do you think it's at 23?

From 0 - 22 are 23 data fields or data entries.

Green are the Prop index numbers, so Prop 1, Prop 2, Prop 3..., Prop 18, Prop 19..., Prop 22, Prop 23
B09vk4v.jpg


Total Length is right column in Hex Format
 

pbox

Private
Nov 7, 2017
17
0
The highlighted part is 22 bytes long. It would need to be 23 for this entry -- there's another zero byte after it, *then* the length for the next entry (0x0A). Right now, that field (listEntryNameLength of entry 19) comes out as 0 which is wrong (and all of the other entries that follow are also garbled).

So what I'm asking is, how do I determine the correct length of this data? Initially it looked like it would be fixed but it obviously isn't.

FWIW the relevant parts of the template are, right now:

Code:
typedef struct listEntryProps {
    ubyte   listEntryNameLength;
    char    listEntryName[listEntryNameLength];
    ubyte   data[0x16];                                        // <-- not as simple as that
};

// ..

// data type switch

case "BuildingInfo+Prop[], Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null":

            ubyte   dataLabelLength;
            char    dataLabel[dataLabelLength];
            DWORD   length;

            local int i;
            for (i=0; i< length; i++) {
                listEntryProps props;
            };

            ubyte   end;

            break;

This is a binary template for 010 Editor, not sure what other editors have this kind of thing. Kind of like a built-in parsing mechanism for hex data.
 
Last edited:

Samson1971

Second Lieutenant
21 Badges
Apr 6, 2015
194
11
  • Cities: Skylines Deluxe Edition
  • Cities in Motion 2
  • Cities: Skylines - Natural Disasters
  • Cities: Skylines - Campus
  • Surviving Mars: First Colony Edition
  • Cities: Skylines Industries
  • Surviving Mars: First Colony Edition
  • Cities: Skylines - Parklife
  • Cities: Skylines - Parklife Pre-Order
  • Surviving Mars: Digital Deluxe Edition
  • Cities: Skylines - Green Cities
  • Surviving Mars
  • Cities: Skylines - Mass Transit
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris
  • Cities: Skylines - Snowfall
  • Cities: Skylines - After Dark
  • Magicka 2
  • Cities: Skylines
The Entry 19 have a not Name then is this Value correct, Name Length is Zero, the rest is 22 Bytes long, included 1 Byte for the Length of Name equal 23 Bytes.

The 0x0A is the length of the Name from Entry 20.

No Entry end with Zero, correct length, if name length have a Zero then correct length of Data-Entry, 22 + 1.

Have a Name Length 10 or other then Data-Entry 22 + 10 or other value.

22 is the minimal Length of Data, + 1 Bytes minimum if name length is Zero other value then + this vaule of name length
 
Last edited:

Samson1971

Second Lieutenant
21 Badges
Apr 6, 2015
194
11
  • Cities: Skylines Deluxe Edition
  • Cities in Motion 2
  • Cities: Skylines - Natural Disasters
  • Cities: Skylines - Campus
  • Surviving Mars: First Colony Edition
  • Cities: Skylines Industries
  • Surviving Mars: First Colony Edition
  • Cities: Skylines - Parklife
  • Cities: Skylines - Parklife Pre-Order
  • Surviving Mars: Digital Deluxe Edition
  • Cities: Skylines - Green Cities
  • Surviving Mars
  • Cities: Skylines - Mass Transit
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris
  • Cities: Skylines - Snowfall
  • Cities: Skylines - After Dark
  • Magicka 2
  • Cities: Skylines
Yes.

the ubyte data[0x16] contains the actual data, but the problem with the length is the name of the props, this is dynamic and depends on the length of the name.

There are data structures that have a fixed name length, e. g. 255 bytes, but in this case this size is dynamic.

This means that at least 1 byte must be added to the 22 bytes of the parameters of this data structure, the byte specifying the length of the name.

example

The name is 10 characters long, then the first byte contains the length 10 followed by the actual name which consists of 10 characters, so we already have a total of 11 bytes, in addition to the data structure itself with its 22 bytes length, which makes 33 bytes.

If there is no name for this entry, the value in the first byte is 0, because there is no name and therefore the name has no length, so this results in only 23 bytes (0x17) together with the data structure, because the length specification of the name is followed directly by the data structure and not by the name of the entry.

Sorry, my English is not so good and I had this text translated with DeepL.