Network problems.
I encountered a roadblock on this project that was hands down the most frustrating error I have
ever encoutered. When I moved the unit on one client the code was written to have it move on the
other, but it didn’t. The biggest problem I have so far with networking is how tricky it is to debug.
There isn’t an immediately apparent way to determine whether the error is being caused by the client
sending the wrong data, the server forwarding the data incorrectly, and the other client receiving
or interpretting the data incorrectly. As it happened it was none of the above. The correct data was
leaving the client, passing through the server and arriving on the other client. A break point was being
hit on the recipient client that had it receiving exactly the data being sent, but by the time it got back
around to an update frame, any changes made by the network function were being reverted.
I figured that this was most likely an issue with threads, the network being on a seperate thread to the game
logic. The way I got around this error was by not sending the data received by the client network straight away,
but rather placing it in a vector, which worked as a queue of changes to send to the game when it was ready to
receive them.