BigBang1112 / gbx-net

General purpose library for Gbx files - data from Nadeo games like Trackmania or Shootmania, written in C#/.NET. It supports high performance serialization and deserialization of 200+ Gbx classes.
https://explorer.gbx.tools
86 stars 20 forks source link

Text format for collaboration? #44

Closed vjeux closed 2 years ago

vjeux commented 2 years ago

Hey! I’m thinking of collaborating on a Trackmania map with other people. I was thinking of hosting the content on github.

I was wondering if it’d be possible to export the internal structure to json (or other text format) back and forth. This way we could see proper diff for changes such as new blocks added, media tracker updates, custom models added/removed (content would still be binary).

The next level is to be able to merge the json by hand and then bring it back to a gbx so multiple people can work on the map at the same time.

I feel like it may be possible but wanted to get other people’s thoughts!

BigBang1112 commented 2 years ago

Hello, if you really wanna track map changes through github, serializing the whole GameBox/Node object is currently not a stable option, because both of these rely on external data and recursion, which is not something that auto-json serializer enjoys much. There's this GBX.NET.Json library made, but it's been mostly untouched and the behaviour could vary in negative ways.

When it comes to converting back to Gbx, you still need to provide a lot of other data that comes with the map (not just blocks and items), otherwise, you're risking map data loss. Converting to JSON one-way is easier because you can also use mappers like AutoMapper or Mapster to easily get rid of the unwanted properties. But getting it back to Gbx, you need to store the binary Gbx file with it, then apply the JSON data onto it. This binary Gbx would then serve as the minor data storage and easy proper Gbx constructor.

For serializing/deserializing JSON, I recommend using the System.Text.Json solution, I had a good experience with it so far. Newtonsoft.Json is an unnecessary dependency imo.

vjeux commented 2 years ago

Thanks for the information! I’ll play around with it and see if I can get anywhere :)