ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/item.C
(Generate patch)

Comparing deliantra/server/socket/item.C (file contents):
Revision 1.8 by root, Sat Sep 16 22:24:13 2006 UTC vs.
Revision 1.12 by root, Thu Dec 14 00:01:37 2006 UTC

395 /* we remove the check for op->env, because in theory, the object 395 /* we remove the check for op->env, because in theory, the object
396 * is hopefully in the same place, so the client should preserve 396 * is hopefully in the same place, so the client should preserve
397 * order. 397 * order.
398 */ 398 */
399 } 399 }
400
400 if (!QUERY_FLAG (op, FLAG_CLIENT_SENT)) 401 if (!QUERY_FLAG (op, FLAG_CLIENT_SENT))
401 { 402 {
402 /* FLAG_CLIENT_SENT is debug only. We are using it to see where 403 /* FLAG_CLIENT_SENT is debug only. We are using it to see where
403 * this is happening - we can set a breakpoint here in the debugger 404 * this is happening - we can set a breakpoint here in the debugger
404 * and track back the call. 405 * and track back the call.
405 */ 406 */
406 LOG (llevDebug, "We have not sent item %s (%d)\n", &op->name, op->count); 407 LOG (llevDebug, "We have not sent item %s (%d)\n", &op->name, op->count);
407 } 408 }
409
408 sl.buf = (unsigned char *) malloc (MAXSOCKBUF); 410 sl.buf = (unsigned char *) malloc (MAXSOCKBUF);
409 411
410 strcpy ((char *) sl.buf, "upditem "); 412 strcpy ((char *) sl.buf, "upditem ");
411 sl.len = strlen ((char *) sl.buf); 413 sl.len = strlen ((char *) sl.buf);
412 414
438 { 440 {
439 if (!(pl->contr->socket.faces_sent[op->face->number] & NS_FACESENT_FACE)) 441 if (!(pl->contr->socket.faces_sent[op->face->number] & NS_FACESENT_FACE))
440 esrv_send_face (&pl->contr->socket, op->face->number, 0); 442 esrv_send_face (&pl->contr->socket, op->face->number, 0);
441 SockList_AddInt (&sl, op->face->number); 443 SockList_AddInt (&sl, op->face->number);
442 } 444 }
445
443 if (flags & UPD_NAME) 446 if (flags & UPD_NAME)
444 { 447 {
445 int len; 448 int len;
446 const char *item_p; 449 const char *item_p;
447 char item_n[MAX_BUF]; 450 char item_n[MAX_BUF];
466 len += strlen (item_n + 1 + len) + 1; 469 len += strlen (item_n + 1 + len) + 1;
467 SockList_AddChar (&sl, (char) len); 470 SockList_AddChar (&sl, (char) len);
468 memcpy (sl.buf + sl.len, item_n, len); 471 memcpy (sl.buf + sl.len, item_n, len);
469 sl.len += len; 472 sl.len += len;
470 } 473 }
474
471 if (flags & UPD_ANIM) 475 if (flags & UPD_ANIM)
472 SockList_AddShort (&sl, op->animation_id); 476 SockList_AddShort (&sl, op->animation_id);
473 477
474 if (flags & UPD_ANIMSPEED) 478 if (flags & UPD_ANIMSPEED)
475 { 479 {
605 609
606/** Client wants to examine some object. So lets do so. */ 610/** Client wants to examine some object. So lets do so. */
607void 611void
608ExamineCmd (char *buf, int len, player *pl) 612ExamineCmd (char *buf, int len, player *pl)
609{ 613{
610 long tag = atoi (buf); 614 tag_t tag = atoi (buf);
615
616 /* If the high bit is set, player examined a pseudo object. */
617 if (tag & 0x80000000)
618 return;
619
611 object *op = esrv_get_ob_from_count (pl->ob, tag); 620 object *op = esrv_get_ob_from_count (pl->ob, tag);
612 621
613 if (!op) 622 if (!op)
614 { 623 {
615 LOG (llevDebug, "Player '%s' tried to examine the unknown object (%ld)\n", &pl->ob->name, tag); 624 LOG (llevDebug, "Player '%s' tried to examine the unknown object (%ld)\n", &pl->ob->name, tag);
616 return; 625 return;
617 } 626 }
627
618 examine (pl->ob, op); 628 examine (pl->ob, op);
619} 629}
620 630
621/** Client wants to apply some object. Lets do so. */ 631/** Client wants to apply some object. Lets do so. */
622void 632void
623ApplyCmd (char *buf, int len, player *pl) 633ApplyCmd (char *buf, int len, player *pl)
624{ 634{
625 uint32 tag = atoi (buf); 635 tag_t tag = atoi (buf);
626 object *op = esrv_get_ob_from_count (pl->ob, tag);
627 636
628 /* sort of a hack, but if the player saves and the player then manually 637 /* sort of a hack, but if the player saves and the player then manually
629 * applies a savebed (or otherwise tries to do stuff), we run into trouble. 638 * applies a savebed (or otherwise tries to do stuff), we run into trouble.
630 */ 639 */
631 if (QUERY_FLAG (pl->ob, FLAG_REMOVED)) 640 if (QUERY_FLAG (pl->ob, FLAG_REMOVED))
637 pl->socket.look_position = tag & 0x7fffffff; 646 pl->socket.look_position = tag & 0x7fffffff;
638 pl->socket.update_look = 1; 647 pl->socket.update_look = 1;
639 return; 648 return;
640 } 649 }
641 650
651 object *op = esrv_get_ob_from_count (pl->ob, tag);
652
642 if (!op) 653 if (!op)
643 { 654 {
644 LOG (llevDebug, "Player '%s' tried to apply the unknown object (%d)\n", &pl->ob->name, tag); 655 LOG (llevDebug, "Player '%s' tried to apply the unknown object (%d)\n", &pl->ob->name, tag);
645 return; 656 return;
646 } 657 }
658
647 player_apply (pl->ob, op, 0, 0); 659 player_apply (pl->ob, op, 0, 0);
648} 660}
649 661
650/** Client wants to apply some object. Lets do so. */ 662/** Client wants to apply some object. Lets do so. */
651void 663void
652LockItem (uint8 * data, int len, player *pl) 664LockItem (uint8 *data, int len, player *pl)
653{ 665{
654 int flag, tag;
655 object *op;
656
657 flag = data[0]; 666 int flag = data[0];
658 tag = GetInt_String (data + 1); 667 tag_t tag = net_uint32 (data + 1);
659 op = esrv_get_ob_from_count (pl->ob, tag); 668 object *op = esrv_get_ob_from_count (pl->ob, tag);
660 669
661 if (!op) 670 if (!op)
662 { 671 {
663 new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to lock/unlock"); 672 new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to lock/unlock");
664 return; 673 return;
665 } 674 }
675
666 if (!flag) 676 if (!flag)
667 CLEAR_FLAG (op, FLAG_INV_LOCKED); 677 CLEAR_FLAG (op, FLAG_INV_LOCKED);
668 else 678 else
669 SET_FLAG (op, FLAG_INV_LOCKED); 679 SET_FLAG (op, FLAG_INV_LOCKED);
680
670 esrv_update_item (UPD_FLAGS, pl->ob, op); 681 esrv_update_item (UPD_FLAGS, pl->ob, op);
671} 682}
672 683
673/** Client wants to apply some object. Lets do so. */ 684/** Client wants to apply some object. Lets do so. */
674void 685void
675MarkItem (uint8 * data, int len, player *pl) 686MarkItem (uint8 * data, int len, player *pl)
676{ 687{
677 int tag; 688 tag_t tag = net_uint32 (data);
678 object *op;
679
680 tag = GetInt_String (data);
681 op = esrv_get_ob_from_count (pl->ob, tag); 689 object *op = esrv_get_ob_from_count (pl->ob, tag);
690
682 if (!op) 691 if (!op)
683 { 692 {
684 new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to mark"); 693 new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to mark");
685 return; 694 return;
686 } 695 }
696
687 pl->mark = op; 697 pl->mark = op;
688 pl->mark_count = op->count;
689 new_draw_info_format (NDI_UNIQUE, 0, pl->ob, "Marked item %s", query_name (op)); 698 new_draw_info_format (NDI_UNIQUE, 0, pl->ob, "Marked item %s", query_name (op));
690} 699}
691
692 700
693/** 701/**
694 * look_at prints items on the specified square. 702 * look_at prints items on the specified square.
695 * 703 *
696 * [ removed EARTHWALL check and added check for containers inventory. 704 * [ removed EARTHWALL check and added check for containers inventory.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines