1

I have looked for ways of doing it but have not found any solution. I need to send a player's coordinates in a game to the server. I got the idea of making a string and splitting it up into pieces of data when recieved but there must be a simpler way, I thought.

The ENet function to create a packet takes in a const void *, but I can't get a reference to a struct of data to work, and to me that does not make sense since the reference points to data on one machine, not every client's. Any ideas?

lomstfer
  • 69
  • 7
  • 1
    Serialize the data to send. Send that buffer of data. On the other machine, deserialize the data. The data can be sent as binary or as text. Usually binary is more compact, but text is easier to work with (especially for debugging). I often implement both, and use binary by default for release builds, and text by default for debug builds. – Eljay Jun 03 '22 at 14:35
  • Look into [Flatbuffers](https://google.github.io/flatbuffers/) or protocol buffers or any other serialization format before trying to roll your own. – Botje Jun 03 '22 at 15:28

0 Answers0