… | |
… | |
157 | draw_client_map (pl); |
157 | draw_client_map (pl); |
158 | |
158 | |
159 | if (update_look) |
159 | if (update_look) |
160 | esrv_draw_look (pl); |
160 | esrv_draw_look (pl); |
161 | |
161 | |
162 | if (ixface.empty () && !partial_face_ofs) |
162 | if (ixface.empty ()) |
163 | { |
163 | { |
164 | // regularly send a new face when queue is empty |
164 | // regularly send a new face when queue is empty |
165 | if (bg_scrub && !--bg_scrub && enable_bg_scrub) |
165 | if (bg_scrub && !--bg_scrub && enable_bg_scrub) |
166 | while (scrub_idx < faces.size () - 1) |
166 | while (scrub_idx < faces.size () - 1) |
167 | { |
167 | { |
168 | ++scrub_idx; |
168 | ++scrub_idx; |
|
|
169 | |
169 | if (!faces_sent [scrub_idx]) |
170 | if (!faces_sent [scrub_idx]) |
170 | { |
171 | { |
171 | send_face (scrub_idx); |
172 | send_face (scrub_idx); |
172 | flush_fx (); |
173 | flush_fx (); |
173 | |
174 | |
… | |
… | |
193 | |
194 | |
194 | bg_scrub = BG_SCRUB_RATE; |
195 | bg_scrub = BG_SCRUB_RATE; |
195 | |
196 | |
196 | while (avail > 0) |
197 | while (avail > 0) |
197 | { |
198 | { |
198 | if (partial_face_ofs) |
199 | ixsend &ix = ixface.back (); |
|
|
200 | |
|
|
201 | if (facedata *d = face_data (ix.idx, faceset)) |
199 | { |
202 | { |
200 | if (facedata *d = face_data (partial_face, faceset)) |
203 | if (fxix) |
201 | { |
204 | { |
202 | // 9 bytes is enough for fx_FFFOOO, 40 leaves some room for image data |
205 | // 9 bytes is enough for fx_FFFOOO, 40 leaves some room for image data |
203 | int chunk = min (min (avail - 40, MAXSOCKBUF - 9), partial_face_ofs); |
206 | int chunk = min (min (avail - 40, MAXSOCKBUF - 9), ix.ofs); |
204 | |
207 | |
205 | if (chunk <= 0) |
208 | if (chunk <= 0) |
206 | break; |
209 | break; |
207 | |
210 | |
208 | partial_face_ofs -= chunk; |
211 | ix.ofs -= chunk; |
209 | |
212 | |
210 | packet sl ("ix"); |
213 | packet sl ("ix"); |
211 | |
214 | |
212 | sl << ber32 (partial_face) |
215 | sl << ber32 (ix.idx) |
213 | << ber32 (partial_face_ofs) |
216 | << ber32 (ix.ofs) |
214 | << data (d->data.data () + partial_face_ofs, chunk); |
217 | << data (d->data.data () + ix.ofs, chunk); |
215 | |
218 | |
216 | send_packet (sl); |
219 | send_packet (sl); |
217 | } |
220 | } |
218 | else |
221 | else |
219 | partial_face_ofs = 0; |
|
|
220 | } |
|
|
221 | else if (!ixface.empty ()) |
|
|
222 | { |
|
|
223 | // use a lifo to send most recently requested images |
|
|
224 | faceidx facenum = ixface.back (); |
|
|
225 | ixface.pop_back (); |
|
|
226 | |
|
|
227 | if (fxix) |
|
|
228 | { |
222 | { |
229 | if (facedata *d = face_data (facenum, faceset)) |
223 | send_image (ix.idx); |
230 | { |
224 | ix.ofs = 0; |
231 | partial_face = facenum; |
|
|
232 | partial_face_ofs = d->data.size (); |
|
|
233 | } |
|
|
234 | } |
225 | } |
235 | else |
|
|
236 | send_image (facenum); |
|
|
237 | } |
226 | } |
238 | else |
227 | else |
239 | break; |
228 | ix.ofs = 0; |
240 | |
229 | |
241 | int consumed = ol - outputbuffer_len (); |
230 | int consumed = ol - outputbuffer_len (); |
|
|
231 | |
242 | avail -= consumed; |
232 | avail -= consumed; |
243 | rate_avail -= consumed; |
233 | rate_avail -= consumed; |
|
|
234 | |
|
|
235 | ol = outputbuffer_len (); |
|
|
236 | |
|
|
237 | if (!ix.ofs) |
|
|
238 | { |
|
|
239 | ixface.pop_back (); |
|
|
240 | if (ixface.empty ()) |
|
|
241 | break; |
|
|
242 | } |
244 | } |
243 | } |
245 | } |
244 | } |
246 | } |
245 | } |
247 | |
246 | |