ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/image.C
(Generate patch)

Comparing deliantra/server/socket/image.C (file contents):
Revision 1.60 by root, Mon Oct 12 14:00:59 2009 UTC vs.
Revision 1.67 by root, Tue Jan 3 11:25:37 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines