… | |
… | |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 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 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * 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, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
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 Affero GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | /** \file |
25 | /** \file |
… | |
… | |
146 | } |
147 | } |
147 | |
148 | |
148 | const facedata *d = f->data (faceset); |
149 | const facedata *d = f->data (faceset); |
149 | |
150 | |
150 | fx << ber32 (facenum) |
151 | fx << ber32 (facenum) |
151 | << data8 (d->chksum, CHKSUM_SIZE); |
152 | << data8 (d->chksum, d->chksum_len); |
152 | |
153 | |
153 | if (smoothing) |
154 | if (smoothing) |
154 | { |
155 | { |
155 | faceinfo *f = face_info (facenum); |
156 | faceinfo *f = face_info (facenum); |
156 | |
157 | |
… | |
… | |
164 | } |
165 | } |
165 | } |
166 | } |
166 | } |
167 | } |
167 | } |
168 | } |
168 | while (!fxface.empty () |
169 | while (!fxface.empty () |
169 | && fx.room () > ber32::size + CHKSUM_SIZE + 1 + 3 /* type switch */ |
170 | && fx.room () > ber32::size + CHKSUM_MAXLEN + 1 + 3 /* type switch */ |
170 | && sx.room () > ber32::size * 3); |
171 | && sx.room () > ber32::size * 3); |
171 | |
172 | |
172 | send_packet (fx); |
173 | send_packet (fx); |
173 | if (sx.length () > 3) send_packet (sx); |
174 | if (sx.length () > 3) send_packet (sx); |
174 | } |
175 | } |
… | |
… | |
201 | */ |
202 | */ |
202 | void |
203 | void |
203 | client::send_animation (short anim_num) |
204 | client::send_animation (short anim_num) |
204 | { |
205 | { |
205 | /* Do some checking on the anim_num we got. Note that the animations |
206 | /* Do some checking on the anim_num we got. Note that the animations |
206 | * are added in contigous order, so if the number is in the valid |
207 | * are added in contiguous order, so if the number is in the valid |
207 | * range, it must be a valid animation. |
208 | * range, it must be a valid animation. |
208 | */ |
209 | */ |
209 | if (anim_num < 0 || anim_num >= animations.size ()) |
210 | if (anim_num < 0 || anim_num >= animations.size ()) |
210 | { |
211 | { |
211 | LOG (llevError, "esrv_send_anim (%d) out of bounds??\n", anim_num); |
212 | LOG (llevError, "esrv_send_anim (%d) out of bounds??\n", anim_num); |
… | |
… | |
221 | * the face itself) down to the client. |
222 | * the face itself) down to the client. |
222 | */ |
223 | */ |
223 | for (int i = 0; i < animations[anim_num].num_animations; i++) |
224 | for (int i = 0; i < animations[anim_num].num_animations; i++) |
224 | { |
225 | { |
225 | send_face (animations[anim_num].faces[i], -20); |
226 | send_face (animations[anim_num].faces[i], -20); |
226 | sl << uint16 (animations[anim_num].faces[i]); /* flags - not used right now */ |
227 | sl << uint16 (animations[anim_num].faces[i]); |
227 | } |
228 | } |
228 | |
229 | |
229 | send_packet (sl); |
230 | send_packet (sl); |
230 | |
231 | |
231 | anims_sent[anim_num] = 1; |
232 | anims_sent[anim_num] = 1; |
232 | } |
233 | } |
233 | |
234 | |
234 | /** |
|
|
235 | * Sends the number of images, checksum of the face file, |
|
|
236 | * and the image_info file information. See the doc/Developers/protocol |
|
|
237 | * if you want further detail. |
|
|
238 | */ |
|
|
239 | void |
|
|
240 | send_image_info (client *ns, char *params) |
|
|
241 | { |
|
|
242 | packet sl; |
|
|
243 | |
|
|
244 | //TODO: second parameter is a checksum, but it makes no sense in this current framework |
|
|
245 | sl.printf ("replyinfo image_info\n%d\n%u\n", MAX_FACES, 0); |
|
|
246 | |
|
|
247 | sl << "0:base:standard:0:32x32:none:The old 32x32 faceset.\n"; |
|
|
248 | |
|
|
249 | ns->send_packet (sl); |
|
|
250 | } |
|
|
251 | |
|
|
252 | /** |
|
|
253 | * Sends requested face information. |
|
|
254 | * \param ns socket to send to |
|
|
255 | * \param params contains first and last index of face |
|
|
256 | * |
|
|
257 | * For each image in [start..stop] sends |
|
|
258 | * - checksum |
|
|
259 | * - name |
|
|
260 | */ |
|
|
261 | void |
|
|
262 | send_image_sums (client *ns, char *params) |
|
|
263 | { |
|
|
264 | int start, stop; |
|
|
265 | char *cp; |
|
|
266 | |
|
|
267 | packet sl; |
|
|
268 | |
|
|
269 | start = atoi (params); |
|
|
270 | for (cp = params; *cp != '\0'; cp++) |
|
|
271 | if (*cp == ' ') |
|
|
272 | break; |
|
|
273 | |
|
|
274 | stop = atoi (cp); |
|
|
275 | if (stop < start || *cp == '\0' || (stop - start) > 1000 || stop >= MAX_FACES) |
|
|
276 | { |
|
|
277 | sl.printf ("replyinfo image_sums %d %d", start, stop); |
|
|
278 | ns->send_packet (sl); |
|
|
279 | sl.reset (); |
|
|
280 | return; |
|
|
281 | } |
|
|
282 | |
|
|
283 | sl.printf ("replyinfo image_sums %d %d ", start, stop); |
|
|
284 | |
|
|
285 | for (int i = start; i <= stop && i < faces.size (); i++) |
|
|
286 | if (const faceinfo *f = face_info (i)) |
|
|
287 | if (ns->fx_want [f->type]) |
|
|
288 | { |
|
|
289 | ns->faces_sent[i] = true; |
|
|
290 | |
|
|
291 | const facedata *d = f->data (ns->faceset); |
|
|
292 | |
|
|
293 | if (sl.room () < 2 + 4 + 1 + d->data.size () + 1) |
|
|
294 | break; |
|
|
295 | |
|
|
296 | sl << uint16 (i) |
|
|
297 | << uint32 (0) // checksum |
|
|
298 | << uint8 (ns->faceset); |
|
|
299 | |
|
|
300 | for (int i = 0; i < CHKSUM_SIZE; ++i) |
|
|
301 | sl.printf ("%02x", d->chksum [i]); |
|
|
302 | |
|
|
303 | sl << uint8 (0); |
|
|
304 | } |
|
|
305 | |
|
|
306 | /* It would make more sense to catch this pre-emptively in the code above. |
|
|
307 | * however, if this really happens, we probably just want to cut down the |
|
|
308 | * size to less than 1000, since that is what we claim the protocol would |
|
|
309 | * support. |
|
|
310 | */ |
|
|
311 | //TODO: taken care of above, should simply abort or make sure the above code is correct |
|
|
312 | if (sl.length () > MAXSOCKBUF) |
|
|
313 | { |
|
|
314 | LOG (llevError, "send_image_send: buffer overrun, %d > %d\n", sl.length (), MAXSOCKBUF); |
|
|
315 | abort (); |
|
|
316 | } |
|
|
317 | |
|
|
318 | ns->send_packet (sl); |
|
|
319 | } |
|
|
320 | |
|
|