… | |
… | |
199 | { |
199 | { |
200 | object *tmp, *last; |
200 | object *tmp, *last; |
201 | int got_one = 0, start_look = 0, end_look = 0; |
201 | int got_one = 0, start_look = 0, end_look = 0; |
202 | char buf[MAX_BUF]; |
202 | char buf[MAX_BUF]; |
203 | |
203 | |
204 | if (!pl->contr->socket.update_look) |
204 | if (!pl->contr->socket->update_look) |
205 | { |
205 | { |
206 | LOG (llevDebug, "esrv_draw_look called when update_look was not set\n"); |
206 | LOG (llevDebug, "esrv_draw_look called when update_look was not set\n"); |
207 | return; |
207 | return; |
208 | } |
208 | } |
209 | else |
209 | else |
210 | pl->contr->socket.update_look = 0; |
210 | pl->contr->socket->update_look = 0; |
211 | |
211 | |
212 | if (QUERY_FLAG (pl, FLAG_REMOVED) |
212 | if (QUERY_FLAG (pl, FLAG_REMOVED) |
213 | || !pl->map |
213 | || !pl->map |
214 | || pl->map->in_memory != MAP_IN_MEMORY |
214 | || pl->map->in_memory != MAP_IN_MEMORY |
215 | || out_of_map (pl->map, pl->x, pl->y)) |
215 | || out_of_map (pl->map, pl->x, pl->y)) |
… | |
… | |
218 | for (tmp = get_map_ob (pl->map, pl->x, pl->y); tmp && tmp->above; tmp = tmp->above) |
218 | for (tmp = get_map_ob (pl->map, pl->x, pl->y); tmp && tmp->above; tmp = tmp->above) |
219 | ; |
219 | ; |
220 | |
220 | |
221 | packet sl; |
221 | packet sl; |
222 | |
222 | |
223 | pl->contr->socket.send_packet ("delinv 0"); |
223 | pl->contr->socket->send_packet ("delinv 0"); |
224 | |
224 | |
225 | sl.printf ("item%d ", pl->contr->socket.itemcmd); |
225 | sl.printf ("item%d ", pl->contr->socket->itemcmd); |
226 | |
226 | |
227 | sl << uint32 (0); |
227 | sl << uint32 (0); |
228 | |
228 | |
229 | if (!(pl->contr->socket.faces_sent[empty_face->number] & NS_FACESENT_FACE)) |
229 | if (!(pl->contr->socket->faces_sent[empty_face->number] & NS_FACESENT_FACE)) |
230 | esrv_send_face (&pl->contr->socket, empty_face->number, 0); |
230 | esrv_send_face (pl->contr->socket, empty_face->number, 0); |
231 | |
231 | |
232 | if (pl->contr->socket.look_position) |
232 | if (pl->contr->socket->look_position) |
233 | { |
233 | { |
|
|
234 | char buf[80]; |
|
|
235 | snprintf (buf, 80, "Apply this to see %d previous items", NUM_LOOK_OBJECTS); |
|
|
236 | |
234 | sl << uint32 (0x80000000 | (pl->contr->socket.look_position - NUM_LOOK_OBJECTS)) |
237 | sl << uint32 (0x80000000 | (pl->contr->socket->look_position - NUM_LOOK_OBJECTS)) |
235 | << uint32 (0) |
238 | << uint32 (0) |
236 | << sint32 (-1) |
239 | << sint32 (-1) |
237 | << uint32 (empty_face->number); |
240 | << uint32 (empty_face->number) |
238 | |
241 | << data8 (buf) |
239 | sl.printf ("Click here to see %d previous items", NUM_LOOK_OBJECTS); |
|
|
240 | |
|
|
241 | sl << uint16 (0) |
242 | << uint16 (0) |
242 | << uint8 (0) |
243 | << uint8 (0) |
243 | << uint32 (0); |
244 | << uint32 (0); |
244 | |
245 | |
245 | if (pl->contr->socket.itemcmd == 2) |
246 | if (pl->contr->socket->itemcmd == 2) |
246 | sl << uint16 (0); |
247 | sl << uint16 (0); |
247 | } |
248 | } |
248 | |
249 | |
249 | for (last = NULL; tmp != last; tmp = tmp->below) |
250 | for (last = NULL; tmp != last; tmp = tmp->below) |
250 | { |
251 | { |
… | |
… | |
257 | last = last->below; |
258 | last = last->below; |
258 | } |
259 | } |
259 | |
260 | |
260 | if (LOOK_OBJ (tmp)) |
261 | if (LOOK_OBJ (tmp)) |
261 | { |
262 | { |
262 | if (++start_look < pl->contr->socket.look_position) |
263 | if (++start_look < pl->contr->socket->look_position) |
263 | continue; |
264 | continue; |
264 | |
265 | |
265 | end_look++; |
266 | end_look++; |
266 | |
267 | |
267 | if (end_look > NUM_LOOK_OBJECTS) |
268 | if (end_look > NUM_LOOK_OBJECTS) |
268 | { |
269 | { |
269 | /* What we basically do is make a 'fake' object - when the user applies it, |
270 | /* What we basically do is make a 'fake' object - when the user applies it, |
270 | * we notice the special tag the object has, and act accordingly. |
271 | * we notice the special tag the object has, and act accordingly. |
271 | */ |
272 | */ |
272 | sl << uint32 (0x80000000 | (pl->contr->socket.look_position + NUM_LOOK_OBJECTS)) |
273 | sl << uint32 (0x80000000 | (pl->contr->socket->look_position + NUM_LOOK_OBJECTS)) |
273 | << uint32 (0) |
274 | << uint32 (0) |
274 | << uint32 ((uint32) - 1) |
275 | << uint32 ((uint32) - 1) |
275 | << uint32 (empty_face->number); |
276 | << uint32 (empty_face->number) |
276 | |
277 | << data8 ("Apply this to see next group of items") |
277 | sl.printf ("Click here to see next group of items"); |
|
|
278 | |
|
|
279 | sl << uint16 (0) |
278 | << uint16 (0) |
280 | << uint8 (0) |
279 | << uint8 (0) |
281 | << uint32 (0); |
280 | << uint32 (0); |
282 | |
281 | |
283 | if (pl->contr->socket.itemcmd == 2) |
282 | if (pl->contr->socket->itemcmd == 2) |
284 | sl << uint16 (0); |
283 | sl << uint16 (0); |
285 | |
284 | |
286 | break; |
285 | break; |
287 | } |
286 | } |
288 | |
287 | |
289 | if (tmp->head) |
288 | if (tmp->head) |
290 | head = tmp->head; |
289 | head = tmp->head; |
291 | else |
290 | else |
292 | head = tmp; |
291 | head = tmp; |
293 | |
292 | |
294 | add_object_to_socklist (pl->contr->socket, sl, head); |
293 | add_object_to_socklist (*pl->contr->socket, sl, head); |
295 | got_one++; |
294 | got_one++; |
296 | |
295 | |
297 | if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN)) |
296 | if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN)) |
298 | { |
297 | { |
299 | Send_With_Handling (&pl->contr->socket, &sl); |
298 | pl->contr->socket->send_packet (sl); |
300 | |
299 | |
301 | sl.reset (); |
300 | sl.reset (); |
302 | sl.printf ("item%d ", pl->contr->socket.itemcmd); |
301 | sl.printf ("item%d ", pl->contr->socket->itemcmd); |
303 | sl << uint32 (0); |
302 | sl << uint32 (0); |
304 | got_one = 0; |
303 | got_one = 0; |
305 | } |
304 | } |
306 | } /* If LOOK_OBJ() */ |
305 | } /* If LOOK_OBJ() */ |
307 | } |
306 | } |
308 | |
307 | |
309 | if (got_one) |
308 | if (got_one) |
310 | Send_With_Handling (&pl->contr->socket, &sl); |
309 | pl->contr->socket->send_packet (sl); |
311 | |
310 | |
312 | } |
311 | } |
313 | |
312 | |
314 | /** |
313 | /** |
315 | * Sends whole inventory. |
314 | * Sends whole inventory. |
… | |
… | |
321 | int got_one = 0; |
320 | int got_one = 0; |
322 | |
321 | |
323 | packet sl; |
322 | packet sl; |
324 | |
323 | |
325 | sl.printf ("delinv %d", op->count); |
324 | sl.printf ("delinv %d", op->count); |
326 | Send_With_Handling (&pl->contr->socket, &sl); |
325 | pl->contr->socket->send_packet (sl); |
327 | |
326 | |
328 | sl.reset (); |
327 | sl.reset (); |
329 | sl.printf ("item%d ", pl->contr->socket.itemcmd); |
328 | sl.printf ("item%d ", pl->contr->socket->itemcmd); |
330 | |
329 | |
331 | sl << uint32 (op->count); |
330 | sl << uint32 (op->count); |
332 | |
331 | |
333 | for (tmp = op->inv; tmp; tmp = tmp->below) |
332 | for (tmp = op->inv; tmp; tmp = tmp->below) |
334 | { |
333 | { |
… | |
… | |
339 | else |
338 | else |
340 | head = tmp; |
339 | head = tmp; |
341 | |
340 | |
342 | if (LOOK_OBJ (head)) |
341 | if (LOOK_OBJ (head)) |
343 | { |
342 | { |
344 | add_object_to_socklist (pl->contr->socket, sl, head); |
343 | add_object_to_socklist (*pl->contr->socket, sl, head); |
345 | |
344 | |
346 | got_one++; |
345 | got_one++; |
347 | |
346 | |
348 | /* IT is possible for players to accumulate a huge amount of |
347 | /* IT is possible for players to accumulate a huge amount of |
349 | * items (especially with some of the bags out there) to |
348 | * items (especially with some of the bags out there) to |
350 | * overflow the buffer. IF so, send multiple item commands. |
349 | * overflow the buffer. IF so, send multiple item commands. |
351 | */ |
350 | */ |
352 | if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN)) |
351 | if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN)) |
353 | { |
352 | { |
354 | Send_With_Handling (&pl->contr->socket, &sl); |
353 | pl->contr->socket->send_packet (sl); |
355 | |
354 | |
356 | sl.reset (); |
355 | sl.reset (); |
357 | sl.printf ("item%d ", pl->contr->socket.itemcmd); |
356 | sl.printf ("item%d ", pl->contr->socket->itemcmd); |
358 | sl << uint32 (op->count); |
357 | sl << uint32 (op->count); |
359 | got_one = 0; |
358 | got_one = 0; |
360 | } |
359 | } |
361 | } /* If LOOK_OBJ() */ |
360 | } /* If LOOK_OBJ() */ |
362 | } |
361 | } |
363 | |
362 | |
364 | if (got_one) |
363 | if (got_one) |
365 | Send_With_Handling (&pl->contr->socket, &sl); |
364 | pl->contr->socket->send_packet (sl); |
366 | |
365 | |
367 | } |
366 | } |
368 | |
367 | |
369 | /** |
368 | /** |
370 | * Updates object *op for player *pl. |
369 | * Updates object *op for player *pl. |
… | |
… | |
423 | op->contr->last_weight = weight; |
422 | op->contr->last_weight = weight; |
424 | } |
423 | } |
425 | |
424 | |
426 | if (flags & UPD_FACE) |
425 | if (flags & UPD_FACE) |
427 | { |
426 | { |
428 | if (!(pl->contr->socket.faces_sent[op->face->number] & NS_FACESENT_FACE)) |
427 | if (!(pl->contr->socket->faces_sent[op->face->number] & NS_FACESENT_FACE)) |
429 | esrv_send_face (&pl->contr->socket, op->face->number, 0); |
428 | esrv_send_face (pl->contr->socket, op->face->number, 0); |
430 | |
429 | |
431 | sl << uint32 (op->face->number); |
430 | sl << uint32 (op->face->number); |
432 | } |
431 | } |
433 | |
432 | |
434 | if (flags & UPD_NAME) |
433 | if (flags & UPD_NAME) |
… | |
… | |
488 | } |
487 | } |
489 | |
488 | |
490 | if (flags & UPD_NROF) |
489 | if (flags & UPD_NROF) |
491 | sl << uint32 (op->nrof); |
490 | sl << uint32 (op->nrof); |
492 | |
491 | |
493 | Send_With_Handling (&pl->contr->socket, &sl); |
492 | pl->contr->socket->send_packet (sl); |
494 | } |
493 | } |
495 | |
494 | |
496 | /** |
495 | /** |
497 | * Sends item's info to player. |
496 | * Sends item's info to player. |
498 | */ |
497 | */ |
… | |
… | |
508 | /* if the item is on the ground, mark that the look needs to |
507 | /* if the item is on the ground, mark that the look needs to |
509 | * be updated. |
508 | * be updated. |
510 | */ |
509 | */ |
511 | if (!op->env) |
510 | if (!op->env) |
512 | { |
511 | { |
513 | pl->contr->socket.update_look = 1; |
512 | pl->contr->socket->update_look = 1; |
514 | return; |
513 | return; |
515 | } |
514 | } |
516 | } |
515 | } |
517 | |
516 | |
518 | packet sl; |
517 | packet sl; |
519 | |
518 | |
520 | sl.printf ("item%d ", pl->contr->socket.itemcmd); |
519 | sl.printf ("item%d ", pl->contr->socket->itemcmd); |
521 | |
520 | |
522 | if (op->head) |
521 | if (op->head) |
523 | op = op->head; |
522 | op = op->head; |
524 | |
523 | |
525 | sl << uint32 (op->env ? op->env->count : 0); |
524 | sl << uint32 (op->env ? op->env->count : 0); |
526 | |
525 | |
527 | add_object_to_socklist (pl->contr->socket, sl, op); |
526 | add_object_to_socklist (*pl->contr->socket, sl, op); |
528 | |
527 | |
529 | Send_With_Handling (&pl->contr->socket, &sl); |
528 | pl->contr->socket->send_packet (sl); |
530 | SET_FLAG (op, FLAG_CLIENT_SENT); |
529 | SET_FLAG (op, FLAG_CLIENT_SENT); |
531 | |
530 | |
532 | } |
531 | } |
533 | |
532 | |
534 | /** |
533 | /** |
… | |
… | |
542 | packet sl; |
541 | packet sl; |
543 | |
542 | |
544 | sl << "delitem " |
543 | sl << "delitem " |
545 | << uint32 (tag); |
544 | << uint32 (tag); |
546 | |
545 | |
547 | Send_With_Handling (&pl->socket, &sl); |
546 | pl->socket->send_packet (sl); |
548 | } |
547 | } |
549 | |
548 | |
550 | |
549 | |
551 | /******************************************************************************* |
550 | /******************************************************************************* |
552 | * |
551 | * |
… | |
… | |
623 | return; |
622 | return; |
624 | |
623 | |
625 | /* If the high bit is set, player applied a pseudo object. */ |
624 | /* If the high bit is set, player applied a pseudo object. */ |
626 | if (tag & 0x80000000) |
625 | if (tag & 0x80000000) |
627 | { |
626 | { |
628 | pl->socket.look_position = tag & 0x7fffffff; |
627 | pl->socket->look_position = tag & 0x7fffffff; |
629 | pl->socket.update_look = 1; |
628 | pl->socket->update_look = 1; |
630 | return; |
629 | return; |
631 | } |
630 | } |
632 | |
631 | |
633 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
632 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
634 | |
633 | |
… | |
… | |
759 | { |
758 | { |
760 | return; |
759 | return; |
761 | } |
760 | } |
762 | dy = atoi (cp); |
761 | dy = atoi (cp); |
763 | |
762 | |
764 | if (FABS (dx) > pl->socket.mapx / 2 || FABS (dy) > pl->socket.mapy / 2) |
763 | if (FABS (dx) > pl->socket->mapx / 2 || FABS (dy) > pl->socket->mapy / 2) |
765 | return; |
764 | return; |
766 | |
765 | |
767 | if (pl->blocked_los[dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2]) |
766 | if (pl->blocked_los[dx + pl->socket->mapx / 2][dy + pl->socket->mapy / 2]) |
768 | return; |
767 | return; |
769 | |
768 | |
770 | look_at (pl->ob, dx, dy); |
769 | look_at (pl->ob, dx, dy); |
771 | } |
770 | } |
772 | |
771 | |