Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schematic generation #31

Open
Eurydia opened this issue Apr 22, 2024 · 4 comments
Open

Schematic generation #31

Eurydia opened this issue Apr 22, 2024 · 4 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@Eurydia
Copy link
Owner

Eurydia commented Apr 22, 2024

The last feature to complete this project is an option to build a dynamic blueprint. It is clear that blueprints in Dyson Sphere Program is an encoded string along with some metadata. The metadata is comma-separated, and the actual blueprint information is present as the payload.

Reversing engineering the blueprint encryption and decryption will undoubtedly be the most time consuming part of this feature.

@Eurydia Eurydia added documentation Improvements or additions to documentation enhancement New feature or request labels Apr 22, 2024
@Eurydia Eurydia self-assigned this Apr 22, 2024
@Eurydia
Copy link
Owner Author

Eurydia commented Apr 22, 2024

A preview of the blueprint is also needed as a complementary feature for this update.

@Eurydia
Copy link
Owner Author

Eurydia commented May 1, 2024

Upon investigation, I have discovered the anatomy of a blueprint. Note that a the header section of a blueprint is mandatory due to the checksum.

BLUEPRINT:0,10,0,0,0,0,0,0,638494904957092655,0.10.29.22015,New%20Blueprint,"H4sIAAAAAAAAC2NkQAWMUAxh/2dgOAFlMsKFEWpPrDHHxv7P4cjwHwpQTWZgAAADD8pdcAAAAA=="E6DED3AAC6C334AE4D6FC6E17ECDF5D0

Firstly, the following section will be referred to as the header. It contains metadata about the blueprint itself.

BLUEPRINT:0,10,0,0,0,0,0,0,638494904957092655,0.10.29.22015,New%20Blueprint,

The first few comma-separated numbers represents the icon layout and icons. They determine which icon layout, icons, and icon positions to display on the in-game menu. The long number represent the time of creation of the blueprint, in seconds since last epoch. The game version in which the blueprint is created. Lastly, the name of blueprint.

However, the name of the file does not need to match the name of the blueprint. For example, the file could be call BP, while the blueprint name is RP.

The section is the actual content of the blueprint.

"H4sIAAAAAAAAC2NkQAWMUAxh/2dgOAFlMsKFEWpPrDHHxv7P4cjwHwpQTWZgAAADD8pdcAAAAA=="

So far, this section contains the building layouts, placements, configuration as well as their coordinates on the planet. The section is encoded using base64. For this section, it is good idea to build and improve upon existing findings; https://github.com/johndoe31415/dspbptk and https://github.com/Wesmania/dspbp.

Finally, the last part is the hash.

E6DED3AAC6C334AE4D6FC6E17ECDF5D0

The hashing algorithm appears to be a modified version of MD5. The hash works by taking the entire content, both header and payload, and append the hash to the end of the string.

@Eurydia
Copy link
Owner Author

Eurydia commented May 5, 2024

The actual payload base64 encoded and gzipped. As such, it should be decoded using base64, and decompress using gzip. The result is a byte string. It cannot be processed any further, so the only way to progress is to match it with existing byte data of buildings, settings, configation, etc.

H4sIAAAAAAAAC2NkQAWMUAxh/2dgOAFlMsKFEWpPrDHHxv7P4cjwHwogImxwUwFEf9RQcAAAAA==

After decoding and decompression, the following byte string is obtained:

\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x00\xff\x00\x00\xc8\x00\x00\x00\x00\x00\x01\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xc8\xac7\x00\x00\x00\x00\x00\x00\x00\x00\x01\xc8\xac7\x00\x00\x00\x00\x00\x00\x00\x00\xff\x08A\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x01\x00\x00\x00\x00\x00

@Eurydia Eurydia changed the title schematic generation Schematic generation Jun 18, 2024
@Eurydia
Copy link
Owner Author

Eurydia commented Jun 18, 2024

The next step is to interpret the byte stream and understand how it stores the information of a blueprint, which will be the most demanding task of the entire feature.

Hopefully, understanding the byte steam will allow me to peek into how a blueprint is generated and create one of my own. Afterward it is just a matter of retracing in the form of compression, encoding, and hashing the stream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant