… | |
… | |
193 | query_flags (object *op) |
193 | query_flags (object *op) |
194 | { |
194 | { |
195 | unsigned int flags = 0; |
195 | unsigned int flags = 0; |
196 | |
196 | |
197 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
197 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
198 | { |
|
|
199 | switch (op->type) |
198 | switch (op->type) |
200 | { |
199 | { |
201 | case BOW: |
200 | case BOW: |
202 | case WAND: |
201 | case WAND: |
203 | case ROD: |
202 | case ROD: |
204 | case HORN: |
203 | case HORN: |
205 | flags = a_readied; |
204 | flags = a_readied; |
206 | break; |
205 | break; |
207 | case WEAPON: |
206 | case WEAPON: |
208 | flags = a_wielded; |
207 | flags = a_wielded; |
209 | break; |
208 | break; |
210 | case SKILL: |
209 | case SKILL: |
211 | case ARMOUR: |
210 | case ARMOUR: |
212 | case HELMET: |
211 | case HELMET: |
213 | case SHIELD: |
212 | case SHIELD: |
214 | case RING: |
213 | case RING: |
215 | case BOOTS: |
214 | case BOOTS: |
216 | case GLOVES: |
215 | case GLOVES: |
217 | case AMULET: |
216 | case AMULET: |
218 | case GIRDLE: |
217 | case GIRDLE: |
219 | case BRACERS: |
218 | case BRACERS: |
220 | case CLOAK: |
219 | case CLOAK: |
221 | flags = a_worn; |
220 | flags = a_worn; |
222 | break; |
221 | break; |
223 | case CONTAINER: |
222 | case CONTAINER: |
224 | flags = a_active; |
223 | flags = a_active; |
225 | break; |
224 | break; |
226 | default: |
225 | default: |
227 | flags = a_applied; |
226 | flags = a_applied; |
228 | break; |
227 | break; |
229 | } |
228 | } |
230 | } |
|
|
231 | |
229 | |
232 | if (op->type == CONTAINER && ((op->env && op->env->container == op) || (!op->env && QUERY_FLAG (op, FLAG_APPLIED)))) |
230 | if (op->type == CONTAINER && ((op->env && op->env->container == op) || (!op->env && QUERY_FLAG (op, FLAG_APPLIED)))) |
233 | flags |= F_OPEN; |
231 | flags |= F_OPEN; |
234 | |
232 | |
235 | if (QUERY_FLAG (op, FLAG_KNOWN_CURSED)) |
233 | if (QUERY_FLAG (op, FLAG_KNOWN_CURSED)) |
… | |
… | |
341 | if (!pl->ns->update_look) |
339 | if (!pl->ns->update_look) |
342 | { |
340 | { |
343 | LOG (llevDebug, "esrv_draw_look called when update_look was not set (player %s)\n", &ob->name); |
341 | LOG (llevDebug, "esrv_draw_look called when update_look was not set (player %s)\n", &ob->name); |
344 | return; |
342 | return; |
345 | } |
343 | } |
346 | else |
344 | |
347 | pl->ns->update_look = 0; |
345 | pl->ns->update_look = 0; |
348 | |
346 | |
349 | if (QUERY_FLAG (ob, FLAG_REMOVED) |
347 | if (QUERY_FLAG (ob, FLAG_REMOVED) |
350 | || !ob->map |
348 | || !ob->map |
351 | || ob->map->in_memory != MAP_ACTIVE |
349 | || ob->map->in_memory != MAP_ACTIVE |
352 | || out_of_map (ob->map, ob->x, ob->y)) |
350 | || out_of_map (ob->map, ob->x, ob->y)) |
… | |
… | |
381 | } |
379 | } |
382 | |
380 | |
383 | object *tmp = ob->ms ().top; |
381 | object *tmp = ob->ms ().top; |
384 | for (object *last = 0; tmp != last; tmp = tmp->below) |
382 | for (object *last = 0; tmp != last; tmp = tmp->below) |
385 | { |
383 | { |
386 | object *head; |
|
|
387 | |
|
|
388 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !last) |
384 | if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !last) |
389 | { |
385 | { |
390 | last = tmp->below; /* assumes double floor mode */ |
386 | last = tmp->below; /* assumes double floor mode */ |
391 | if (last && QUERY_FLAG (last, FLAG_IS_FLOOR)) |
387 | if (last && QUERY_FLAG (last, FLAG_IS_FLOOR)) |
392 | last = last->below; |
388 | last = last->below; |
… | |
… | |
417 | sl << uint16 (0); |
413 | sl << uint16 (0); |
418 | |
414 | |
419 | break; |
415 | break; |
420 | } |
416 | } |
421 | |
417 | |
422 | if (tmp->head) |
|
|
423 | head = tmp->head; |
|
|
424 | else |
|
|
425 | head = tmp; |
|
|
426 | |
|
|
427 | add_object_to_socklist (*pl->ns, sl, head); |
418 | add_object_to_socklist (*pl->ns, sl, tmp->head_ ()); |
428 | got_one++; |
419 | got_one++; |
429 | |
420 | |
430 | if (sl.length () > MAXSOCKBUF - MAXITEMLEN) |
421 | if (sl.length () > MAXSOCKBUF - MAXITEMLEN) |
431 | { |
422 | { |
432 | pl->ns->send_packet (sl); |
423 | pl->ns->send_packet (sl); |
… | |
… | |
526 | |
517 | |
527 | packet sl ("upditem"); |
518 | packet sl ("upditem"); |
528 | |
519 | |
529 | sl << uint8 (flags); |
520 | sl << uint8 (flags); |
530 | |
521 | |
531 | if (op->head) |
|
|
532 | op = op->head; |
522 | op = op->head_ (); |
533 | |
523 | |
534 | sl << uint32 (op->count); |
524 | sl << uint32 (op->count); |
535 | |
525 | |
536 | if (flags & UPD_LOCATION) |
526 | if (flags & UPD_LOCATION) |
537 | sl << uint32 (op->env ? op->env->count : 0); |
527 | sl << uint32 (op->env ? op->env->count : 0); |
… | |
… | |
625 | esrv_send_item (object *pl, object *op) |
615 | esrv_send_item (object *pl, object *op) |
626 | { |
616 | { |
627 | if (!pl->contr->ns) |
617 | if (!pl->contr->ns) |
628 | return; |
618 | return; |
629 | |
619 | |
630 | /* If this is not the player object, do some more checks */ |
|
|
631 | if (op != pl) |
|
|
632 | { |
|
|
633 | /* We only send 'visible' objects to the client */ |
620 | /* We only send 'visible' objects to the client, and sometimes the player */ |
634 | if (!op->client_visible ()) |
621 | if (!op->client_visible () && op->type != PLAYER) |
635 | return; |
622 | return; |
636 | |
|
|
637 | /* if the item is on the ground, mark that the look needs to |
|
|
638 | * be updated. |
|
|
639 | */ |
|
|
640 | if (!op->env) |
|
|
641 | { |
|
|
642 | pl->contr->ns->floorbox_update (); |
|
|
643 | return; |
|
|
644 | } |
|
|
645 | } |
|
|
646 | |
623 | |
647 | packet sl; |
624 | packet sl; |
648 | |
625 | |
649 | sl.printf ("item%d ", pl->contr->ns->itemcmd); |
626 | sl.printf ("item%d ", pl->contr->ns->itemcmd); |
650 | |
627 | |
651 | if (op->head) |
|
|
652 | op = op->head; |
628 | op = op->head_ (); |
653 | |
629 | |
654 | sl << uint32 (op->env ? op->env->count : 0); |
630 | sl << uint32 (op->env ? op->env->count : 0); |
655 | |
631 | |
656 | add_object_to_socklist (*pl->contr->ns, sl, op); |
632 | add_object_to_socklist (*pl->contr->ns, sl, op); |
657 | |
633 | |
… | |
… | |
934 | op->failmsg ("Only dropped some items, can't drop that many items at once."); |
910 | op->failmsg ("Only dropped some items, can't drop that many items at once."); |
935 | } |
911 | } |
936 | else |
912 | else |
937 | drop_object (pl, op, nrof); |
913 | drop_object (pl, op, nrof); |
938 | |
914 | |
939 | update_after_inventory_change (pl); |
|
|
940 | |
|
|
941 | return; |
915 | return; |
942 | } |
916 | } |
943 | else if (to == pl->count) |
917 | else if (to == pl->count) |
944 | { /* pick it up to the inventory */ |
918 | { /* pick it up to the inventory */ |
945 | /* return if player has already picked it up */ |
919 | /* return if player has already picked it up */ |
… | |
… | |
961 | /* put_object_in_sack presumes that necessary sanity checking |
935 | /* put_object_in_sack presumes that necessary sanity checking |
962 | * has already been done (eg, it can be picked up and fits in |
936 | * has already been done (eg, it can be picked up and fits in |
963 | * in a sack, so check for those things. We should also check |
937 | * in a sack, so check for those things. We should also check |
964 | * an make sure env is in fact a container for that matter. |
938 | * an make sure env is in fact a container for that matter. |
965 | */ |
939 | */ |
966 | if (env->type == CONTAINER && can_pick (pl, op) && sack_can_hold (pl, env, op, nrof)) |
940 | if (env->type == CONTAINER |
967 | { |
941 | && can_pick (pl, op) |
|
|
942 | && sack_can_hold (pl, env, op, nrof)) |
968 | put_object_in_sack (pl, env, op, nrof); |
943 | put_object_in_sack (pl, env, op, nrof); |
969 | update_after_inventory_change (pl); |
|
|
970 | } |
|
|
971 | } |
944 | } |
972 | |
945 | |