… | |
… | |
53 | static unsigned int |
53 | static unsigned int |
54 | query_flags (object *op) |
54 | query_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 | |
… | |
… | |
116 | static void |
116 | static void |
117 | add_object_to_socklist (client &ns, packet &sl, object *head) |
117 | add_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; |
… | |
… | |
194 | { |
193 | { |
195 | LOG (llevDebug, "esrv_draw_look called when update_look was not set (player %s)\n", &ob->name); |
194 | LOG (llevDebug, "esrv_draw_look called when update_look was not set (player %s)\n", &ob->name); |
196 | return; |
195 | return; |
197 | } |
196 | } |
198 | |
197 | |
|
|
198 | pl->ns->send_packet ("delinv 0"); |
|
|
199 | |
|
|
200 | if (pl->run_on) |
|
|
201 | return; |
|
|
202 | |
199 | pl->ns->update_look = 0; |
203 | pl->ns->update_look = 0; |
200 | |
204 | |
201 | if (QUERY_FLAG (ob, FLAG_REMOVED) |
205 | if (ob->flag [FLAG_REMOVED] |
202 | || !ob->map |
206 | || !ob->map |
203 | || ob->map->in_memory != MAP_ACTIVE |
207 | || ob->map->in_memory != MAP_ACTIVE |
204 | || out_of_map (ob->map, ob->x, ob->y)) |
208 | || out_of_map (ob->map, ob->x, ob->y)) |
205 | return; |
209 | return; |
206 | |
|
|
207 | pl->ns->send_packet ("delinv 0"); |
|
|
208 | |
210 | |
209 | packet sl; |
211 | packet sl; |
210 | sl.printf ("item%d ", pl->ns->itemcmd); |
212 | sl.printf ("item%d ", pl->ns->itemcmd); |
211 | |
213 | |
212 | sl << uint32 (0); |
214 | sl << uint32 (0); |
… | |
… | |
279 | dirty = true; |
281 | dirty = true; |
280 | |
282 | |
281 | // if packet got too large, send it and begin a new one |
283 | // if packet got too large, send it and begin a new one |
282 | if (sl.length () > MAXSOCKBUF - MAXITEMLEN) |
284 | if (sl.length () > MAXSOCKBUF - MAXITEMLEN) |
283 | { |
285 | { |
|
|
286 | pl->ns->flush_fx (); |
284 | pl->ns->send_packet (sl); |
287 | pl->ns->send_packet (sl); |
285 | |
288 | |
286 | sl.reset (); |
289 | sl.reset (); |
287 | sl.printf ("item%d ", pl->ns->itemcmd); |
290 | sl.printf ("item%d ", pl->ns->itemcmd); |
288 | sl << uint32 (0); |
291 | sl << uint32 (0); |
… | |
… | |
307 | |
310 | |
308 | dirty = true; |
311 | dirty = true; |
309 | } |
312 | } |
310 | |
313 | |
311 | if (dirty) |
314 | if (dirty) |
|
|
315 | { |
|
|
316 | pl->ns->flush_fx (); |
312 | pl->ns->send_packet (sl); |
317 | pl->ns->send_packet (sl); |
|
|
318 | } |
313 | } |
319 | } |
314 | |
320 | |
315 | /** |
321 | /** |
316 | * Sends whole inventory. |
322 | * Sends whole inventory. |
317 | */ |
323 | */ |
… | |
… | |
349 | * items (especially with some of the bags out there) to |
355 | * items (especially with some of the bags out there) to |
350 | * overflow the buffer. IF so, send multiple item commands. |
356 | * overflow the buffer. IF so, send multiple item commands. |
351 | */ |
357 | */ |
352 | if (sl.length () > MAXSOCKBUF - MAXITEMLEN) |
358 | if (sl.length () > MAXSOCKBUF - MAXITEMLEN) |
353 | { |
359 | { |
|
|
360 | pl->contr->ns->flush_fx (); |
354 | pl->contr->ns->send_packet (sl); |
361 | pl->contr->ns->send_packet (sl); |
355 | |
362 | |
356 | sl.reset (); |
363 | sl.reset (); |
357 | sl.printf ("item%d ", pl->contr->ns->itemcmd); |
364 | sl.printf ("item%d ", pl->contr->ns->itemcmd); |
358 | sl << uint32 (op->count); |
365 | sl << uint32 (op->count); |
… | |
… | |
360 | } |
367 | } |
361 | } |
368 | } |
362 | } |
369 | } |
363 | |
370 | |
364 | if (got_one) |
371 | if (got_one) |
|
|
372 | { |
|
|
373 | pl->contr->ns->flush_fx (); |
365 | pl->contr->ns->send_packet (sl); |
374 | pl->contr->ns->send_packet (sl); |
|
|
375 | } |
366 | } |
376 | } |
367 | |
377 | |
368 | /** |
378 | /** |
369 | * Updates object *op for player *pl. |
379 | * Updates object *op for player *pl. |
370 | * |
380 | * |
… | |
… | |
441 | |
451 | |
442 | if (flags & UPD_ANIMSPEED) |
452 | if (flags & UPD_ANIMSPEED) |
443 | { |
453 | { |
444 | int anim_speed = 0; |
454 | int anim_speed = 0; |
445 | |
455 | |
446 | if (QUERY_FLAG (op, FLAG_ANIMATE)) |
456 | if (op->flag [FLAG_ANIMATE]) |
447 | { |
457 | { |
448 | if (op->anim_speed) |
458 | if (op->anim_speed) |
449 | anim_speed = op->anim_speed; |
459 | anim_speed = op->anim_speed; |
450 | else |
460 | else |
451 | { |
461 | { |
… | |
… | |
491 | |
501 | |
492 | sl << uint32 (op->env ? op->env->count : 0); |
502 | sl << uint32 (op->env ? op->env->count : 0); |
493 | |
503 | |
494 | add_object_to_socklist (*pl->contr->ns, sl, op); |
504 | add_object_to_socklist (*pl->contr->ns, sl, op); |
495 | |
505 | |
|
|
506 | pl->contr->ns->flush_fx (); |
496 | pl->contr->ns->send_packet (sl); |
507 | pl->contr->ns->send_packet (sl); |
497 | } |
508 | } |
498 | |
509 | |
499 | /** |
510 | /** |
500 | * Tells the client to delete an item. |
511 | * Tells the client to delete an item. |
… | |
… | |
619 | { |
630 | { |
620 | LOG (llevDebug, "Player '%s' tried to apply the unknown object (%d)\n", &pl->ob->name, tag); |
631 | LOG (llevDebug, "Player '%s' tried to apply the unknown object (%d)\n", &pl->ob->name, tag); |
621 | return; |
632 | return; |
622 | } |
633 | } |
623 | |
634 | |
624 | pl->ob->apply (op); |
635 | pl->ob->apply (op, AP_TOGGLE); |
625 | } |
636 | } |
626 | |
637 | |
627 | /** Client wants to lock some object. Lets do so. */ |
638 | /** Client wants to lock some object. Lets do so. */ |
628 | void |
639 | void |
629 | LockItem (char *data, int len, player *pl) |
640 | LockItem (char *data, int len, player *pl) |
… | |
… | |
637 | pl->failmsg ("Could not find object to lock/unlock"); |
648 | pl->failmsg ("Could not find object to lock/unlock"); |
638 | return; |
649 | return; |
639 | } |
650 | } |
640 | |
651 | |
641 | if (!flag) |
652 | if (!flag) |
642 | CLEAR_FLAG (op, FLAG_INV_LOCKED); |
653 | op->clr_flag (FLAG_INV_LOCKED); |
643 | else |
654 | else |
644 | SET_FLAG (op, FLAG_INV_LOCKED); |
655 | op->set_flag (FLAG_INV_LOCKED); |
645 | |
656 | |
646 | esrv_update_item (UPD_FLAGS, pl->ob, op); |
657 | esrv_update_item (UPD_FLAGS, pl->ob, op); |
647 | } |
658 | } |
648 | |
659 | |
649 | /** Client wants to mark some object. Lets do so. */ |
660 | /** Client wants to mark some object. Lets do so. */ |
… | |
… | |
710 | else |
721 | else |
711 | { |
722 | { |
712 | if (pos.normalise ()) |
723 | if (pos.normalise ()) |
713 | for (object *tmp = pos->top; tmp; tmp = tmp->below) |
724 | for (object *tmp = pos->top; tmp; tmp = tmp->below) |
714 | { |
725 | { |
715 | if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ)) |
726 | if (tmp->invisible && !ob->flag [FLAG_WIZ]) |
716 | continue; |
727 | continue; |
717 | |
728 | |
718 | if (wiz) |
729 | if (wiz) |
719 | buf.printf (" - %s (%d) %s\n", query_name (tmp), tmp->count, tmp->uuid.c_str ()); |
730 | buf.printf (" - %s (%d) %s\n", query_name (tmp), tmp->count, tmp->uuid.c_str ()); |
720 | else |
731 | else |
… | |
… | |
722 | |
733 | |
723 | object *head = tmp->head_ (); |
734 | object *head = tmp->head_ (); |
724 | |
735 | |
725 | if (head->inv) |
736 | if (head->inv) |
726 | if ((head->type != CONTAINER && head->type != FLESH) |
737 | if ((head->type != CONTAINER && head->type != FLESH) |
727 | || QUERY_FLAG (ob, FLAG_WIZ)) |
738 | || ob->flag [FLAG_WIZ]) |
728 | buf << head->query_inventory (ob, " "); |
739 | buf << head->query_inventory (ob, " "); |
729 | |
740 | |
730 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !wiz) /* don't continue under the floor */ |
741 | if (tmp->flag [FLAG_IS_FLOOR] && !wiz) /* don't continue under the floor */ |
731 | break; |
742 | break; |
732 | } |
743 | } |
733 | } |
744 | } |
734 | |
745 | |
735 | if (buf.empty ()) |
746 | if (buf.empty ()) |
… | |
… | |
770 | return; |
781 | return; |
771 | |
782 | |
772 | /* If it is an active container, then we should drop all objects |
783 | /* If it is an active container, then we should drop all objects |
773 | * in the container and not the container itself. |
784 | * in the container and not the container itself. |
774 | */ |
785 | */ |
775 | if (op->inv && QUERY_FLAG (op, FLAG_APPLIED)) |
786 | if (op->inv && op->flag [FLAG_APPLIED]) |
776 | { |
787 | { |
777 | int cnt = MAX_ITEM_PER_ACTION; |
788 | int cnt = MAX_ITEM_PER_ACTION; |
778 | |
789 | |
779 | for (object *current = op->inv; current && cnt--; ) |
790 | for (object *current = op->inv; current && cnt--; ) |
780 | { |
791 | { |