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.61 by root, Wed Nov 4 13:46:37 2009 UTC

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
241send_image_info (client *ns, char *params)
242{
243 packet sl;
244
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}
252
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
263send_image_sums (client *ns, char *params)
264{
265 int start, stop;
266 char *cp;
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}
321

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines