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.5 by root, Sun Sep 10 13:43:33 2006 UTC vs.
Revision 1.12 by root, Thu Dec 14 00:01:37 2006 UTC

1
2/*
3 * static char *rcsid_item_c =
4 * "$Id: item.C,v 1.5 2006/09/10 13:43:33 root Exp $";
5 */
6
7/* 1/*
8 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
9 3
10 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
11 Copyright (C) 1992 Frank Tore Johansen 5 Copyright (C) 1992 Frank Tore Johansen
22 16
23 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 20
27 The author can be reached via e-mail to crossfire-devel@real-time.com 21 The author can be reached via e-mail to <crossfire@schmorp.de>
28*/ 22*/
29 23
30/** 24/**
31 * \file 25 * \file
32 * Client/server logic. 26 * Client/server logic.
401 /* 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
402 * is hopefully in the same place, so the client should preserve 396 * is hopefully in the same place, so the client should preserve
403 * order. 397 * order.
404 */ 398 */
405 } 399 }
400
406 if (!QUERY_FLAG (op, FLAG_CLIENT_SENT)) 401 if (!QUERY_FLAG (op, FLAG_CLIENT_SENT))
407 { 402 {
408 /* 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
409 * 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
410 * and track back the call. 405 * and track back the call.
411 */ 406 */
412 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);
413 } 408 }
409
414 sl.buf = (unsigned char *) malloc (MAXSOCKBUF); 410 sl.buf = (unsigned char *) malloc (MAXSOCKBUF);
415 411
416 strcpy ((char *) sl.buf, "upditem "); 412 strcpy ((char *) sl.buf, "upditem ");
417 sl.len = strlen ((char *) sl.buf); 413 sl.len = strlen ((char *) sl.buf);
418 414
444 { 440 {
445 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))
446 esrv_send_face (&pl->contr->socket, op->face->number, 0); 442 esrv_send_face (&pl->contr->socket, op->face->number, 0);
447 SockList_AddInt (&sl, op->face->number); 443 SockList_AddInt (&sl, op->face->number);
448 } 444 }
445
449 if (flags & UPD_NAME) 446 if (flags & UPD_NAME)
450 { 447 {
451 int len; 448 int len;
452 const char *item_p; 449 const char *item_p;
453 char item_n[MAX_BUF]; 450 char item_n[MAX_BUF];
472 len += strlen (item_n + 1 + len) + 1; 469 len += strlen (item_n + 1 + len) + 1;
473 SockList_AddChar (&sl, (char) len); 470 SockList_AddChar (&sl, (char) len);
474 memcpy (sl.buf + sl.len, item_n, len); 471 memcpy (sl.buf + sl.len, item_n, len);
475 sl.len += len; 472 sl.len += len;
476 } 473 }
474
477 if (flags & UPD_ANIM) 475 if (flags & UPD_ANIM)
478 SockList_AddShort (&sl, op->animation_id); 476 SockList_AddShort (&sl, op->animation_id);
479 477
480 if (flags & UPD_ANIMSPEED) 478 if (flags & UPD_ANIMSPEED)
481 { 479 {
611 609
612/** Client wants to examine some object. So lets do so. */ 610/** Client wants to examine some object. So lets do so. */
613void 611void
614ExamineCmd (char *buf, int len, player *pl) 612ExamineCmd (char *buf, int len, player *pl)
615{ 613{
616 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
617 object *op = esrv_get_ob_from_count (pl->ob, tag); 620 object *op = esrv_get_ob_from_count (pl->ob, tag);
618 621
619 if (!op) 622 if (!op)
620 { 623 {
621 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);
622 return; 625 return;
623 } 626 }
627
624 examine (pl->ob, op); 628 examine (pl->ob, op);
625} 629}
626 630
627/** Client wants to apply some object. Lets do so. */ 631/** Client wants to apply some object. Lets do so. */
628void 632void
629ApplyCmd (char *buf, int len, player *pl) 633ApplyCmd (char *buf, int len, player *pl)
630{ 634{
631 uint32 tag = atoi (buf); 635 tag_t tag = atoi (buf);
632 object *op = esrv_get_ob_from_count (pl->ob, tag);
633 636
634 /* 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
635 * 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.
636 */ 639 */
637 if (QUERY_FLAG (pl->ob, FLAG_REMOVED)) 640 if (QUERY_FLAG (pl->ob, FLAG_REMOVED))
643 pl->socket.look_position = tag & 0x7fffffff; 646 pl->socket.look_position = tag & 0x7fffffff;
644 pl->socket.update_look = 1; 647 pl->socket.update_look = 1;
645 return; 648 return;
646 } 649 }
647 650
651 object *op = esrv_get_ob_from_count (pl->ob, tag);
652
648 if (!op) 653 if (!op)
649 { 654 {
650 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);
651 return; 656 return;
652 } 657 }
658
653 player_apply (pl->ob, op, 0, 0); 659 player_apply (pl->ob, op, 0, 0);
654} 660}
655 661
656/** Client wants to apply some object. Lets do so. */ 662/** Client wants to apply some object. Lets do so. */
657void 663void
658LockItem (uint8 * data, int len, player *pl) 664LockItem (uint8 *data, int len, player *pl)
659{ 665{
660 int flag, tag;
661 object *op;
662
663 flag = data[0]; 666 int flag = data[0];
664 tag = GetInt_String (data + 1); 667 tag_t tag = net_uint32 (data + 1);
665 op = esrv_get_ob_from_count (pl->ob, tag); 668 object *op = esrv_get_ob_from_count (pl->ob, tag);
666 669
667 if (!op) 670 if (!op)
668 { 671 {
669 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");
670 return; 673 return;
671 } 674 }
675
672 if (!flag) 676 if (!flag)
673 CLEAR_FLAG (op, FLAG_INV_LOCKED); 677 CLEAR_FLAG (op, FLAG_INV_LOCKED);
674 else 678 else
675 SET_FLAG (op, FLAG_INV_LOCKED); 679 SET_FLAG (op, FLAG_INV_LOCKED);
680
676 esrv_update_item (UPD_FLAGS, pl->ob, op); 681 esrv_update_item (UPD_FLAGS, pl->ob, op);
677} 682}
678 683
679/** Client wants to apply some object. Lets do so. */ 684/** Client wants to apply some object. Lets do so. */
680void 685void
681MarkItem (uint8 * data, int len, player *pl) 686MarkItem (uint8 * data, int len, player *pl)
682{ 687{
683 int tag; 688 tag_t tag = net_uint32 (data);
684 object *op;
685
686 tag = GetInt_String (data);
687 op = esrv_get_ob_from_count (pl->ob, tag); 689 object *op = esrv_get_ob_from_count (pl->ob, tag);
690
688 if (!op) 691 if (!op)
689 { 692 {
690 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");
691 return; 694 return;
692 } 695 }
696
693 pl->mark = op; 697 pl->mark = op;
694 pl->mark_count = op->count;
695 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));
696} 699}
697
698 700
699/** 701/**
700 * look_at prints items on the specified square. 702 * look_at prints items on the specified square.
701 * 703 *
702 * [ removed EARTHWALL check and added check for containers inventory. 704 * [ removed EARTHWALL check and added check for containers inventory.
706look_at (object *op, int dx, int dy) 708look_at (object *op, int dx, int dy)
707{ 709{
708 object *tmp; 710 object *tmp;
709 int flag = 0; 711 int flag = 0;
710 sint16 x, y; 712 sint16 x, y;
711 mapstruct *m; 713 maptile *m;
712 714
713 x = op->x + dx; 715 x = op->x + dx;
714 y = op->y + dy; 716 y = op->y + dy;
715 717
716 if (out_of_map (op->map, x, y)) 718 if (out_of_map (op->map, x, y))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines