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

Separate Packet Serialization/Deserialization to allow custom format. #36

Closed
terahlunah opened this issue Jun 9, 2018 · 2 comments
Closed

Comments

@terahlunah
Copy link
Contributor

Currently the packet are just a big enum serialized as-is which limits the way we can craft packet.

For example it's hard to have packet with conditional data.

You could use an Option at the moment but :

  • if things get's nested heavily it's gonna be unreadable
  • if the packet contains a hundred conditional fields like the EntityUpdate will contains later (sending only changed fields), the packet will be twice the size it needs to be because of the way the serializer works with enums, and given the frequency and size of EntityUpdate, it's really bad.

A good idea would be to separate thing out like this :

  • A packet struct containing the pure data
  • A packet serializer/deserializer (which could use the
  • A packet handler to fill/do things with the pure data
@zesterer
Copy link
Contributor

zesterer commented Jun 9, 2018

Interestingly, I believe Serde only serializes the exact enum variant required. If an enum variant requires less data than others to store, Serde will only store the minimum necessary to do so. More information here: serde-rs/serde#251

This would suggest that using serialized enums to send data is still relatively efficient.

@terahlunah
Copy link
Contributor Author

I had a look at serde, you're right, it should be fine

xMAC94x pushed a commit that referenced this issue Apr 29, 2020
xMAC94x pushed a commit that referenced this issue Apr 29, 2020
…o 'master'

Pause when in singleplayer and pause menu

Closes #36

See merge request veloren/veloren!833
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants