--- deliantra/server/socket/item.C 2007/01/06 14:42:31 1.30 +++ deliantra/server/socket/item.C 2007/01/09 21:32:43 1.32 @@ -1,26 +1,26 @@ /* - CrossFire, A Multiplayer game for X-windows - - Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team - Copyright (C) 2002 Mark Wedel & Crossfire Development Team - Copyright (C) 1992 Frank Tore Johansen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - The author can be reached via e-mail to -*/ + * CrossFire, A Multiplayer game for X-windows + * + * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team + * Copyright (C) 2002 Mark Wedel & Crossfire Development Team + * Copyright (C) 1992 Frank Tore Johansen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * The author can be reached via e-mail to + */ /** * \file @@ -28,13 +28,13 @@ * * \date 2003-12-02 * - * This containes item logic for client/server. It doesn't contain + * This contains item logic for client/server. It doesn't contain * the actual commands that send the data, but does contain * the logic for what items should be sent. */ #include -#include /* LOOK_OBJ */ +#include #include /** This is the maximum number of bytes we expect any one item to take up */ @@ -327,7 +327,6 @@ SET_FLAG (head, FLAG_CLIENT_SENT); } - /** * Send the look window. Don't need to do animations here * This sends all the faces to the client, not just updates. This is @@ -336,7 +335,6 @@ void esrv_draw_look (object *pl) { - object *tmp, *last; int got_one = 0, start_look = 0, end_look = 0; char buf[MAX_BUF]; @@ -354,9 +352,6 @@ || out_of_map (pl->map, pl->x, pl->y)) return; - for (tmp = GET_MAP_OB (pl->map, pl->x, pl->y); tmp && tmp->above; tmp = tmp->above) - ; - pl->contr->ns->send_packet ("delinv 0"); packet sl; @@ -385,7 +380,8 @@ sl << uint16 (0); } - for (last = NULL; tmp != last; tmp = tmp->below) + object *tmp = pl->ms ().top; + for (object *last = 0; tmp != last; tmp = tmp->below) { object *head; @@ -396,7 +392,7 @@ last = last->below; } - if (LOOK_OBJ (tmp)) + if (tmp->client_visible ()) { if (++start_look < pl->contr->ns->look_position) continue; @@ -454,10 +450,8 @@ void esrv_send_inventory (object *pl, object *op) { - object *tmp; int got_one = 0; - pl->contr->ns->send_packet_printf ("delinv %d", op->count); packet sl; @@ -465,7 +459,7 @@ sl << uint32 (op->count); - for (tmp = op->inv; tmp; tmp = tmp->below) + for (object *tmp = op->inv; tmp; tmp = tmp->below) { object *head; @@ -474,7 +468,7 @@ else head = tmp; - if (LOOK_OBJ (head)) + if (head->client_visible ()) { add_object_to_socklist (*pl->contr->ns, sl, head); @@ -493,7 +487,7 @@ sl << uint32 (op->count); got_one = 0; } - } /* If LOOK_OBJ() */ + } } if (got_one) @@ -514,7 +508,7 @@ /* If we have a request to send the player item, skip a few checks. */ if (op != pl) { - if (!LOOK_OBJ (op)) + if (!op->client_visible ()) return; /* we remove the check for op->env, because in theory, the object * is hopefully in the same place, so the client should preserve @@ -522,6 +516,10 @@ */ } + client *ns = pl->contr->ns; + if (!ns) + return; + if (!QUERY_FLAG (op, FLAG_CLIENT_SENT)) { /* FLAG_CLIENT_SENT is debug only. We are using it to see where @@ -553,13 +551,13 @@ sl << uint32 (QUERY_FLAG (op, FLAG_NO_PICK) ? -1 : weight); if (pl == op) - op->contr->last_weight = weight; + ns->last_weight = weight; } if (flags & UPD_FACE) { - if (!(pl->contr->ns->faces_sent[op->face->number] & NS_FACESENT_FACE)) - esrv_send_face (pl->contr->ns, op->face->number, 0); + if (!(ns->faces_sent[op->face->number] & NS_FACESENT_FACE)) + esrv_send_face (ns, op->face->number, 0); sl << uint32 (op->face->number); } @@ -636,8 +634,9 @@ if (op != pl) { /* We only send 'visibile' objects to the client */ - if (!LOOK_OBJ (op)) + if (!op->client_visible ()) return; + /* if the item is on the ground, mark that the look needs to * be updated. */