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.94 by root, Sun Apr 11 23:48:57 2010 UTC vs.
Revision 1.103 by root, Thu Jan 19 21:18:34 2017 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,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the Affero GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 20 * <http://www.gnu.org/licenses/>.
21 * 21 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 23 */
24 24
25/** 25/**
26 * \file 26 * \file
142 142
143 *len = sl.cur - len - 1; 143 *len = sl.cur - len - 1;
144 } 144 }
145 else 145 else
146 { 146 {
147 int len = min (head->custom_name.length (), 127); 147 int len = min (127, head->custom_name.length ());
148 148
149 sl << uint8 (len * 2 + 1) 149 sl << uint8 (len * 2 + 1)
150 << data (head->custom_name, len) 150 << data (head->custom_name, len)
151 << uint8 (0) 151 << uint8 (0)
152 << data (head->custom_name, len); 152 << data (head->custom_name, len);
178 178
179#define FINGER_UP "finger_up.x11" 179#define FINGER_UP "finger_up.x11"
180#define FINGER_DOWN "finger_down.x11" 180#define FINGER_DOWN "finger_down.x11"
181 181
182/** 182/**
183 * Send the look window. Don't need to do animations here 183 * Send the look window. Don't need to do animations here
184 * This sends all the faces to the client, not just updates. This is 184 * This sends all the faces to the client, not just updates. This is
185 * because object ordering would otherwise be inconsistent. 185 * because object ordering would otherwise be inconsistent.
186 */ 186 */
187void 187void
188esrv_draw_look (player *pl) 188esrv_draw_look (player *pl)
207 pl->ns->update_look = 0; 207 pl->ns->update_look = 0;
208 pl->ns->need_delinv0 = 1; 208 pl->ns->need_delinv0 = 1;
209 209
210 if (ob->flag [FLAG_REMOVED] 210 if (ob->flag [FLAG_REMOVED]
211 || !ob->map 211 || !ob->map
212 || ob->map->in_memory != MAP_ACTIVE 212 || ob->map->state != MAP_ACTIVE
213 || out_of_map (ob->map, ob->x, ob->y)) 213 || out_of_map (ob->map, ob->x, ob->y))
214 return; 214 return;
215 215
216 packet sl; 216 packet sl;
217 sl.printf ("item%d ", pl->ns->itemcmd); 217 sl.printf ("item%d ", pl->ns->itemcmd);
627 pl->ns->look_position = tag & 0x7fffffff; 627 pl->ns->look_position = tag & 0x7fffffff;
628 pl->ns->floorbox_update (); 628 pl->ns->floorbox_update ();
629 return; 629 return;
630 } 630 }
631 631
632 // the object might be legally gone already
632 object *op = esrv_get_ob_from_count (pl->ob, tag); 633 if (object *op = esrv_get_ob_from_count (pl->ob, tag))
633
634 if (!op)
635 {
636 LOG (llevDebug, "Player '%s' tried to apply the unknown object (%d)\n", &pl->ob->name, tag);
637 return;
638 }
639
640 pl->ob->apply (op, AP_TOGGLE); 634 pl->ob->apply (op, AP_TOGGLE);
641} 635}
642 636
643/** Client wants to lock some object. Lets do so. */ 637/** Client wants to lock some object. Lets do so. */
644void 638void
645LockItem (char *data, int len, player *pl) 639LockItem (char *data, int len, player *pl)
648 tag_t tag = net_uint32 ((uint8 *)data + 1); 642 tag_t tag = net_uint32 ((uint8 *)data + 1);
649 object *op = esrv_get_ob_from_count (pl->ob, tag); 643 object *op = esrv_get_ob_from_count (pl->ob, tag);
650 644
651 if (!op) 645 if (!op)
652 { 646 {
653 pl->failmsg ("Could not find object to lock/unlock"); 647 pl->failmsgf ("Could not find object %d to lock/unlock", tag);
654 return; 648 return;
655 } 649 }
656 650
657 if (!flag) 651 if (!flag)
658 op->clr_flag (FLAG_INV_LOCKED); 652 op->clr_flag (FLAG_INV_LOCKED);
669 tag_t tag = net_uint32 ((uint8 *)data); 663 tag_t tag = net_uint32 ((uint8 *)data);
670 object *op = esrv_get_ob_from_count (pl->ob, tag); 664 object *op = esrv_get_ob_from_count (pl->ob, tag);
671 665
672 if (!op) 666 if (!op)
673 { 667 {
674 pl->failmsg ("Could not find object to mark"); 668 pl->failmsgf ("Could not find object %d to mark", tag);
675 return; 669 return;
676 } 670 }
677 671
678 pl->mark = op; 672 pl->mark = op;
679 pl->ob->statusmsg (format ("Marked item %s", query_name (op))); 673 pl->ob->statusmsg (format ("Marked item %s", query_name (op)));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines