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.89 by root, Sat Apr 3 02:27:24 2010 UTC vs.
Revision 1.92 by root, Sun Apr 11 00:34:07 2010 UTC

53static unsigned int 53static unsigned int
54query_flags (object *op) 54query_flags (object *op)
55{ 55{
56 unsigned int flags = 0; 56 unsigned int flags = 0;
57 57
58 if (QUERY_FLAG (op, FLAG_APPLIED)) 58 if (op->flag [FLAG_APPLIED])
59 switch (op->type) 59 switch (op->type)
60 { 60 {
61 case BOW: 61 case BOW:
62 case WAND: 62 case WAND:
63 case ROD: 63 case ROD:
89 } 89 }
90 90
91 if (op->is_open_container ()) 91 if (op->is_open_container ())
92 flags |= F_OPEN; 92 flags |= F_OPEN;
93 93
94 if (QUERY_FLAG (op, FLAG_KNOWN_CURSED)) 94 if (op->flag [FLAG_KNOWN_CURSED])
95 { 95 {
96 if (QUERY_FLAG (op, FLAG_DAMNED)) 96 if (op->flag [FLAG_DAMNED])
97 flags |= F_DAMNED; 97 flags |= F_DAMNED;
98 else if (QUERY_FLAG (op, FLAG_CURSED)) 98 else if (op->flag [FLAG_CURSED])
99 flags |= F_CURSED; 99 flags |= F_CURSED;
100 } 100 }
101 101
102 if (QUERY_FLAG (op, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (op, FLAG_IDENTIFIED)) 102 if (op->flag [FLAG_KNOWN_MAGICAL] && !op->flag [FLAG_IDENTIFIED])
103 flags |= F_MAGIC; 103 flags |= F_MAGIC;
104 if (QUERY_FLAG (op, FLAG_UNPAID)) 104 if (op->flag [FLAG_UNPAID])
105 flags |= F_UNPAID; 105 flags |= F_UNPAID;
106 if (QUERY_FLAG (op, FLAG_INV_LOCKED)) 106 if (op->flag [FLAG_INV_LOCKED])
107 flags |= F_LOCKED; 107 flags |= F_LOCKED;
108 108
109 return flags; 109 return flags;
110} 110}
111 111
116static void 116static void
117add_object_to_socklist (client &ns, packet &sl, object *head) 117add_object_to_socklist (client &ns, packet &sl, object *head)
118{ 118{
119 int flags = query_flags (head); 119 int flags = query_flags (head);
120 120
121 if (QUERY_FLAG (head, FLAG_NO_PICK)) 121 if (head->flag [FLAG_NO_PICK])
122 flags |= F_NOPICK; 122 flags |= F_NOPICK;
123 123
124 ns.send_face (head->face, -50); 124 ns.send_face (head->face, -50);
125 ns.flush_fx ();
126 125
127 if (QUERY_FLAG (head, FLAG_ANIMATE) && !ns.anims_sent[head->animation_id]) 126 if (head->flag [FLAG_ANIMATE] && !ns.anims_sent[head->animation_id])
128 ns.send_animation (head->animation_id); 127 ns.send_animation (head->animation_id);
129 128
130 sl << uint32 (head->count) 129 sl << uint32 (head->count)
131 << uint32 (flags) 130 << uint32 (flags)
132 << uint32 (QUERY_FLAG (head, FLAG_NO_PICK) ? -1 : head->client_weight ()) 131 << uint32 (head->flag [FLAG_NO_PICK] ? -1 : head->client_weight ())
133 << uint32 (head->face); 132 << uint32 (head->face);
134 133
135 if (!head->custom_name) 134 if (!head->custom_name)
136 { 135 {
137 const char *name; 136 const char *name;
196 return; 195 return;
197 } 196 }
198 197
199 pl->ns->update_look = 0; 198 pl->ns->update_look = 0;
200 199
201 if (QUERY_FLAG (ob, FLAG_REMOVED) 200 if (ob->flag [FLAG_REMOVED]
202 || !ob->map 201 || !ob->map
203 || ob->map->in_memory != MAP_ACTIVE 202 || ob->map->in_memory != MAP_ACTIVE
204 || out_of_map (ob->map, ob->x, ob->y)) 203 || out_of_map (ob->map, ob->x, ob->y))
205 return; 204 return;
206 205
279 dirty = true; 278 dirty = true;
280 279
281 // if packet got too large, send it and begin a new one 280 // if packet got too large, send it and begin a new one
282 if (sl.length () > MAXSOCKBUF - MAXITEMLEN) 281 if (sl.length () > MAXSOCKBUF - MAXITEMLEN)
283 { 282 {
283 pl->ns->flush_fx ();
284 pl->ns->send_packet (sl); 284 pl->ns->send_packet (sl);
285 285
286 sl.reset (); 286 sl.reset ();
287 sl.printf ("item%d ", pl->ns->itemcmd); 287 sl.printf ("item%d ", pl->ns->itemcmd);
288 sl << uint32 (0); 288 sl << uint32 (0);
307 307
308 dirty = true; 308 dirty = true;
309 } 309 }
310 310
311 if (dirty) 311 if (dirty)
312 {
313 pl->ns->flush_fx ();
312 pl->ns->send_packet (sl); 314 pl->ns->send_packet (sl);
315 }
313} 316}
314 317
315/** 318/**
316 * Sends whole inventory. 319 * Sends whole inventory.
317 */ 320 */
349 * items (especially with some of the bags out there) to 352 * items (especially with some of the bags out there) to
350 * overflow the buffer. IF so, send multiple item commands. 353 * overflow the buffer. IF so, send multiple item commands.
351 */ 354 */
352 if (sl.length () > MAXSOCKBUF - MAXITEMLEN) 355 if (sl.length () > MAXSOCKBUF - MAXITEMLEN)
353 { 356 {
357 pl->contr->ns->flush_fx ();
354 pl->contr->ns->send_packet (sl); 358 pl->contr->ns->send_packet (sl);
355 359
356 sl.reset (); 360 sl.reset ();
357 sl.printf ("item%d ", pl->contr->ns->itemcmd); 361 sl.printf ("item%d ", pl->contr->ns->itemcmd);
358 sl << uint32 (op->count); 362 sl << uint32 (op->count);
360 } 364 }
361 } 365 }
362 } 366 }
363 367
364 if (got_one) 368 if (got_one)
369 {
370 pl->contr->ns->flush_fx ();
365 pl->contr->ns->send_packet (sl); 371 pl->contr->ns->send_packet (sl);
372 }
366} 373}
367 374
368/** 375/**
369 * Updates object *op for player *pl. 376 * Updates object *op for player *pl.
370 * 377 *
441 448
442 if (flags & UPD_ANIMSPEED) 449 if (flags & UPD_ANIMSPEED)
443 { 450 {
444 int anim_speed = 0; 451 int anim_speed = 0;
445 452
446 if (QUERY_FLAG (op, FLAG_ANIMATE)) 453 if (op->flag [FLAG_ANIMATE])
447 { 454 {
448 if (op->anim_speed) 455 if (op->anim_speed)
449 anim_speed = op->anim_speed; 456 anim_speed = op->anim_speed;
450 else 457 else
451 { 458 {
491 498
492 sl << uint32 (op->env ? op->env->count : 0); 499 sl << uint32 (op->env ? op->env->count : 0);
493 500
494 add_object_to_socklist (*pl->contr->ns, sl, op); 501 add_object_to_socklist (*pl->contr->ns, sl, op);
495 502
503 pl->contr->ns->flush_fx ();
496 pl->contr->ns->send_packet (sl); 504 pl->contr->ns->send_packet (sl);
497} 505}
498 506
499/** 507/**
500 * Tells the client to delete an item. 508 * Tells the client to delete an item.
619 { 627 {
620 LOG (llevDebug, "Player '%s' tried to apply the unknown object (%d)\n", &pl->ob->name, tag); 628 LOG (llevDebug, "Player '%s' tried to apply the unknown object (%d)\n", &pl->ob->name, tag);
621 return; 629 return;
622 } 630 }
623 631
624 pl->ob->apply (op); 632 pl->ob->apply (op, AP_TOGGLE);
625} 633}
626 634
627/** Client wants to lock some object. Lets do so. */ 635/** Client wants to lock some object. Lets do so. */
628void 636void
629LockItem (char *data, int len, player *pl) 637LockItem (char *data, int len, player *pl)
637 pl->failmsg ("Could not find object to lock/unlock"); 645 pl->failmsg ("Could not find object to lock/unlock");
638 return; 646 return;
639 } 647 }
640 648
641 if (!flag) 649 if (!flag)
642 CLEAR_FLAG (op, FLAG_INV_LOCKED); 650 op->clr_flag (FLAG_INV_LOCKED);
643 else 651 else
644 SET_FLAG (op, FLAG_INV_LOCKED); 652 op->set_flag (FLAG_INV_LOCKED);
645 653
646 esrv_update_item (UPD_FLAGS, pl->ob, op); 654 esrv_update_item (UPD_FLAGS, pl->ob, op);
647} 655}
648 656
649/** Client wants to mark some object. Lets do so. */ 657/** Client wants to mark some object. Lets do so. */
710 else 718 else
711 { 719 {
712 if (pos.normalise ()) 720 if (pos.normalise ())
713 for (object *tmp = pos->top; tmp; tmp = tmp->below) 721 for (object *tmp = pos->top; tmp; tmp = tmp->below)
714 { 722 {
715 if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ)) 723 if (tmp->invisible && !ob->flag [FLAG_WIZ])
716 continue; 724 continue;
717 725
718 if (wiz) 726 if (wiz)
719 buf.printf (" - %s (%d) %s\n", query_name (tmp), tmp->count, tmp->uuid.c_str ()); 727 buf.printf (" - %s (%d) %s\n", query_name (tmp), tmp->count, tmp->uuid.c_str ());
720 else 728 else
722 730
723 object *head = tmp->head_ (); 731 object *head = tmp->head_ ();
724 732
725 if (head->inv) 733 if (head->inv)
726 if ((head->type != CONTAINER && head->type != FLESH) 734 if ((head->type != CONTAINER && head->type != FLESH)
727 || QUERY_FLAG (ob, FLAG_WIZ)) 735 || ob->flag [FLAG_WIZ])
728 buf << head->query_inventory (ob, " "); 736 buf << head->query_inventory (ob, " ");
729 737
730 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !wiz) /* don't continue under the floor */ 738 if (tmp->flag [FLAG_IS_FLOOR] && !wiz) /* don't continue under the floor */
731 break; 739 break;
732 } 740 }
733 } 741 }
734 742
735 if (buf.empty ()) 743 if (buf.empty ())
770 return; 778 return;
771 779
772 /* If it is an active container, then we should drop all objects 780 /* If it is an active container, then we should drop all objects
773 * in the container and not the container itself. 781 * in the container and not the container itself.
774 */ 782 */
775 if (op->inv && QUERY_FLAG (op, FLAG_APPLIED)) 783 if (op->inv && op->flag [FLAG_APPLIED])
776 { 784 {
777 int cnt = MAX_ITEM_PER_ACTION; 785 int cnt = MAX_ITEM_PER_ACTION;
778 786
779 for (object *current = op->inv; current && cnt--; ) 787 for (object *current = op->inv; current && cnt--; )
780 { 788 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines