Skip to content

More networking improvements - #111

Open
AlchlcDvl wants to merge 3 commits into
NuclearPowered:masterfrom
AlchlcDvl:networking-improvements
Open

AlchlcDvl wants to merge 3 commits into
NuclearPowered:masterfrom
AlchlcDvl:networking-improvements

Conversation

@AlchlcDvl

@AlchlcDvl AlchlcDvl commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor
  • Adds a new INetSerializable interface that allows types to define how they are read and written
  • Adds packing methods for long and ulong values
  • Adds the missing branch in the boxed read method for short values
  • Re-adds the Color write method (because we're better off having it than not tbh)
  • Improves the reading and writing of long values
  • Improves on the generic message converter system to allow multiple type parameters of an arbitrary order
  • Improves the boxed read method by consolidating a lot of the type checks into a Dictionary key read
  • Removes deprecated code and the related warning

I would recommend merging #102 and #110 first before this so I can account for their respective changes (as I have plans to look over the IL code as a whole)

- Removes deprecated code
- Improves the reading and writing `long` values
- Readds the Color write method (because we're better off having it than not tbh)
- Adds a new `INetSerializable` interface that allows types to define how they are read and written
- Improves on the generic message converter system to allow multiple type parameters of an arbitrary order
- Improves the boxed read method by consolidating a lot of the type checks into a Dictionary key read
Comment thread Reactor/Networking/Extensions/ExtraMessageExtensions.cs
/// Writes the instance to the provided writer.
/// </summary>
/// <param name="writer">The <see cref="MessageWriter"/> to write to.</param>
void WriteTo(MessageWriter writer);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not Serialize and Deserialize?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made more intuitive sense to name them WriteTo and ReadFrom to me

@AlchlcDvl

AlchlcDvl commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

I'm just confused since I can't really tell what's going in Hazel's reading and writing, instead of using ZigZag encoding, they are just directly casting to and from between int and uint values. I decided not to do that here with long and ulong values since bandwidth actually matters.

I am tempted to do two things, however both seem to not be ideal moves:

  • add packed read and write methods for short and ushort, but they won't save much bandwidth
  • patch Hazel reading and writing to actually properly pack and unpack int values, but I feel like that might break existing reactor and impostor protocols if any exist and depend on the strange packing of int values

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

Successfully merging this pull request may close these issues.

2 participants