--- deliantra/server/socket/image.C 2007/05/28 21:22:26 1.42
+++ deliantra/server/socket/image.C 2007/07/06 03:52:51 1.46
@@ -1,23 +1,22 @@
/*
- * This file is part of Crossfire TRT, the Multiplayer Online Role Playing Game.
+ * 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 (at your option)
- * any later version.
+ * 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 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 GNU General Public License
- * for more details.
+ * 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
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along
- * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*
* The authors can be reached via e-mail to
*/
@@ -193,14 +192,71 @@
}
/**
- * 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 ();
+
+ auto (pos, ns->ixface.end ());
+
+ if (ns->fxix < 2)
+ {
+ // gcfclient does not support prioritising, older cfplus versions
+ // do not support interleaved transfers.
+ if (!ns->ixface.empty ())
+ pos = ns->ixface.end () - 1;
+ }
+ else
+ {
+ // the by far most common case will be to insert
+ // near the end, so little looping.
+ while (pos != ns->ixface.begin ())
+ {
+ --pos;
+
+ // sort within 2k bins, to slightly prefer smaller images
+ if (pri > pos->pri || (pri == pos->pri && (ix.ofs >> 11) <= (pos->ofs >> 11)))
+ {
+ ++pos;
+ break;
+ }
+ }
+ }
+
+ ns->ixface.insert (pos, ix);
+
+#if 0
+ for (auto (i, ns->ixface.begin ()); i != ns->ixface.end (); ++i)
+ fprintf (stderr, "<%d,%d> ", i->pri, i->ofs);
+ fprintf (stderr, "\n");
+#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
@@ -349,13 +405,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;