--- deliantra/server/socket/item.C 2007/06/03 17:05:36 1.46 +++ deliantra/server/socket/item.C 2007/07/29 19:11:47 1.52 @@ -1,23 +1,22 @@ /* - * This file is part of Crossfire TRT, the Multiplayer Online Role Playing Game. + * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. * * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team * Copyright (©) 1992,2007 Frank Tore Johansen * - * Crossfire TRT 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. + * Crossfire TRT 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 3 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. + * 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 Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . * * The authors can be reached via e-mail to */ @@ -266,7 +265,7 @@ if (QUERY_FLAG (head, FLAG_NO_PICK)) flags |= F_NOPICK; - ns.send_face (head->face); + ns.send_face (head->face, -50); ns.flush_fx (); if (QUERY_FLAG (head, FLAG_ANIMATE) && !ns.anims_sent[head->animation_id]) @@ -360,7 +359,7 @@ sl << uint32 (0); - pl->ns->send_face (empty_face); + pl->ns->send_face (empty_face, -50); pl->ns->flush_fx (); if (pl->ns->look_position) @@ -428,7 +427,7 @@ add_object_to_socklist (*pl->ns, sl, head); got_one++; - if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN)) + if (sl.length () > MAXSOCKBUF - MAXITEMLEN) { pl->ns->send_packet (sl); @@ -482,7 +481,7 @@ * items (especially with some of the bags out there) to * overflow the buffer. IF so, send multiple item commands. */ - if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN)) + if (sl.length () > MAXSOCKBUF - MAXITEMLEN) { pl->contr->ns->send_packet (sl); @@ -559,7 +558,7 @@ if (flags & UPD_FACE) { - ns->send_face (op->face); + ns->send_face (op->face, -50); ns->flush_fx (); sl << uint32 (op->face); } @@ -838,63 +837,60 @@ * [ removed EARTHWALL check and added check for containers inventory. * Tero.Haatanen@lut.fi ] */ -void -look_at (object *op, int dx, int dy) +static void +look_at (player *pl, int dx, int dy) { - object *tmp; - int flag = 0; - sint16 x, y; - maptile *m; - - x = op->x + dx; - y = op->y + dy; + object *ob = pl->ob; - if (out_of_map (op->map, x, y)) - return; + maptile *m = pl->observe->map; + sint16 x = pl->observe->x + dx; + sint16 y = pl->observe->y + dy; - m = get_map_from_coord (op->map, &x, &y); if (!m) return; - for (tmp = GET_MAP_OB (m, x, y); tmp && tmp->above; tmp = tmp->above) - ; + if (!xy_normalise (m, x, y)) + { + new_draw_info (NDI_UNIQUE, 0, ob, "You see nothing there."); + return; + } - for (; tmp; tmp = tmp->below) + int flag = 0; + + for (object *tmp = m->at (x, y).top; tmp; tmp = tmp->below) { - if (tmp->invisible && !QUERY_FLAG (op, FLAG_WIZ)) + if (tmp->invisible && !QUERY_FLAG (ob, FLAG_WIZ)) continue; if (!flag) { if (dx || dy) - new_draw_info (NDI_UNIQUE, 0, op, "There you see:"); + new_draw_info (NDI_UNIQUE, 0, ob, "There you see:"); else - { - clear_win_info (op); - new_draw_info (NDI_UNIQUE, 0, op, "You see:"); - } + new_draw_info (NDI_UNIQUE, 0, ob, "You see:"); + flag = 1; } - if (QUERY_FLAG (op, FLAG_WIZ)) - new_draw_info_format (NDI_UNIQUE, 0, op, "- %s (%d).", query_name (tmp), tmp->count); + if (QUERY_FLAG (ob, FLAG_WIZ)) + new_draw_info_format (NDI_UNIQUE, 0, ob, "- %s (%d).", query_name (tmp), tmp->count); else - new_draw_info_format (NDI_UNIQUE, 0, op, "- %s.", query_name (tmp)); + new_draw_info_format (NDI_UNIQUE, 0, ob, "- %s.", query_name (tmp)); if (((tmp->inv != NULL || (tmp->head && tmp->head->inv)) && - (tmp->type != CONTAINER && tmp->type != FLESH)) || QUERY_FLAG (op, FLAG_WIZ)) - inventory (op, tmp->head == NULL ? tmp : tmp->head); + (tmp->type != CONTAINER && tmp->type != FLESH)) || QUERY_FLAG (ob, FLAG_WIZ)) + inventory (ob, tmp->head == NULL ? tmp : tmp->head); - if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !QUERY_FLAG (op, FLAG_WIZ)) /* don't continue under the floor */ + if (QUERY_FLAG (tmp, FLAG_IS_FLOOR) && !QUERY_FLAG (ob, FLAG_WIZ)) /* don't continue under the floor */ break; } if (!flag) { if (dx || dy) - new_draw_info (NDI_UNIQUE, 0, op, "You see nothing there."); + new_draw_info (NDI_UNIQUE, 0, ob, "You see nothing there."); else - new_draw_info (NDI_UNIQUE, 0, op, "You see nothing."); + new_draw_info (NDI_UNIQUE, 0, ob, "You see nothing."); } } @@ -902,21 +898,25 @@ void LookAt (char *buf, int len, player *pl) { - int dx, dy; char *cp; - dx = atoi (buf); + int dx = atoi (buf); if (!(cp = strchr (buf, ' '))) return; - dy = atoi (cp); - if (fabs (dx) > pl->ns->mapx / 2 || fabs (dy) > pl->ns->mapy / 2) - return; + int dy = atoi (cp); - if (pl->blocked_los[dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2]) - return; + if (player *opl = pl->observe->contr) + if (client *ns = opl->ns) + { + if (fabs (dx) > ns->mapx / 2 || fabs (dy) > ns->mapy / 2) + return; + + if (opl->blocked_los[dx + ns->mapx / 2][dy + ns->mapy / 2]) + return; + } - look_at (pl->ob, dx, dy); + look_at (pl, dx, dy); } /** Move an object to a new location */