1 | /* |
1 | /* |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001,2007 Mark Wedel |
5 | * Copyright (©) 2001,2007 Mark Wedel |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Crossfire TRT is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
… | |
… | |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
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, see <http://www.gnu.org/licenses/>. |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * |
20 | * |
21 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
22 | */ |
23 | |
23 | |
24 | /** \file |
24 | /** \file |
25 | * Image related communication |
25 | * Image related communication |
26 | * |
26 | * |
… | |
… | |
67 | { |
67 | { |
68 | int idx = 0, pri = 0; |
68 | int idx = 0, pri = 0; |
69 | |
69 | |
70 | sscanf (buf, "%d %d", &idx, &pri); |
70 | sscanf (buf, "%d %d", &idx, &pri); |
71 | |
71 | |
|
|
72 | //TODO: somehow fetch default priority from send_fx here |
|
|
73 | |
72 | const facedata *d = face_data (idx, ns->faceset); |
74 | const facedata *d = face_data (idx, ns->faceset); |
73 | |
75 | |
74 | if (!d) |
76 | if (!d) |
75 | return; // doh |
77 | return; // doh |
76 | |
78 | |
… | |
… | |
169 | |
171 | |
170 | faceinfo *f = face_info (facenum); |
172 | faceinfo *f = face_info (facenum); |
171 | |
173 | |
172 | if (!f) |
174 | if (!f) |
173 | { |
175 | { |
174 | LOG (llevError, "client::send_face (%d) out of bounds??\n", facenum); |
176 | LOG (llevError | logBacktrace, "client::send_face (%d) out of bounds??\n", facenum); |
175 | return; |
177 | return; |
176 | } |
178 | } |
177 | |
179 | |
178 | // refuse to send non-image faces |
180 | // refuse to send non-image faces |
179 | if (!fx_want [f->type]) |
181 | if (!fx_want [f->type]) |
… | |
… | |
292 | { |
294 | { |
293 | LOG (llevError, "client::send_image (%d) out of bounds??\n", facenum); |
295 | LOG (llevError, "client::send_image (%d) out of bounds??\n", facenum); |
294 | return; |
296 | return; |
295 | } |
297 | } |
296 | |
298 | |
297 | //TODO: check type here? |
|
|
298 | |
|
|
299 | if (force_image_newmap) |
299 | if (force_image_newmap) |
300 | force_newmap = true; |
300 | force_newmap = true; |
301 | |
301 | |
302 | packet sl; |
302 | packet sl; |
303 | |
303 | |
… | |
… | |
420 | } |
420 | } |
421 | |
421 | |
422 | sl.printf ("replyinfo image_sums %d %d ", start, stop); |
422 | sl.printf ("replyinfo image_sums %d %d ", start, stop); |
423 | |
423 | |
424 | for (int i = start; i <= stop && i < faces.size (); i++) |
424 | for (int i = start; i <= stop && i < faces.size (); i++) |
425 | { |
425 | if (const faceinfo *f = face_info (i)) |
|
|
426 | if (ns->fx_want [f->type]) |
|
|
427 | { |
426 | ns->faces_sent[i] = true; |
428 | ns->faces_sent[i] = true; |
427 | |
429 | |
428 | const facedata *d = face_data (i, ns->faceset); |
430 | const facedata *d = f->data (ns->faceset); |
429 | |
431 | |
430 | if (sl.room () < 2 + 4 + 1 + d->data.size () + 1) |
432 | if (sl.room () < 2 + 4 + 1 + d->data.size () + 1) |
431 | break; |
433 | break; |
432 | |
434 | |
433 | sl << uint16 (i) |
435 | sl << uint16 (i) |
434 | << uint32 (0) // checksum |
436 | << uint32 (0) // checksum |
435 | << uint8 (ns->faceset); |
437 | << uint8 (ns->faceset); |
436 | |
438 | |
437 | print_facename (sl, *d); sl << uint8 (0); |
439 | print_facename (sl, *d); sl << uint8 (0); |
438 | } |
440 | } |
439 | |
441 | |
440 | /* It would make more sense to catch this pre-emptively in the code above. |
442 | /* It would make more sense to catch this pre-emptively in the code above. |
441 | * however, if this really happens, we probably just want to cut down the |
443 | * however, if this really happens, we probably just want to cut down the |
442 | * size to less than 1000, since that is what we claim the protocol would |
444 | * size to less than 1000, since that is what we claim the protocol would |
443 | * support. |
445 | * support. |
444 | */ |
446 | */ |
445 | //TODO: taken care of above, should simply abort or make sure the above code is correct |
447 | //TODO: taken care of above, should simply abort or make sure the above code is correct |
446 | if (sl.length () >= MAXSOCKBUF) |
448 | if (sl.length () > MAXSOCKBUF) |
447 | { |
449 | { |
448 | LOG (llevError, "send_image_send: buffer overrun, %d > %d\n", sl.length (), MAXSOCKBUF); |
450 | LOG (llevError, "send_image_send: buffer overrun, %d > %d\n", sl.length (), MAXSOCKBUF); |
449 | abort (); |
451 | abort (); |
450 | } |
452 | } |
451 | |
453 | |