… | |
… | |
17 | |
17 | |
18 | You should have received a copy of the GNU General Public License |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | |
21 | |
22 | The authors can be reached via e-mail at crossfire.de |
22 | The authors can be reached via e-mail at crossfire@schmorp.de |
23 | */ |
23 | */ |
24 | |
24 | |
25 | /* This file defines various flags that both the new client and |
25 | /* This file defines various flags that both the new client and |
26 | * newserver uses. These should never be changed, only expanded. |
26 | * newserver uses. These should never be changed, only expanded. |
27 | * Changing them will likely cause all old clients to not work properly. |
27 | * Changing them will likely cause all old clients to not work properly. |
… | |
… | |
39 | * more reliable, as both the client and server will definately be |
39 | * more reliable, as both the client and server will definately be |
40 | * talking about the same values. |
40 | * talking about the same values. |
41 | */ |
41 | */ |
42 | |
42 | |
43 | |
43 | |
44 | #ifndef NEWCLIENT_H |
44 | #ifndef NETWORK_H |
45 | #define NEWCLIENT_H |
45 | #define NETWORK_H |
|
|
46 | |
|
|
47 | #include <cstdarg> |
46 | |
48 | |
47 | /* Maximum size of any packet we expect. Using this makes it so we don't need to |
49 | /* Maximum size of any packet we expect. Using this makes it so we don't need to |
48 | * allocated and deallocated the same buffer over and over again and the price |
50 | * allocated and deallocated the same buffer over and over again and the price |
49 | * of using a bit of extra memory. It also makes the code simpler. |
51 | * of using a bit of extra memory. It also makes the code simpler. |
50 | * |
52 | * |
… | |
… | |
306 | packet &operator <<(const data16 &v); |
308 | packet &operator <<(const data16 &v); |
307 | |
309 | |
308 | packet &operator <<(const char *v); |
310 | packet &operator <<(const char *v); |
309 | packet &operator <<(const shstr &sh) { return *this << data (&sh, sh.length ()); } |
311 | packet &operator <<(const shstr &sh) { return *this << data (&sh, sh.length ()); } |
310 | |
312 | |
|
|
313 | void vprintf (const char *format, va_list ap); |
|
|
314 | |
311 | void printf (const char *format, ...); |
315 | void printf (const char *format, ...) |
|
|
316 | { |
|
|
317 | va_list ap; |
|
|
318 | va_start (ap, format); |
|
|
319 | vprintf (format, ap); |
|
|
320 | va_end (ap); |
|
|
321 | } |
312 | }; |
322 | }; |
313 | |
323 | |
314 | inline uint16 net_uint16 (uint8 *data) { return (data [0] << 8) | data [1]; } |
324 | inline uint16 net_uint16 (uint8 *data) { return (data [0] << 8) | data [1]; } |
315 | inline uint32 net_uint32 (uint8 *data) { return (net_uint16 (data) << 16) | net_uint16 (data + 2); } |
325 | inline uint32 net_uint32 (uint8 *data) { return (net_uint16 (data) << 16) | net_uint16 (data + 2); } |
316 | inline sint16 net_sint16 (uint8 *data) { return sint16 (net_uint16 (data)); } |
326 | inline sint16 net_sint16 (uint8 *data) { return sint16 (net_uint16 (data)); } |