--- deliantra/server/socket/image.C 2007/04/03 00:21:38 1.39 +++ deliantra/server/socket/image.C 2007/07/05 10:34:08 1.45 @@ -1,25 +1,24 @@ /* - * CrossFire, A Multiplayer game - * - * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team - * Copyright (C) 2001 Mark Wedel - * Copyright (C) 1992 Frank Tore Johansen - * - * This program is free software; you can redistribute it and/or modify + * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. + * + * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team + * Copyright (©) 2001,2007 Mark Wedel + * Copyright (©) 1992,2007 Frank Tore Johansen + * + * Crossfire TRT is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * The author can be reached via e-mail to + * along with this program. If not, see . + * + * The authors can be reached via e-mail to */ /** \file @@ -193,14 +192,52 @@ } /** - * Client has requested pixmap that it somehow missed getting. - * This will be called often if the client is - * caching images. + * client requested an image. send it rate-limited + * before flushing. */ void -SendFaceCmd (char *buf, int len, client *ns) +AskFaceCmd (char *buf, int len, client *ns) { - ns->send_image (atoi (buf)); + int idx = 0, pri = 0; + + sscanf (buf, "%d %d", &idx, &pri); + + const facedata *d = face_data (idx, ns->faceset); + + if (!d) + return; // doh + + client::ixsend ix; + + ix.pri = pri; + ix.idx = idx; + ix.ofs = d->data.size (); + + // this is (hopefully) a temporary fix around older cfplus versions not + // supporting interleaved transfers + ns->ixface.insert (ns->ixface.begin (), ix); + +#if 0 + // the by far most common case will be to insert + // right at the end, so no looping. + auto (i, ns->ixface.end ()); + for (; i != ns->ixface.begin (); ) + if (pri >= (--i)->pri) + break; + + ns->ixface.insert (i, ix); +#endif +} + +/** + * Tells client the picture it has to use + * to smooth a picture number given as argument. + */ +void +AskSmooth (char *buf, int len, client *ns) +{ + ns->send_face (atoi (buf)); + ns->flush_fx (); } // how lame @@ -281,17 +318,21 @@ print_facename (sl, *d); send_packet (sl); - faceinfo *f = face_info (facenum); - if (f->smooth && EMI_smooth) + if (EMI_smooth) { - send_face (f->smooth); + faceinfo *f = face_info (facenum); + + if (f->smooth) + { + send_face (f->smooth); - packet sl ("smooth"); + packet sl ("smooth"); - sl << uint16 (facenum) - << uint16 (f->smooth); + sl << uint16 (facenum) + << uint16 (f->smooth); - send_packet (sl); + send_packet (sl); + } } } @@ -299,7 +340,8 @@ { while (!fxface.empty ()) { - packet sl ("fx"); + packet fx ("fx"); + packet sx ("sx"); do { @@ -309,17 +351,29 @@ if (d) { - sl << ber32 (facenum) + fx << ber32 (facenum) << data8 (d->chksum, CHKSUM_SIZE); - faceinfo *f = face_info (facenum); - if (f->smooth && EMI_smooth) - sl << ber32 (f->smooth); + if (smoothing) + { + faceinfo *f = face_info (facenum); + + if (f->smooth) + { + send_face (f->smooth); + sx << ber32 (facenum) + << ber32 (f->smooth) + << ber32 (f->smoothlevel); + } + } } } - while (!fxface.empty () && sl.room () > CHKSUM_SIZE + 8 + 8); + while (!fxface.empty () + && fx.room () > ber32::size + CHKSUM_SIZE + 1 + && sx.room () > ber32::size * 3); - send_packet (sl); + send_packet (fx); + if (sx.length () > 3) send_packet (sx); } } @@ -332,13 +386,15 @@ const facedata *d = face_data (facenum, faceset); + faces_sent[facenum] = true; + if (!d) { LOG (llevError, "client::send_image (%d) out of bounds??\n", facenum); return; } - - faces_sent[facenum] = true; + + //TODO: check type here? if (force_image_newmap) force_newmap = true; @@ -389,7 +445,7 @@ * are added in contigous order, so if the number is in the valid * range, it must be a valid animation. */ - if (anim_num < 0 || anim_num > num_animations) + if (anim_num < 0 || anim_num >= animations.size ()) { LOG (llevError, "esrv_send_anim (%d) out of bounds??\n", anim_num); return;