Medo42/Gang-Garrison-2 — pull request #117 by TazeTSchnitzel (2013-03-25 23:17:31+00:00)
Title: Added Server-sent plugin networking, aka PluginPackets!

All server-sent plugins now get a special packetID that can be used with the PluginPacket* functions to send buffers encapsulated in the new `PLUGIN_PACKET` packet, and to receive them. Receiving, clients get just the buffer (from the server), servers get the buffer (from the client) and the Player object (corresponding to the client). Sending, servers send the buffer to all clients, and clients send the buffer to just the server.

Simple, and somewhat elegant. Maybe.

* When a server-sent plugin is run, `argument1` is a special packetID value
* PluginPacketSend(packetID, buffer) sends the buffer specified, to the server (if client) or to all clients (if server), with that packetID
* PluginPacketPop(packetID) discards the first packet received, from the server (if client) or from a client (if server), if any (returning false if not, true if so), for that packetID
* PluginPacketGetBuffer(packetID) returns the buffer of the first packet received, from the server (if client) or from a client (if server), if any (returning -1 if not), for that packetID
* PluginPacketGetPlayer(packetID) returns the Player responsible for the first packet received, from a client (if server, otherwise returns -1), if any (returning -1 if not), for that packetID