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.58 by root, Tue Apr 15 14:21:04 2008 UTC vs.
Revision 1.61 by root, Tue Apr 22 07:28:05 2008 UTC

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);
506 */ 506 */
507void 507void
508esrv_update_item (int flags, object *pl, object *op) 508esrv_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 */
673void 665void
674esrv_del_item (player *pl, int tag) 666esrv_del_item (player *pl, int tag)
675{ 667{
676 if (!pl->ns) 668 if (!pl->ns)
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;
929
930 int cnt = MAX_ITEM_PER_DROP; 920 int cnt = MAX_ITEM_PER_DROP;
931 921
932 for (current = op->inv; current != NULL; current = next) 922 for (object *current = op->inv; current; )
933 { 923 {
934 next = current->below; 924 object *next = current->below;
925
935 drop_object (pl, current, 0); 926 drop_object (pl, current, 0);
936 927
937 if (--cnt <= 0) break; 928 if (--cnt <= 0) break;
929
930 current = next;
938 } 931 }
939 932
940 if (cnt <= 0) 933 if (cnt <= 0)
941 op->failmsg ("Only dropped some items, can't drop that many items at once."); 934 op->failmsg ("Only dropped some items, can't drop that many items at once.");
942
943 esrv_update_item (UPD_WEIGHT, pl, op);
944 } 935 }
945 else 936 else
946 drop_object (pl, op, nrof); 937 drop_object (pl, op, nrof);
947 938
948 update_after_inventory_change (pl); 939 update_after_inventory_change (pl);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines