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 | * Copyright (©) 1992,2007 Frank Tore Johansen |
|
|
6 | * |
5 | * |
7 | * 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 |
8 | * 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 |
9 | * 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 |
10 | * option) any later version. |
9 | * option) any later version. |
… | |
… | |
232 | { |
231 | { |
233 | if (may_execute (pkt) || always_immediate (this, pkt, data, datalen)) |
232 | if (may_execute (pkt) || always_immediate (this, pkt, data, datalen)) |
234 | { |
233 | { |
235 | //TODO: only one format |
234 | //TODO: only one format |
236 | if (pkt->flags & PF_PLAYER) |
235 | if (pkt->flags & PF_PLAYER) |
|
|
236 | { |
237 | ((void (*)(char *, int, player *))pkt->cb)((char *)data, datalen, pl); |
237 | ((void (*)(char *, int, player *))pkt->cb)((char *)data, datalen, pl); |
|
|
238 | pl->need_updated_stats (); |
|
|
239 | } |
238 | else |
240 | else |
239 | ((void (*)(char *, int, client *))pkt->cb)((char *)data, datalen, this); |
241 | ((void (*)(char *, int, client *))pkt->cb)((char *)data, datalen, this); |
240 | } |
242 | } |
241 | else |
243 | else |
242 | send_packet_printf ("drawinfo %d ERROR: you cannot execute '%s' now.", NDI_RED | NDI_REPLY, pkt->name); |
244 | send_packet_printf ("drawinfo %d ERROR: you cannot execute '%s' now.", NDI_RED | NDI_REPLY, pkt->name); |
… | |
… | |
255 | pl && pl->ob ? &pl->ob->name : "[anonymous]"); |
257 | pl && pl->ob ? &pl->ob->name : "[anonymous]"); |
256 | destroy (); |
258 | destroy (); |
257 | return false; |
259 | return false; |
258 | } |
260 | } |
259 | |
261 | |
|
|
262 | uint8_t save_byte = inbuf [pkt_len]; // rather ugly |
260 | inbuf [pkt_len] = 0; /* Terminate buffer - useful for string data */ |
263 | inbuf [pkt_len] = 0; /* temporarily terminate buffer - useful for string data */ |
261 | |
264 | |
262 | /* First, break out beginning word. There are at least |
265 | /* First, break out beginning word. There are at least |
263 | * a few commands that do not have any paremeters. If |
266 | * a few commands that do not have any paremeters. If |
264 | * we get such a command, don't worry about trying |
267 | * we get such a command, don't worry about trying |
265 | * to break it up. |
268 | * to break it up. |
… | |
… | |
289 | goto next_packet; |
292 | goto next_packet; |
290 | } |
293 | } |
291 | |
294 | |
292 | // If we get here, we didn't find a valid command. |
295 | // If we get here, we didn't find a valid command. |
293 | send_packet_printf ("drawinfo %d ERROR: command '%s' not supported.", NDI_RED | NDI_REPLY, (char *)inbuf + 2); |
296 | send_packet_printf ("drawinfo %d ERROR: command '%s' not supported.", NDI_RED | NDI_REPLY, (char *)inbuf + 2); |
|
|
297 | |
294 | next_packet: |
298 | next_packet: |
|
|
299 | inbuf [pkt_len] = save_byte; // rather ugly |
295 | skip_packet (pkt_len); |
300 | skip_packet (pkt_len); |
296 | |
301 | |
297 | // input buffer has space again |
302 | // input buffer has space again |
298 | socket_ev.poll (socket_ev.poll () | EV_READ); |
303 | socket_ev.poll (socket_ev.poll () | EV_READ); |
299 | |
304 | |