1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * |
5 | * |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
6 | * Deliantra is free software: you can redistribute it and/or modify it under |
7 | * the terms of the Affero GNU General Public License as published by the |
7 | * the terms of the Affero GNU General Public License as published by the |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
8 | * Free Software Foundation, either version 3 of the License, or (at your |
9 | * option) any later version. |
9 | * option) any later version. |
… | |
… | |
20 | * The authors can be reached via e-mail to <support@deliantra.net> |
20 | * The authors can be reached via e-mail to <support@deliantra.net> |
21 | */ |
21 | */ |
22 | |
22 | |
23 | #ifndef CLIENT_H |
23 | #ifndef CLIENT_H |
24 | #define CLIENT_H |
24 | #define CLIENT_H |
25 | |
|
|
26 | #include <deque> |
|
|
27 | #include <bitset> |
|
|
28 | #include <tr1/unordered_set> |
|
|
29 | |
25 | |
30 | #if HAVE_TCP_INFO |
26 | #if HAVE_TCP_INFO |
31 | # include <netinet/tcp.h> |
27 | # include <netinet/tcp.h> |
32 | #else |
28 | #else |
33 | struct tcp_info { |
29 | struct tcp_info { |
… | |
… | |
258 | int len; |
254 | int len; |
259 | int count; |
255 | int count; |
260 | char msg[MSG_BUF_SIZE]; |
256 | char msg[MSG_BUF_SIZE]; |
261 | } msgbuf[MSG_BUF_COUNT]; |
257 | } msgbuf[MSG_BUF_COUNT]; |
262 | |
258 | |
263 | MTH bool msg_suppressed (const char *msg); |
259 | MTH bool msg_suppressed (const_utf8_string msg); |
264 | |
260 | |
265 | /* The following is the setup for a ring buffer for storing output |
261 | /* The following is the setup for a ring buffer for storing output |
266 | * data that the OS can't handle right away. |
262 | * data that the OS can't handle right away. |
267 | * TODO: this member is enourmously large - optimise? |
263 | * TODO: this member is enourmously large - optimise? |
268 | */ |
264 | */ |
… | |
… | |
290 | MTH void flush (); |
286 | MTH void flush (); |
291 | MTH void write_outputbuffer (); |
287 | MTH void write_outputbuffer (); |
292 | MTH int outputbuffer_len () const { return outputbuffer.len; } |
288 | MTH int outputbuffer_len () const { return outputbuffer.len; } |
293 | void send (void *buf_, int len); |
289 | void send (void *buf_, int len); |
294 | |
290 | |
295 | void send_packet (const char *buf); |
291 | void send_packet (const_octet_string buf); |
296 | void send_packet (const char *buf, int len); |
292 | void send_packet (const_octet_string buf, int len); |
297 | void send_packet_printf (const char *format, ...) attribute ((format (printf, 2, 3))); |
293 | void send_packet_printf (const_utf8_string format, ...) attribute ((format (printf, 2, 3))); |
298 | void send_packet (packet &sl); |
294 | void send_packet (packet &sl); |
299 | |
295 | |
300 | void send_drawinfo (const char *msg, int flags = NDI_BLACK); |
296 | void send_drawinfo (const_utf8_string msg, int flags = NDI_BLACK); |
301 | |
297 | |
302 | MTH void send_face (faceidx facenum, int pri = 0); |
298 | MTH void send_face (faceidx facenum, int pri = 0); |
303 | MTH void send_faces (object *ob); |
299 | MTH void send_faces (object *ob); |
304 | MTH void send_animation (short anim_num); |
300 | MTH void send_animation (short anim_num); |
305 | void send_msg (int color, const char *type, const char *msg); |
301 | void send_msg (int color, const_utf8_string type, const_utf8_string msg); |
306 | |
302 | |
307 | MTH void play_sound (faceidx sound, int dx = 0, int dy = 0); |
303 | MTH void play_sound (faceidx sound, int dx = 0, int dy = 0); |
308 | // called when something under the player changes |
304 | // called when something under the player changes |
309 | MTH void floorbox_update () { update_look = 1; } |
305 | MTH void floorbox_update () { update_look = 1; } |
310 | // called when the player has been moved |
306 | // called when the player has been moved |
… | |
… | |
378 | for (int _i = 0; _i < clients.size (); ++_i) \ |
374 | for (int _i = 0; _i < clients.size (); ++_i) \ |
379 | statementvar (client *, var, clients [_i]) |
375 | statementvar (client *, var, clients [_i]) |
380 | |
376 | |
381 | // returns true when the message needs special (read: perl) treatment |
377 | // returns true when the message needs special (read: perl) treatment |
382 | static inline bool |
378 | static inline bool |
383 | msg_is_special (const char *msg, bool nl_special = true) |
379 | msg_is_special (const_any_string msg, bool nl_special = true) |
384 | { |
380 | { |
385 | return msg [strcspn (msg, nl_special ? "<&\n" : "<&")]; |
381 | return msg [strcspn (msg, nl_special ? "<&\n" : "<&")]; |
386 | } |
382 | } |
387 | |
383 | |
388 | #endif |
384 | #endif |