… | |
… | |
337 | { |
337 | { |
338 | object *tmp, *last; |
338 | object *tmp, *last; |
339 | int got_one = 0, start_look = 0, end_look = 0; |
339 | int got_one = 0, start_look = 0, end_look = 0; |
340 | char buf[MAX_BUF]; |
340 | char buf[MAX_BUF]; |
341 | |
341 | |
342 | if (!pl->contr->socket->update_look) |
342 | if (!pl->contr->ns->update_look) |
343 | { |
343 | { |
344 | LOG (llevDebug, "esrv_draw_look called when update_look was not set\n"); |
344 | LOG (llevDebug, "esrv_draw_look called when update_look was not set\n"); |
345 | return; |
345 | return; |
346 | } |
346 | } |
347 | else |
347 | else |
348 | pl->contr->socket->update_look = 0; |
348 | pl->contr->ns->update_look = 0; |
349 | |
349 | |
350 | if (QUERY_FLAG (pl, FLAG_REMOVED) |
350 | if (QUERY_FLAG (pl, FLAG_REMOVED) |
351 | || !pl->map |
351 | || !pl->map |
352 | || pl->map->in_memory != MAP_IN_MEMORY |
352 | || pl->map->in_memory != MAP_IN_MEMORY |
353 | || out_of_map (pl->map, pl->x, pl->y)) |
353 | || out_of_map (pl->map, pl->x, pl->y)) |
354 | return; |
354 | return; |
355 | |
355 | |
356 | for (tmp = GET_MAP_OB (pl->map, pl->x, pl->y); tmp && tmp->above; tmp = tmp->above) |
356 | for (tmp = GET_MAP_OB (pl->map, pl->x, pl->y); tmp && tmp->above; tmp = tmp->above) |
357 | ; |
357 | ; |
358 | |
358 | |
359 | pl->contr->socket->send_packet ("delinv 0"); |
359 | pl->contr->ns->send_packet ("delinv 0"); |
360 | |
360 | |
361 | packet sl; |
361 | packet sl; |
362 | sl.printf ("item%d ", pl->contr->socket->itemcmd); |
362 | sl.printf ("item%d ", pl->contr->ns->itemcmd); |
363 | |
363 | |
364 | sl << uint32 (0); |
364 | sl << uint32 (0); |
365 | |
365 | |
366 | if (!(pl->contr->socket->faces_sent[empty_face->number] & NS_FACESENT_FACE)) |
366 | if (!(pl->contr->ns->faces_sent[empty_face->number] & NS_FACESENT_FACE)) |
367 | esrv_send_face (pl->contr->socket, empty_face->number, 0); |
367 | esrv_send_face (pl->contr->ns, empty_face->number, 0); |
368 | |
368 | |
369 | if (pl->contr->socket->look_position) |
369 | if (pl->contr->ns->look_position) |
370 | { |
370 | { |
371 | char buf[80]; |
371 | char buf[80]; |
372 | snprintf (buf, 80, "Apply this to see %d previous items", FLOORBOX_PAGESIZE); |
372 | snprintf (buf, 80, "Apply this to see %d previous items", FLOORBOX_PAGESIZE); |
373 | |
373 | |
374 | sl << uint32 (0x80000000 | (pl->contr->socket->look_position - FLOORBOX_PAGESIZE)) |
374 | sl << uint32 (0x80000000 | (pl->contr->ns->look_position - FLOORBOX_PAGESIZE)) |
375 | << uint32 (0) |
375 | << uint32 (0) |
376 | << sint32 (-1) |
376 | << sint32 (-1) |
377 | << uint32 (empty_face->number) |
377 | << uint32 (empty_face->number) |
378 | << data8 (buf) |
378 | << data8 (buf) |
379 | << uint16 (0) |
379 | << uint16 (0) |
380 | << uint8 (0) |
380 | << uint8 (0) |
381 | << uint32 (0); |
381 | << uint32 (0); |
382 | |
382 | |
383 | if (pl->contr->socket->itemcmd == 2) |
383 | if (pl->contr->ns->itemcmd == 2) |
384 | sl << uint16 (0); |
384 | sl << uint16 (0); |
385 | } |
385 | } |
386 | |
386 | |
387 | for (last = NULL; tmp != last; tmp = tmp->below) |
387 | for (last = NULL; tmp != last; tmp = tmp->below) |
388 | { |
388 | { |
… | |
… | |
395 | last = last->below; |
395 | last = last->below; |
396 | } |
396 | } |
397 | |
397 | |
398 | if (LOOK_OBJ (tmp)) |
398 | if (LOOK_OBJ (tmp)) |
399 | { |
399 | { |
400 | if (++start_look < pl->contr->socket->look_position) |
400 | if (++start_look < pl->contr->ns->look_position) |
401 | continue; |
401 | continue; |
402 | |
402 | |
403 | end_look++; |
403 | end_look++; |
404 | |
404 | |
405 | if (end_look > FLOORBOX_PAGESIZE) |
405 | if (end_look > FLOORBOX_PAGESIZE) |
406 | { |
406 | { |
407 | /* What we basically do is make a 'fake' object - when the user applies it, |
407 | /* What we basically do is make a 'fake' object - when the user applies it, |
408 | * we notice the special tag the object has, and act accordingly. |
408 | * we notice the special tag the object has, and act accordingly. |
409 | */ |
409 | */ |
410 | sl << uint32 (0x80000000 | (pl->contr->socket->look_position + FLOORBOX_PAGESIZE)) |
410 | sl << uint32 (0x80000000 | (pl->contr->ns->look_position + FLOORBOX_PAGESIZE)) |
411 | << uint32 (0) |
411 | << uint32 (0) |
412 | << uint32 ((uint32) - 1) |
412 | << uint32 ((uint32) - 1) |
413 | << uint32 (empty_face->number) |
413 | << uint32 (empty_face->number) |
414 | << data8 ("Apply this to see next group of items") |
414 | << data8 ("Apply this to see next group of items") |
415 | << uint16 (0) |
415 | << uint16 (0) |
416 | << uint8 (0) |
416 | << uint8 (0) |
417 | << uint32 (0); |
417 | << uint32 (0); |
418 | |
418 | |
419 | if (pl->contr->socket->itemcmd == 2) |
419 | if (pl->contr->ns->itemcmd == 2) |
420 | sl << uint16 (0); |
420 | sl << uint16 (0); |
421 | |
421 | |
422 | break; |
422 | break; |
423 | } |
423 | } |
424 | |
424 | |
425 | if (tmp->head) |
425 | if (tmp->head) |
426 | head = tmp->head; |
426 | head = tmp->head; |
427 | else |
427 | else |
428 | head = tmp; |
428 | head = tmp; |
429 | |
429 | |
430 | add_object_to_socklist (*pl->contr->socket, sl, head); |
430 | add_object_to_socklist (*pl->contr->ns, sl, head); |
431 | got_one++; |
431 | got_one++; |
432 | |
432 | |
433 | if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN)) |
433 | if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN)) |
434 | { |
434 | { |
435 | pl->contr->socket->send_packet (sl); |
435 | pl->contr->ns->send_packet (sl); |
436 | |
436 | |
437 | sl.reset (); |
437 | sl.reset (); |
438 | sl.printf ("item%d ", pl->contr->socket->itemcmd); |
438 | sl.printf ("item%d ", pl->contr->ns->itemcmd); |
439 | sl << uint32 (0); |
439 | sl << uint32 (0); |
440 | got_one = 0; |
440 | got_one = 0; |
441 | } |
441 | } |
442 | } |
442 | } |
443 | } |
443 | } |
444 | |
444 | |
445 | if (got_one) |
445 | if (got_one) |
446 | pl->contr->socket->send_packet (sl); |
446 | pl->contr->ns->send_packet (sl); |
447 | |
447 | |
448 | } |
448 | } |
449 | |
449 | |
450 | /** |
450 | /** |
451 | * Sends whole inventory. |
451 | * Sends whole inventory. |
… | |
… | |
455 | { |
455 | { |
456 | object *tmp; |
456 | object *tmp; |
457 | int got_one = 0; |
457 | int got_one = 0; |
458 | |
458 | |
459 | |
459 | |
460 | pl->contr->socket->send_packet_printf ("delinv %d", op->count); |
460 | pl->contr->ns->send_packet_printf ("delinv %d", op->count); |
461 | |
461 | |
462 | packet sl; |
462 | packet sl; |
463 | sl.printf ("item%d ", pl->contr->socket->itemcmd); |
463 | sl.printf ("item%d ", pl->contr->ns->itemcmd); |
464 | |
464 | |
465 | sl << uint32 (op->count); |
465 | sl << uint32 (op->count); |
466 | |
466 | |
467 | for (tmp = op->inv; tmp; tmp = tmp->below) |
467 | for (tmp = op->inv; tmp; tmp = tmp->below) |
468 | { |
468 | { |
… | |
… | |
473 | else |
473 | else |
474 | head = tmp; |
474 | head = tmp; |
475 | |
475 | |
476 | if (LOOK_OBJ (head)) |
476 | if (LOOK_OBJ (head)) |
477 | { |
477 | { |
478 | add_object_to_socklist (*pl->contr->socket, sl, head); |
478 | add_object_to_socklist (*pl->contr->ns, sl, head); |
479 | |
479 | |
480 | got_one++; |
480 | got_one++; |
481 | |
481 | |
482 | /* IT is possible for players to accumulate a huge amount of |
482 | /* IT is possible for players to accumulate a huge amount of |
483 | * items (especially with some of the bags out there) to |
483 | * items (especially with some of the bags out there) to |
484 | * overflow the buffer. IF so, send multiple item commands. |
484 | * overflow the buffer. IF so, send multiple item commands. |
485 | */ |
485 | */ |
486 | if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN)) |
486 | if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN)) |
487 | { |
487 | { |
488 | pl->contr->socket->send_packet (sl); |
488 | pl->contr->ns->send_packet (sl); |
489 | |
489 | |
490 | sl.reset (); |
490 | sl.reset (); |
491 | sl.printf ("item%d ", pl->contr->socket->itemcmd); |
491 | sl.printf ("item%d ", pl->contr->ns->itemcmd); |
492 | sl << uint32 (op->count); |
492 | sl << uint32 (op->count); |
493 | got_one = 0; |
493 | got_one = 0; |
494 | } |
494 | } |
495 | } /* If LOOK_OBJ() */ |
495 | } /* If LOOK_OBJ() */ |
496 | } |
496 | } |
497 | |
497 | |
498 | if (got_one) |
498 | if (got_one) |
499 | pl->contr->socket->send_packet (sl); |
499 | pl->contr->ns->send_packet (sl); |
500 | } |
500 | } |
501 | |
501 | |
502 | /** |
502 | /** |
503 | * Updates object *op for player *pl. |
503 | * Updates object *op for player *pl. |
504 | * |
504 | * |
… | |
… | |
555 | op->contr->last_weight = weight; |
555 | op->contr->last_weight = weight; |
556 | } |
556 | } |
557 | |
557 | |
558 | if (flags & UPD_FACE) |
558 | if (flags & UPD_FACE) |
559 | { |
559 | { |
560 | if (!(pl->contr->socket->faces_sent[op->face->number] & NS_FACESENT_FACE)) |
560 | if (!(pl->contr->ns->faces_sent[op->face->number] & NS_FACESENT_FACE)) |
561 | esrv_send_face (pl->contr->socket, op->face->number, 0); |
561 | esrv_send_face (pl->contr->ns, op->face->number, 0); |
562 | |
562 | |
563 | sl << uint32 (op->face->number); |
563 | sl << uint32 (op->face->number); |
564 | } |
564 | } |
565 | |
565 | |
566 | if (flags & UPD_NAME) |
566 | if (flags & UPD_NAME) |
… | |
… | |
620 | } |
620 | } |
621 | |
621 | |
622 | if (flags & UPD_NROF) |
622 | if (flags & UPD_NROF) |
623 | sl << uint32 (op->nrof); |
623 | sl << uint32 (op->nrof); |
624 | |
624 | |
625 | pl->contr->socket->send_packet (sl); |
625 | pl->contr->ns->send_packet (sl); |
626 | } |
626 | } |
627 | |
627 | |
628 | /** |
628 | /** |
629 | * Sends item's info to player. |
629 | * Sends item's info to player. |
630 | */ |
630 | */ |
… | |
… | |
640 | /* if the item is on the ground, mark that the look needs to |
640 | /* if the item is on the ground, mark that the look needs to |
641 | * be updated. |
641 | * be updated. |
642 | */ |
642 | */ |
643 | if (!op->env) |
643 | if (!op->env) |
644 | { |
644 | { |
645 | pl->contr->socket->floorbox_update (); |
645 | pl->contr->ns->floorbox_update (); |
646 | return; |
646 | return; |
647 | } |
647 | } |
648 | } |
648 | } |
649 | |
649 | |
650 | packet sl; |
650 | packet sl; |
651 | |
651 | |
652 | sl.printf ("item%d ", pl->contr->socket->itemcmd); |
652 | sl.printf ("item%d ", pl->contr->ns->itemcmd); |
653 | |
653 | |
654 | if (op->head) |
654 | if (op->head) |
655 | op = op->head; |
655 | op = op->head; |
656 | |
656 | |
657 | sl << uint32 (op->env ? op->env->count : 0); |
657 | sl << uint32 (op->env ? op->env->count : 0); |
658 | |
658 | |
659 | add_object_to_socklist (*pl->contr->socket, sl, op); |
659 | add_object_to_socklist (*pl->contr->ns, sl, op); |
660 | |
660 | |
661 | pl->contr->socket->send_packet (sl); |
661 | pl->contr->ns->send_packet (sl); |
662 | SET_FLAG (op, FLAG_CLIENT_SENT); |
662 | SET_FLAG (op, FLAG_CLIENT_SENT); |
663 | } |
663 | } |
664 | |
664 | |
665 | /** |
665 | /** |
666 | * Tells the client to delete an item. Uses the item |
666 | * Tells the client to delete an item. Uses the item |
… | |
… | |
672 | { |
672 | { |
673 | packet sl ("delitem"); |
673 | packet sl ("delitem"); |
674 | |
674 | |
675 | sl << uint32 (tag); |
675 | sl << uint32 (tag); |
676 | |
676 | |
677 | pl->socket->send_packet (sl); |
677 | pl->ns->send_packet (sl); |
678 | } |
678 | } |
679 | |
679 | |
680 | |
680 | |
681 | /******************************************************************************* |
681 | /******************************************************************************* |
682 | * |
682 | * |
… | |
… | |
753 | return; |
753 | return; |
754 | |
754 | |
755 | /* If the high bit is set, player applied a pseudo object. */ |
755 | /* If the high bit is set, player applied a pseudo object. */ |
756 | if (tag & 0x80000000) |
756 | if (tag & 0x80000000) |
757 | { |
757 | { |
758 | pl->socket->look_position = tag & 0x7fffffff; |
758 | pl->ns->look_position = tag & 0x7fffffff; |
759 | pl->socket->floorbox_update (); |
759 | pl->ns->floorbox_update (); |
760 | return; |
760 | return; |
761 | } |
761 | } |
762 | |
762 | |
763 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
763 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
764 | |
764 | |
… | |
… | |
889 | { |
889 | { |
890 | return; |
890 | return; |
891 | } |
891 | } |
892 | dy = atoi (cp); |
892 | dy = atoi (cp); |
893 | |
893 | |
894 | if (FABS (dx) > pl->socket->mapx / 2 || FABS (dy) > pl->socket->mapy / 2) |
894 | if (FABS (dx) > pl->ns->mapx / 2 || FABS (dy) > pl->ns->mapy / 2) |
895 | return; |
895 | return; |
896 | |
896 | |
897 | if (pl->blocked_los[dx + pl->socket->mapx / 2][dy + pl->socket->mapy / 2]) |
897 | if (pl->blocked_los[dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2]) |
898 | return; |
898 | return; |
899 | |
899 | |
900 | look_at (pl->ob, dx, dy); |
900 | look_at (pl->ob, dx, dy); |
901 | } |
901 | } |
902 | |
902 | |