[Tool] EmpyrionStuff - EPB read/write

Discussion in 'The Hangar Bay' started by Apan Loon, Jun 7, 2018.

  1. geostar1024

    geostar1024 Rear Admiral

    Joined:
    Jan 24, 2016
    Messages:
    4,843
    Likes Received:
    6,634
    Remember that the render cost ("class") is a function of the number of devices, number of lights, and number of triangles. I'd guess that devices are separated from regular blocks because devices almost certainly have additional code attached to them, so a device's impact on performance is not just what it takes to render it.
     
    #41
  2. Apan Loon

    Apan Loon Lieutenant

    Joined:
    Jun 7, 2018
    Messages:
    38
    Likes Received:
    13
    Argh! As of 8.5 an extra byte has snuck in between the device group name and the unknown flags. Can anyone figure out how to account for this? (The file version number has not increased, so I am guessing that something in the file indicates if these are there or not)

    Code:
    ...
    nBlockCounts: 0300
    Type Count
    1801 14000000
    2e02 01000000
    9c01 09000000
    unknown05: 05
    nDeviceGroups: 0300
    name: 07 63 7067 436f 7265 //"cpgCore"
    00                   <--------------------------
    01 ff
    nDevices: 0100
    00180080 00
    name: 08 63 7067 4c69 6768 74 //"cpgLight"
    00                   <--------------------------
    01 ff
    nDevices: 1400
    00083080 08 4c69676874203133 //"Light 13"
    00084080 08 4c69676874203134 //"Light 14"
    ...
     
    #42
  3. geostar1024

    geostar1024 Rear Admiral

    Joined:
    Jan 24, 2016
    Messages:
    4,843
    Likes Received:
    6,634
    I just started up work again on my version, and ran smack into this issue. I ended up handling it by reading as many bytes as it took to encounter the 0xFF byte that always seems to be there and then doing the appropriate conversion. As far as I can tell, the extra byte is always 0x00, so I'm currently reading it as a 16-bit integer if there are two bytes. After doing some testing, it really does seem to be the case that this data (1 byte pre-20, 2 bytes post-20) indicates whether or not a group was auto-generated: 256 (little-endian; 1 if big-endian), and zero if it was manually created or modified by the player in any way.

    Also, I did some more work on the datetime field, which appears right before the steam_id section. It's prefixed by 0x05 at location 0x86; the next 7 bytes hold the timestamp in hundreds of nanoseconds since 1827-09-25 18:40:30 (don't ask me why that's the epoch, but it works for all of the blueprints I've tested so far); you have to lop off the last byte (which always seems to be 0x88) and replace it with 0x00 before converting to a 64-bit unsigned integer (from there divide by 1e7 and add it to the epoch). But seriously, why this epoch?
     
    #43
  4. Apan Loon

    Apan Loon Lieutenant

    Joined:
    Jun 7, 2018
    Messages:
    38
    Likes Received:
    13
    I am pretty sure that I managed to read those as standard .Net DateTime objects - skipping one byte somewhere. Not all of them made sense though - as if they had a strange date where only the time part were used.
     
    #44
  5. geostar1024

    geostar1024 Rear Admiral

    Joined:
    Jan 24, 2016
    Messages:
    4,843
    Likes Received:
    6,634
    That would be consistent with what I've been seeing, since normally Microsoft uses 1900 as their epoch. And it'd be very interesting if you came across a blueprint for which the epoch I've experimentally determined does not give the correct date.
     
    #45
  6. Apan Loon

    Apan Loon Lieutenant

    Joined:
    Jun 7, 2018
    Messages:
    38
    Likes Received:
    13
    I haven't done much research since August, but all the creation dates seem fine. On the files I had in early August they range from 2016-12-23 to 2018-07-02.

    The meta data field that I labelled "UnknownMetax12" however, shows the date as 0001-06-12 and a reasonable time. Some files list this as 0001-01-01 00:00:00 ( all zero in the actual data) though. It is quite possible that this isn't actually a datetime - it could be just a time followed by some other data that just happens to be zero for all files...

    EDIT: This is what the .Net documentation says:
     
    #46
    Last edited: Dec 1, 2018
  7. Apan Loon

    Apan Loon Lieutenant

    Joined:
    Jun 7, 2018
    Messages:
    38
    Likes Received:
    13
    Minor update: I realised that one of the bytes in the device group list, the one just before the entry count, is the index of the custom switch in the main control panel. 0xff means that none of the custom switches affect this group, zero means that Custom1 controls it, one means that Custom2 controls it and so on.

    I have not yet looked in to the two new file format versions that has been released since I last looked. I am guessing that version 21 added support for the colour palette addition and that version 22 added support for logistics setup. There may, of course, be more to these...
     
    #47
  8. Apan Loon

    Apan Loon Lieutenant

    Joined:
    Jun 7, 2018
    Messages:
    38
    Likes Received:
    13
    I have done some major cleanup of the reader code. Now it can read all epb files I have without crashing. Some data is still not interpreted correctly, but many files are 100% parsed. This is mostly due to adding version checks and acknowledging different way to store some data in different file format versions.

    Several unknown bytes have been removed from the format definition and these bytes now fit into the surrounding sections.

    The new section "BlockTags", previously known as "Unknown06" is interesting. This section assigns tags to blocks. This ranges from light parameters through enemy spawners to vendors. The documentation has been updated to illustrate how these tags are set up for the various tasks.

    I also renamed the Signals, Logic and LogicOps sections, both in the code and the format documentation. Makes it a little bit easier to understand how the logic rules are stored in the file. A signal source is a switch or detector that creates a true/false value. Signals are then mapped to objects that listen to it. The signal path can optionally go through a signal operator to create complex logic systems.

    My program can not yet create all of these sections, it still creates files of version 20 with most of the old assumptions still in place. In order to be able to have the program create block tags or logic systems, some more work has to be done. Specifically, there needs to be a run-time data structure to hold the various sections after reading them and the most challenging part is to add ways to specify these through the interface. Perhaps the command line interface has reached it's limit in terms of creating blueprints...
     
    #48
  9. Apan Loon

    Apan Loon Lieutenant

    Joined:
    Jun 7, 2018
    Messages:
    38
    Likes Received:
    13
    [​IMG]
     
    #49
    Exacute likes this.
  10. Apan Loon

    Apan Loon Lieutenant

    Joined:
    Jun 7, 2018
    Messages:
    38
    Likes Received:
    13
    Hmm, the huge amount of data added to EPB files of version 23 is confusing.

    BAJ_PharosSubmergedTank.epb, BA_TOPSpiceDestillery.epb and BA_TestBase.epb seem to look somewhat similar but BA_FillerTest.epb has an extra two bytes in front of every matrix that appear to contain only booleans for each possible block position. No, I need a break...
     
    #50
    Last edited: Jan 12, 2019 at 1:49 PM

Share This Page