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,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 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. |
… | |
… | |
132 | if (inbuf_len >= 2 + pkt_len) |
132 | if (inbuf_len >= 2 + pkt_len) |
133 | return 2 + pkt_len; |
133 | return 2 + pkt_len; |
134 | |
134 | |
135 | if (inbuf_len == sizeof (inbuf)) |
135 | if (inbuf_len == sizeof (inbuf)) |
136 | { |
136 | { |
137 | send_packet_printf ("drawinfo %d input buffer overflow - closing connection.", NDI_RED | NDI_REPLY); |
137 | send_packet_printf ("msg %d log input buffer overflow - closing connection.", NDI_RED | NDI_REPLY); |
138 | destroy (); |
138 | destroy (); |
139 | return -1; |
139 | return -1; |
140 | } |
140 | } |
141 | } |
141 | } |
142 | |
142 | |
… | |
… | |
150 | memmove (inbuf, inbuf + len, inbuf_len); |
150 | memmove (inbuf, inbuf + len, inbuf_len); |
151 | } |
151 | } |
152 | |
152 | |
153 | /***************************************************************************** |
153 | /***************************************************************************** |
154 | * Start of command dispatch area. |
154 | * Start of command dispatch area. |
155 | * The commands here are protocol commands. |
155 | * The commands here are protocol commands. |
156 | ****************************************************************************/ |
156 | ****************************************************************************/ |
157 | |
157 | |
158 | // SocketCommand, PlayingCommand, should not exist with those ugly casts |
158 | // SocketCommand, PlayingCommand, should not exist with those ugly casts |
159 | #define SC(cb) (void *)static_cast<void (*)(char *, int, client *)>(cb), |
159 | #define SC(cb) (void *)static_cast<void (*)(char *, int, client *)>(cb), |
160 | #define PC(cb) (void *)static_cast<void (*)(char *, int, player *)>(cb), PF_PLAYER | |
160 | #define PC(cb) (void *)static_cast<void (*)(char *, int, player *)>(cb), PF_PLAYER | |
… | |
… | |
239 | } |
239 | } |
240 | else |
240 | else |
241 | ((void (*)(char *, int, client *))pkt->cb)((char *)data, datalen, this); |
241 | ((void (*)(char *, int, client *))pkt->cb)((char *)data, datalen, this); |
242 | } |
242 | } |
243 | else |
243 | else |
244 | send_packet_printf ("drawinfo %d ERROR: you cannot execute '%s' now.", NDI_RED | NDI_REPLY, pkt->name); |
244 | send_packet_printf ("msg %d log ERROR: you cannot execute '%s' now.", NDI_RED | NDI_REPLY, pkt->name); |
245 | } |
245 | } |
246 | |
246 | |
247 | bool |
247 | bool |
248 | client::handle_packet () |
248 | client::handle_packet () |
249 | { |
249 | { |
… | |
… | |
291 | |
291 | |
292 | goto next_packet; |
292 | goto next_packet; |
293 | } |
293 | } |
294 | |
294 | |
295 | // If we get here, we didn't find a valid command. |
295 | // If we get here, we didn't find a valid command. |
296 | send_packet_printf ("drawinfo %d ERROR: command '%s' not supported.", NDI_RED | NDI_REPLY, (char *)inbuf + 2); |
296 | send_packet_printf ("msg %d log ERROR: command '%s' not supported.", NDI_RED | NDI_REPLY, (char *)inbuf + 2); |
297 | |
297 | |
298 | next_packet: |
298 | next_packet: |
299 | inbuf [pkt_len] = save_byte; // rather ugly |
299 | inbuf [pkt_len] = save_byte; // rather ugly |
300 | skip_packet (pkt_len); |
300 | skip_packet (pkt_len); |
301 | |
301 | |
… | |
… | |
688 | cfperl_send_msg (this, color, type, msg); |
688 | cfperl_send_msg (this, color, type, msg); |
689 | else |
689 | else |
690 | send_packet_printf ("msg %d %s %s", color & NDI_CLIENT_MASK, type, msg); |
690 | send_packet_printf ("msg %d %s %s", color & NDI_CLIENT_MASK, type, msg); |
691 | } |
691 | } |
692 | |
692 | |
693 | void |
|
|
694 | client::send_drawinfo (const char *msg, int flags) |
|
|
695 | { |
|
|
696 | send_msg (flags, "log", msg); |
|
|
697 | } |
|
|
698 | |
|
|
699 | /*********************************************************************** |
693 | /*********************************************************************** |
700 | * |
694 | * |
701 | * packet functions/utilities |
695 | * packet functions/utilities |
702 | * |
696 | * |
703 | **********************************************************************/ |
697 | **********************************************************************/ |