--- deliantra/server/socket/item.C 2008/05/06 19:47:56 1.67 +++ deliantra/server/socket/item.C 2008/10/28 12:48:23 1.72 @@ -39,146 +39,6 @@ /** This is the maximum number of bytes we expect any one item to take up */ #define MAXITEMLEN 300 -#if 0 -tag_t -client_container::tag () const -{ - switch (type) - { - case CC_INVENTORY: - return ns->pl->count; - case CC_MAPSPACE: - return 0; - case CC_CONTAINER: - return env->count; - } - - abort (); -} - -void -client_container::clear () -{ - switch (type) - { - case CC_INVENTORY: - abort (); - - case CC_MAPSPACE: - case CC_CONTAINER: - ns->send_packet_printf ("delinv %d", tag ()); - break; - } - - for (iterator i = begin (); i != end (); ++i) - i->op->seen_by = 0; - - vector< refitem, slice_allocator >::clear (); -} - -inline iterator -client_container::merge_item (iterator i, object *op) -{ - if (i != end () && i->op == op) - return ++i; - - if (op->seen_by) - return; // seen by another entity already - - op->seen_by = this; - - refitem ref; - ref.op = op; - - return insert (i, ref); -} - -void -client_container::update (int offset) -{ - iterator i = begin (); - - switch (type) - { - case CC_INVENTORY: - case CC_CONTAINER: - { - object *env = type == CC_INVENTORY - ? ns->pl->ob - : this->env; - - // pass 1, erase all objects no longer in container - for (iterator j = begin (); j != end (); ++j) - if (j->op->env != env) - { - j->op->seen_by = 0; - erase (j); - } - - // pass 2 merge items - for (object *op = env->inv; op; op = op->below) - { - if (--offset < 0) - i = merge_item (i, op); - else if (offset < -FLOORBOX_PAGESIZE) - break; - } - } - break; - - case CC_MAPSPACE: - { - // pass 1, erase all objects no longer on space - for (iterator j = begin (); j != end (); ++j) - if (j->op->x != x || j->op->y != y || j->op->map != map) - { - j->op->seen_by = 0; - erase (j); - } - - // pass 2 merge items - for (object *op = GET_MAP_OB (map, x, y); op; op = op->above) - { - if (--offset < 0) - i = merge_item (i, op); - else if (offset < -FLOORBOX_PAGESIZE) - break; - } - } - break; - } - - // pass 3, erase all extra items - for (iterator j = i; j != end (); ++j) - j->op->seen_by = 0; - - if (i != end ()) - erase (i, end ()); -} - -void -client_container::set_mapspace (maptile *map, int x, int y) -{ - if (type == CC_MAPSPACE - && this->map == map - && this->x == x - && this->y == y) - return; - - clear (); - - type = CC_MAPSPACE; - this->map = map; - this->x = x; - this->y = y; -} - -void -client_container::set_container (object *env) -{ -} -#endif - /******************************************************************************* * * Functions related to sending object data to the client. @@ -306,8 +166,6 @@ if (ns.itemcmd == 2) sl << uint16 (head->client_type); - - SET_FLAG (head, FLAG_CLIENT_SENT); } static faceidx @@ -527,15 +385,6 @@ if (!ns) return; - if (!QUERY_FLAG (op, FLAG_CLIENT_SENT)) - { - /* FLAG_CLIENT_SENT is debug only. We are using it to see where - * this is happening - we can set a breakpoint here in the debugger - * and track back the call. - */ - LOG (llevDebug, "We have not sent item %s (%d)\n", &op->name, op->count); - } - packet sl ("upditem"); sl << uint8 (flags); @@ -552,9 +401,9 @@ if (flags & UPD_WEIGHT) { - sint32 weight = op->flag [FLAG_NO_PICK] ? -1 : op->client_weight (); + sint32 weight = op->client_weight (); - if (op) + if (op == pl) ns->last_weight = weight; sl << uint32 (weight); @@ -653,7 +502,6 @@ add_object_to_socklist (*pl->contr->ns, sl, op); pl->contr->ns->send_packet (sl); - SET_FLAG (op, FLAG_CLIENT_SENT); } /** @@ -752,7 +600,8 @@ std::string s = op->describe (pl->ob); packet sl ("ex"); - sl << ber32 (tag) << s.c_str (); + sl << ber32 (tag) + << data (*pl->expand_cfpod (s.c_str ())); pl->ns->send_packet (sl); } @@ -847,16 +696,16 @@ continue; if (QUERY_FLAG (ob, FLAG_WIZ)) - buf.printf ("- %s (%d).\n", query_name (tmp), tmp->count); + buf.printf (" - %s (%d).\n", query_name (tmp), tmp->count); else - buf.printf ("- %s.\n", query_name (tmp)); + buf.printf (" - %s.\n", query_name (tmp)); object *head = tmp->head_ (); if (head->inv) if ((head->type != CONTAINER && head->type != FLESH) || QUERY_FLAG (ob, FLAG_WIZ)) - buf << head->query_inventory (ob, " "); + buf << head->query_inventory (ob, " "); if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !QUERY_FLAG (ob, FLAG_WIZ)) /* don't continue under the floor */ break;