DemonTPx/smashbattle — pull request #52 by rayburgemeestre (2014-02-16 17:36:58+00:00)
Title: Lot's of fixes required to get UDP transmissions (hopefully) stable. :-)

* Moved establishing of "communication token" to front of all communication in separate negotiation state.
* Mark client's "UDP ready" with explicit "Server-ready" / "Client-ready" negotiation.
* Fix UDP for server's clients.
**Do not open separate UDP ports for serverclients, just bind them.
**Only allocate packet once
**Only free packet in destructor, once freed, succesful send's in sdl are no longer guarenteed.
**Do not send communicationToken in every packet.
* Fix UDP for client's serverclient.
**No longer account for communicationToken from server in UDP packets
**Use new parse_udp() function that gives preference to UDP parsing, and prevents "collisions" with TCP data (when parsing)
**The communication token is now a Uint32, prevents problems when communicating between 32bit and 64bit platforms. (The sizeof() structs wouldn't match.)
**Explicit acknowledgement of SetCommunicationToken.
* Client only sends PING? requests periodically if it has a communicationtoken available.
* New parse_udp that "inserts" the UDP packet in the buffer, so it's processed first. It restores the "expecting packet" state if a TCP packet is not fully received.
* Fix bug in Server where it would attempt to receive UDP packets even though it is not initialized as a server.
* Explicit binding of client remote ip+port to the UDP socket on server. The communicationToken is for extra security.
* Calculating lags on server is an explicit state now. Only handled after commToken is ready.