1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
271 | if (QUERY_FLAG (head, FLAG_ANIMATE) && !ns.anims_sent[head->animation_id]) |
271 | if (QUERY_FLAG (head, FLAG_ANIMATE) && !ns.anims_sent[head->animation_id]) |
272 | ns.send_animation (head->animation_id); |
272 | ns.send_animation (head->animation_id); |
273 | |
273 | |
274 | sl << uint32 (head->count) |
274 | sl << uint32 (head->count) |
275 | << uint32 (flags) |
275 | << uint32 (flags) |
276 | << uint32 (QUERY_FLAG (head, FLAG_NO_PICK) ? -1 : WEIGHT (head)) |
276 | << uint32 (QUERY_FLAG (head, FLAG_NO_PICK) ? -1 : head->client_weight ()) |
277 | << uint32 (head->face); |
277 | << uint32 (head->face); |
278 | |
278 | |
279 | if (!head->custom_name) |
279 | if (!head->custom_name) |
280 | { |
280 | { |
281 | strncpy (item_n, query_base_name (head, 0), 127); |
281 | strncpy (item_n, query_base_name (head, 0), 127); |
… | |
… | |
346 | else |
346 | else |
347 | pl->ns->update_look = 0; |
347 | pl->ns->update_look = 0; |
348 | |
348 | |
349 | if (QUERY_FLAG (ob, FLAG_REMOVED) |
349 | if (QUERY_FLAG (ob, FLAG_REMOVED) |
350 | || !ob->map |
350 | || !ob->map |
351 | || ob->map->in_memory != MAP_IN_MEMORY |
351 | || ob->map->in_memory != MAP_ACTIVE |
352 | || out_of_map (ob->map, ob->x, ob->y)) |
352 | || out_of_map (ob->map, ob->x, ob->y)) |
353 | return; |
353 | return; |
354 | |
354 | |
355 | pl->ns->send_packet ("delinv 0"); |
355 | pl->ns->send_packet ("delinv 0"); |
356 | |
356 | |
… | |
… | |
506 | */ |
506 | */ |
507 | void |
507 | void |
508 | esrv_update_item (int flags, object *pl, object *op) |
508 | esrv_update_item (int flags, object *pl, object *op) |
509 | { |
509 | { |
510 | /* If we have a request to send the player item, skip a few checks. */ |
510 | /* If we have a request to send the player item, skip a few checks. */ |
511 | if (op != pl) |
|
|
512 | { |
|
|
513 | if (!op->client_visible ()) |
511 | if (op != pl && !op->client_visible ()) |
514 | return; |
512 | return; |
515 | /* we remove the check for op->env, because in theory, the object |
|
|
516 | * is hopefully in the same place, so the client should preserve |
|
|
517 | * order. |
|
|
518 | */ |
|
|
519 | } |
|
|
520 | |
513 | |
521 | client *ns = pl->contr->ns; |
514 | client *ns = pl->contr->ns; |
522 | if (!ns) |
515 | if (!ns) |
523 | return; |
516 | return; |
524 | |
517 | |
… | |
… | |
546 | if (flags & UPD_FLAGS) |
539 | if (flags & UPD_FLAGS) |
547 | sl << uint32 (query_flags (op)); |
540 | sl << uint32 (query_flags (op)); |
548 | |
541 | |
549 | if (flags & UPD_WEIGHT) |
542 | if (flags & UPD_WEIGHT) |
550 | { |
543 | { |
551 | sint32 weight = WEIGHT (op); |
544 | sint32 weight = op->flag [FLAG_NO_PICK] ? -1 : op->client_weight (); |
552 | |
545 | |
553 | sl << uint32 (QUERY_FLAG (op, FLAG_NO_PICK) ? -1 : weight); |
|
|
554 | |
|
|
555 | if (pl == op) |
546 | if (op) |
556 | ns->last_weight = weight; |
547 | ns->last_weight = weight; |
|
|
548 | |
|
|
549 | sl << uint32 (weight); |
557 | } |
550 | } |
558 | |
551 | |
559 | if (flags & UPD_FACE) |
552 | if (flags & UPD_FACE) |
560 | { |
553 | { |
561 | ns->send_face (op->face, -50); |
554 | ns->send_face (op->face, -50); |
… | |
… | |
635 | return; |
628 | return; |
636 | |
629 | |
637 | /* If this is not the player object, do some more checks */ |
630 | /* If this is not the player object, do some more checks */ |
638 | if (op != pl) |
631 | if (op != pl) |
639 | { |
632 | { |
640 | /* We only send 'visibile' objects to the client */ |
633 | /* We only send 'visible' objects to the client */ |
641 | if (!op->client_visible ()) |
634 | if (!op->client_visible ()) |
642 | return; |
635 | return; |
643 | |
636 | |
644 | /* if the item is on the ground, mark that the look needs to |
637 | /* if the item is on the ground, mark that the look needs to |
645 | * be updated. |
638 | * be updated. |
… | |
… | |
665 | pl->contr->ns->send_packet (sl); |
658 | pl->contr->ns->send_packet (sl); |
666 | SET_FLAG (op, FLAG_CLIENT_SENT); |
659 | SET_FLAG (op, FLAG_CLIENT_SENT); |
667 | } |
660 | } |
668 | |
661 | |
669 | /** |
662 | /** |
670 | * Tells the client to delete an item. Uses the item |
663 | * Tells the client to delete an item. |
671 | * command with a -1 location. |
|
|
672 | */ |
664 | */ |
673 | void |
665 | void |
674 | esrv_del_item (player *pl, int tag) |
666 | esrv_del_item (player *pl, int tag) |
675 | { |
667 | { |
676 | if (!pl->ns) |
668 | if (!pl->ns) |
… | |
… | |
800 | tag_t tag = net_uint32 ((uint8 *)data + 1); |
792 | tag_t tag = net_uint32 ((uint8 *)data + 1); |
801 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
793 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
802 | |
794 | |
803 | if (!op) |
795 | if (!op) |
804 | { |
796 | { |
805 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to lock/unlock"); |
797 | pl->failmsg ("Could not find object to lock/unlock"); |
806 | return; |
798 | return; |
807 | } |
799 | } |
808 | |
800 | |
809 | if (!flag) |
801 | if (!flag) |
810 | CLEAR_FLAG (op, FLAG_INV_LOCKED); |
802 | CLEAR_FLAG (op, FLAG_INV_LOCKED); |
… | |
… | |
821 | tag_t tag = net_uint32 ((uint8 *)data); |
813 | tag_t tag = net_uint32 ((uint8 *)data); |
822 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
814 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
823 | |
815 | |
824 | if (!op) |
816 | if (!op) |
825 | { |
817 | { |
826 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to mark"); |
818 | pl->failmsg ("Could not find object to mark"); |
827 | return; |
819 | return; |
828 | } |
820 | } |
829 | |
821 | |
830 | pl->mark = op; |
822 | pl->mark = op; |
831 | new_draw_info_format (NDI_UNIQUE, 0, pl->ob, "Marked item %s", query_name (op)); |
823 | pl->ob->statusmsg (format ("Marked item %s", query_name (op))); |
832 | } |
824 | } |
833 | |
825 | |
834 | /** |
826 | /** |
835 | * look_at prints items on the specified square. |
827 | * look_at prints items on the specified square. |
836 | * |
828 | * |
… | |
… | |
923 | /* If it is an active container, then we should drop all objects |
915 | /* If it is an active container, then we should drop all objects |
924 | * in the container and not the container itself. |
916 | * in the container and not the container itself. |
925 | */ |
917 | */ |
926 | if (op->inv && QUERY_FLAG (op, FLAG_APPLIED)) |
918 | if (op->inv && QUERY_FLAG (op, FLAG_APPLIED)) |
927 | { |
919 | { |
928 | object *current, *next; |
920 | int cnt = MAX_ITEM_PER_DROP; |
929 | |
921 | |
930 | for (current = op->inv; current != NULL; current = next) |
922 | for (object *current = op->inv; current; ) |
931 | { |
923 | { |
932 | next = current->below; |
924 | object *next = current->below; |
|
|
925 | |
933 | drop_object (pl, current, 0); |
926 | drop_object (pl, current, 0); |
|
|
927 | |
|
|
928 | if (--cnt <= 0) break; |
|
|
929 | |
|
|
930 | current = next; |
934 | } |
931 | } |
935 | |
932 | |
936 | esrv_update_item (UPD_WEIGHT, pl, op); |
933 | if (cnt <= 0) |
|
|
934 | op->failmsg ("Only dropped some items, can't drop that many items at once."); |
937 | } |
935 | } |
938 | else |
936 | else |
939 | drop_object (pl, op, nrof); |
937 | drop_object (pl, op, nrof); |
940 | |
938 | |
941 | return; |
939 | return; |
… | |
… | |
961 | /* put_object_in_sack presumes that necessary sanity checking |
959 | /* put_object_in_sack presumes that necessary sanity checking |
962 | * has already been done (eg, it can be picked up and fits in |
960 | * 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 |
961 | * 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. |
962 | * an make sure env is in fact a container for that matter. |
965 | */ |
963 | */ |
966 | if (env->type == CONTAINER && can_pick (pl, op) && sack_can_hold (pl, env, op, nrof)) |
964 | if (env->type == CONTAINER |
|
|
965 | && can_pick (pl, op) |
|
|
966 | && sack_can_hold (pl, env, op, nrof)) |
967 | put_object_in_sack (pl, env, op, nrof); |
967 | put_object_in_sack (pl, env, op, nrof); |
968 | } |
968 | } |
969 | |
969 | |