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.30 by root, Wed Mar 14 01:19:10 2007 UTC vs.
Revision 1.39 by root, Tue Apr 3 00:21:38 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 ns->send_face (atoi (buf), 1); 203 ns->send_image (atoi (buf));
204} 204}
205 205
206// how lame 206// how lame
207static void print_facename (packet &sl, const facedata &d) 207static void print_facename (packet &sl, const facedata &d)
208{ 208{
209 for (int i = 0; i < CHKSUM_SIZE; ++i) 209 for (int i = 0; i < CHKSUM_SIZE; ++i)
210 sl.printf ("%02x", d.chksum [i]); 210 sl.printf ("%02x", d.chksum [i]);
211} 211}
212 212
213// gcfclient uses the server-provided checksum for comparison, 213// gcfclient uses the server-provided checksum for comparison, but always
214// but always wrotes a broken checksum to its cache file, so we 214// writes a broken checksum to its cache file, so we have to provide
215// have to provide gcfclient with a useless checksum just to 215// gcfclient with the same broken (and useless) checksum just to have it
216// have to cache the image despite its bugs. 216// cache the image despite its bugs.
217static uint32 gcfclient_checksum (const facedata *d) 217static uint32 gcfclient_checksum (const facedata *d)
218{ 218{
219 uint32 csum = 0; 219 uint32 csum = 0;
220 220
221 for (std::string::const_iterator i = d->data.begin (); 221 for (std::string::const_iterator i = d->data.begin ();
236 * 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
237 * 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,
238 * 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.
239 */ 239 */
240void 240void
241client::send_face (faceidx facenum, bool forced) 241client::send_face (faceidx facenum)
242{ 242{
243 // never send face 0. ever. it does not exist. 243 // never send face 0. ever. it does not exist.
244 if (!facenum) 244 if (!facenum)
245 return; 245 return;
246 246
250 { 250 {
251 LOG (llevError, "client::send_face (%d) out of bounds??\n", facenum); 251 LOG (llevError, "client::send_face (%d) out of bounds??\n", facenum);
252 return; 252 return;
253 } 253 }
254 254
255 if (faces_sent[facenum])
256 return;
257
258 faces_sent[facenum] = true;
259
260 // if for some reason we let a client without face caching connect,
261 // we better support that decision here and implement it.
262 if (!facecache)
263 return send_image (facenum);
264
265 if (fxix)
266 {
267 fxface.push_back (facenum);
268 return;
269 }
270
255 packet sl; 271 packet sl;
256 272
257 if (facecache && !forced) 273 if (force_face0)
258 { 274 sl << "face " << uint16 (facenum);
259 if (faces_sent[facenum]) 275 else if (image2)
260 return; 276 sl << "face2 " << uint16 (facenum) << uint8 (0) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0);
277 else
278 sl << "face1 " << uint16 (facenum) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0);
261 279
262 faces_sent[facenum] = true; 280 // how lame
281 print_facename (sl, *d);
282 send_packet (sl);
263 283
264 faceinfo *f = face_info (facenum); 284 faceinfo *f = face_info (facenum);
265 if (f->smooth && EMI_smooth) 285 if (f->smooth && EMI_smooth)
286 {
287 send_face (f->smooth);
288
289 packet sl ("smooth");
290
291 sl << uint16 (facenum)
292 << uint16 (f->smooth);
293
294 send_packet (sl);
295 }
296}
297
298void client::flush_fx ()
299{
300 while (!fxface.empty ())
301 {
302 packet sl ("fx");
303
304 do
266 { 305 {
267 send_face (f->smooth); 306 faceidx facenum = fxface.back (); fxface.pop_back ();
268 307
269 packet sl ("smooth"); 308 const facedata *d = face_data (facenum, faceset);
270 309
310 if (d)
311 {
271 sl << uint16 (facenum) 312 sl << ber32 (facenum)
313 << data8 (d->chksum, CHKSUM_SIZE);
314
315 faceinfo *f = face_info (facenum);
316 if (f->smooth && EMI_smooth)
272 << uint16 (f->smooth); 317 sl << ber32 (f->smooth);
273 318 }
274 send_packet (sl);
275 } 319 }
320 while (!fxface.empty () && sl.room () > CHKSUM_SIZE + 8 + 8);
276 321
277 if (force_face0) 322 send_packet (sl);
278 sl << "face " << uint16 (facenum);
279 else if (image2)
280 sl << "face2 " << uint16 (facenum) << uint8 (0) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0);
281 else
282 sl << "face1 " << uint16 (facenum) << uint32 (force_bad_checksum ? gcfclient_checksum (d) : 0);
283
284 // how lame
285 print_facename (sl, *d);
286 }
287 else
288 { 323 }
324}
325
326void
327client::send_image (faceidx facenum)
328{
329 // never send face 0. ever. it does not exist.
330 if (!facenum)
331 return;
332
333 const facedata *d = face_data (facenum, faceset);
334
335 if (!d)
336 {
337 LOG (llevError, "client::send_image (%d) out of bounds??\n", facenum);
338 return;
339 }
340
341 faces_sent[facenum] = true;
342
343 if (force_image_newmap)
344 force_newmap = true;
345
346 packet sl;
347
289 sl << (image2 ? "image2 " : "image ") 348 sl << (image2 ? "image2 " : "image ")
290 << uint32 (facenum); 349 << uint32 (facenum);
291 350
292 if (image2) 351 if (image2)
293 sl << uint8 (0); 352 sl << uint8 (0);
294 353
295 sl << uint32 (d->data.size ()) 354 sl << uint32 (d->data.size ())
296 << data (d->data.data (), d->data.size ()); 355 << data (d->data.data (), d->data.size ());
297 }
298 356
299 send_packet (sl); 357 send_packet (sl);
300} 358}
301 359
302// send all faces of this object to the client 360// send all faces of this object to the client

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines