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.66 by root, Tue Jan 3 11:23:42 2012 UTC vs.
Revision 1.74 by root, Sun Nov 11 18:21:21 2012 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001 Mark Wedel 5 * Copyright (©) 2001 Mark Wedel
6 * Copyright (©) 1992 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the Affero GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 20 * <http://www.gnu.org/licenses/>.
21 * 21 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 23 */
24 24
25/** \file 25/*
26 * Image related communication 26 * Image related communication
27 *
28 * \date 2003-12-02
29 * 27 *
30 * This file deals with the image related communication to the 28 * This file deals with the image related communication to the
31 * client. I've located all the functions in this file - this 29 * client. I've located all the functions in this file - this
32 * localizes it more, and means that we don't need to declare 30 * localizes it more, and means that we don't need to declare
33 * things like all the structures as globals. 31 * things like all the structures as globals.
51 49
52 sscanf (buf, "%d %d", &idx, &pri); 50 sscanf (buf, "%d %d", &idx, &pri);
53 51
54 //TODO: somehow fetch default priority from send_fx here 52 //TODO: somehow fetch default priority from send_fx here
55 53
56 const facedata *d = face_data (idx, ns->faceset); 54 const faceinfo *f = face_info (idx);
57 55
58 if (!d) 56 if (!f)
59 return; // doh 57 return; // doh
60 58
59 int set = ns->tileset;
60
61 if (!f->face [set].chksum_len)
62 set = 0;
63
64 /* cfperl_ix calls cf::face::ix which loads the data */
65 /* and then calls cf::client::send_ix to actually queue the ix */
66 cfperl_ix (ns, set, idx, pri);
67}
68
69void
70client::ix_send (faceidx idx, sint16 pri, SV *data_sv)
71{
72 STRLEN size;
73 char *data = SvPVbyte (data_sv, size);
61 client::ixsend ix; 74 ixsend ix;
62 75
63 ix.pri = pri; 76 ix.pri = pri;
64 ix.idx = idx; 77 ix.idx = idx;
65 ix.ofs = d->data.size (); 78 ix.ofs = size;
79 ix.data = (uint8 *)data;
80 ix.data_sv = SvREFCNT_inc (data_sv);
66 81
67 auto (pos, ns->ixface.end ()); 82 auto (pos, ixface.end ());
68 83
69 // the by far most common case will be to insert 84 // the by far most common case will be to insert
70 // near the end, so little looping. 85 // near the end, so little looping.
71 while (pos != ns->ixface.begin ()) 86 while (pos != ixface.begin ())
72 { 87 {
73 --pos; 88 --pos;
74 89
75 // sort within 2k bins, to slightly prefer smaller images 90 // sort within 2k bins, to slightly prefer smaller images
76 if (pri > pos->pri || (pri == pos->pri && (ix.ofs >> 11) <= (pos->ofs >> 11))) 91 if (pri > pos->pri || (pri == pos->pri && (ix.ofs >> 11) <= (pos->ofs >> 11)))
78 ++pos; 93 ++pos;
79 break; 94 break;
80 } 95 }
81 } 96 }
82 97
83 ns->ixface.insert (pos, ix); 98 ixface.insert (pos, ix);
84 99
85#if 0 100#if 0
86 for (auto (i, ns->ixface.begin ()); i != ns->ixface.end (); ++i) 101 for (auto (i, ixface.begin ()); i != ixface.end (); ++i)
87 fprintf (stderr, "<%d,%d> ", i->pri, i->ofs); 102 fprintf (stderr, "<%d,%d> ", i->pri, i->ofs);
88 fprintf (stderr, "\n"); 103 fprintf (stderr, "\n");
89#endif 104#endif
90} 105}
91 106
107void
108client::ix_pop ()
109{
110 ixsend &ix = ixface.back ();
111
112 SvREFCNT_dec (ix.data_sv);
113
114 ixface.pop_back ();
115}
116
92/** 117/**
93 * Sends a face to a client if they are in pixmap mode 118 * Sends a face offer (fx) to a client.
94 * nothing gets sent in bitmap mode.
95 * If nocache is true (nonzero), ignore the cache setting from the client - 119 * If nocache is true (nonzero), ignore the cache setting from the client -
96 * this is needed for the askface, in which we really do want to send the 120 * this is needed for the askface, in which we really do want to send the
97 * face (and askface is the only place that should be setting it). Otherwise, 121 * face (and askface is the only place that should be setting it). Otherwise,
98 * we look at the facecache, and if set, send the image name. 122 * we look at the facecache, and if set, send the image name.
99 */ 123 */
110 { 134 {
111 LOG (llevError | logBacktrace, "client::send_face (%d) out of bounds??\n", facenum); 135 LOG (llevError | logBacktrace, "client::send_face (%d) out of bounds??\n", facenum);
112 return; 136 return;
113 } 137 }
114 138
115 // refuse to send non-image faces 139 // refuse to send non-image faces unless requested
116 if (!fx_want [f->type]) 140 if (!fx_want [f->type])
117 return; 141 return;
118 142
119 if (faces_sent [facenum]) 143 if (faces_sent [facenum])
120 return; 144 return;
121 145
122 faces_sent[facenum] = true; 146 faces_sent [facenum] = true;
123 147
124 fxface.push_back (facenum); 148 fxface.push_back (facenum);
125} 149}
126 150
127void client::flush_fx () 151void client::flush_fx ()
144 168
145 fx << ber32 (0) 169 fx << ber32 (0)
146 << uint8 (1) << uint8 (type); 170 << uint8 (1) << uint8 (type);
147 } 171 }
148 172
149 const facedata *d = f->data (faceset); 173 const facedata *d = f->data (tileset);
150 174
151 fx << ber32 (facenum) 175 fx << ber32 (facenum)
152 << data8 (d->chksum, d->chksum_len); 176 << data8 (d->chksum, d->chksum_len);
153 177
154 if (smoothing) 178 if (smoothing)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines