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.26 by root, Mon Mar 12 23:45:10 2007 UTC vs.
Revision 1.31 by root, Wed Mar 14 04:12:29 2007 UTC

198 * caching images. 198 * caching images.
199 */ 199 */
200void 200void
201SendFaceCmd (char *buf, int len, client *ns) 201SendFaceCmd (char *buf, int len, client *ns)
202{ 202{
203 uint16 facenum = atoi (buf); 203 ns->send_face (atoi (buf), 1);
204
205 if (facenum != 0)
206 esrv_send_face (ns, facenum, 1);
207} 204}
208 205
209// how lame 206// how lame
210static void print_facename (packet &sl, const facedata &d) 207static void print_facename (packet &sl, const facedata &d)
211{ 208{
239 * this is needed for the askface, in which we really do want to send the 236 * this is needed for the askface, in which we really do want to send the
240 * face (and askface is the only place that should be setting it). Otherwise, 237 * face (and askface is the only place that should be setting it). Otherwise,
241 * we look at the facecache, and if set, send the image name. 238 * we look at the facecache, and if set, send the image name.
242 */ 239 */
243void 240void
244esrv_send_face (client *ns, short face_num, int nocache) 241client::send_face (faceidx facenum, bool forced)
245{ 242{
246 if (face_num <= 0 || face_num >= faces.size ()) 243 // never send face 0. ever. it does not exist.
244 if (!facenum)
245 return;
246
247 const facedata *d = face_data (facenum, faceset);
248
249 if (!d)
247 { 250 {
248 LOG (llevError, "esrv_send_face (%d) out of bounds??\n", face_num); 251 LOG (llevError, "client::send_face (%d) out of bounds??\n", facenum);
249 return; 252 return;
250 } 253 }
251 254
252 const facedata *d = face_data (face_num, ns->faceset);
253
254 packet sl; 255 packet sl;
255 256
256 if (ns->facecache && !nocache) 257 if (facecache && !forced)
257 { 258 {
259 if (faces_sent[facenum])
260 return;
261
262 faces_sent[facenum] = true;
263
258 if (ns->force_face0) 264 if (force_face0)
259 sl << "face " << uint16 (face_num); 265 sl << "face " << uint16 (facenum);
260 else if (ns->image2) 266 else if (image2)
261 sl << "face2 " << uint16 (face_num) << uint8 (0) << uint32 (ns->force_bad_checksum ? gcfclient_checksum (d) : 0); 267 sl << "face2 " << uint16 (facenum) << uint8 (0) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0);
262 else 268 else
263 sl << "face1 " << uint16 (face_num) << uint32 (ns->force_bad_checksum ? gcfclient_checksum (d) : 0); 269 sl << "face1 " << uint16 (facenum) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0);
264 270
265 // how lame 271 // how lame
266 print_facename (sl, *d); 272 print_facename (sl, *d);
267
268 ns->send_packet (sl); 273 send_packet (sl);
274
275 faceinfo *f = face_info (facenum);
276 if (f->smooth && EMI_smooth)
277 {
278 send_face (f->smooth);
279
280 packet sl ("smooth");
281
282 sl << uint16 (facenum)
283 << uint16 (f->smooth);
284
285 send_packet (sl);
286 }
269 } 287 }
270 else 288 else
271 { 289 {
272 fprintf (stderr, "image %s %d\n", &faces [face_num].name, nocache);//D
273 sl << (ns->image2 ? "image2 " : "image ") 290 sl << (image2 ? "image2 " : "image ")
274 << uint32 (face_num); 291 << uint32 (facenum);
275 292
276 if (ns->image2) 293 if (image2)
277 sl << uint8 (0); 294 sl << uint8 (0);
278 295
279 sl << uint32 (d->data.size ()) 296 sl << uint32 (d->data.size ())
280 << data (d->data.data (), d->data.size ()); 297 << data (d->data.data (), d->data.size ());
281 298
282 ns->send_packet (sl); 299 send_packet (sl);
300 }
301}
302
303// send all faces of this object to the client
304// this uses more bandwidth initially, but makes
305// animations look much smoother, and every client
306// is supposed to do client-side caching anyways.
307void
308client::send_faces (object *ob)
309{
310 send_face (ob->face);
311
312 if (ob->animation_id)
283 } 313 {
314 animation &anim = animations [ob->animation_id];
284 315
285 ns->faces_sent[face_num] |= NS_FACESENT_FACE; 316 for (int i = 0; i < anim.num_animations; i++)
317 send_face (anim.faces [i]);
318 }
319}
320
321/**
322 * Need to send an animation sequence to the client.
323 * We will send appropriate face commands to the client if we haven't
324 * sent them the face yet (this can become quite costly in terms of
325 * how much we are sending - on the other hand, this should only happen
326 * when the player logs in and picks stuff up.
327 */
328void
329client::send_animation (short anim_num)
330{
331 /* Do some checking on the anim_num we got. Note that the animations
332 * are added in contigous order, so if the number is in the valid
333 * range, it must be a valid animation.
334 */
335 if (anim_num < 0 || anim_num > num_animations)
336 {
337 LOG (llevError, "esrv_send_anim (%d) out of bounds??\n", anim_num);
338 return;
339 }
340
341 packet sl ("anim");
342
343 sl << uint16 (anim_num)
344 << uint16 (0); /* flags - not used right now */
345
346 /* Build up the list of faces. Also, send any information (ie, the
347 * the face itself) down to the client.
348 */
349 for (int i = 0; i < animations[anim_num].num_animations; i++)
350 {
351 send_face (animations[anim_num].faces[i]);
352 sl << uint16 (animations[anim_num].faces[i]); /* flags - not used right now */
353 }
354
355 send_packet (sl);
356
357 anims_sent[anim_num] = 1;
286} 358}
287 359
288/** 360/**
289 * Sends the number of images, checksum of the face file, 361 * Sends the number of images, checksum of the face file,
290 * and the image_info file information. See the doc/Developers/protocol 362 * and the image_info file information. See the doc/Developers/protocol
291 * if you want further detail. 363 * if you want further detail.
292 */ 364 */
293
294void 365void
295send_image_info (client *ns, char *params) 366send_image_info (client *ns, char *params)
296{ 367{
297 packet sl; 368 packet sl;
298 369
337 408
338 sl.printf ("replyinfo image_sums %d %d ", start, stop); 409 sl.printf ("replyinfo image_sums %d %d ", start, stop);
339 410
340 for (int i = start; i <= stop && i < faces.size (); i++) 411 for (int i = start; i <= stop && i < faces.size (); i++)
341 { 412 {
342 ns->faces_sent[i] |= NS_FACESENT_FACE; 413 ns->faces_sent[i] = true;
343 414
344 const facedata *d = face_data (i, ns->faceset); 415 const facedata *d = face_data (i, ns->faceset);
345 416
346 if (sl.room () < 2 + 4 + 1 + d->data.size () + 1) 417 if (sl.room () < 2 + 4 + 1 + d->data.size () + 1)
347 break; 418 break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines