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 (©) 2018 Marc Alexander Lehmann / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * 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 |
6 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
8 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * 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 |
10 | * 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 |
11 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
12 | * option) any later version. |
12 | * |
13 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
17 | * GNU General Public License for more details. |
17 | * |
18 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * 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 |
20 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
21 | * <http://www.gnu.org/licenses/>. |
21 | * |
22 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
24 | */ |
24 | |
25 | |
25 | /** |
26 | /** |
26 | * \file |
27 | * \file |
… | |
… | |
46 | * |
47 | * |
47 | ******************************************************************************/ |
48 | ******************************************************************************/ |
48 | |
49 | |
49 | /** |
50 | /** |
50 | * This is a similar to query_name, but returns flags |
51 | * This is a similar to query_name, but returns flags |
51 | * to be sent to client. |
52 | * to be sent to client. |
52 | */ |
53 | */ |
53 | static unsigned int |
54 | static unsigned int |
54 | query_flags (object *op) |
55 | query_flags (object *op) |
55 | { |
56 | { |
56 | unsigned int flags = 0; |
57 | unsigned int flags = 0; |
… | |
… | |
134 | if (!head->custom_name) |
135 | if (!head->custom_name) |
135 | { |
136 | { |
136 | const char *name; |
137 | const char *name; |
137 | uint8 *len = sl.cur++; // patch up length later |
138 | uint8 *len = sl.cur++; // patch up length later |
138 | |
139 | |
139 | name = query_base_name (head, 0); sl << data (name, min (127, strlen (name))); |
140 | name = query_base_name (head, 0); sl << data_n (name, min (127, strlen (name))); |
140 | sl << uint8 (0); |
141 | sl << uint8 (0); |
141 | name = query_base_name (head, 1); sl << data (name, min (127, strlen (name))); |
142 | name = query_base_name (head, 1); sl << data_n (name, min (127, strlen (name))); |
142 | |
143 | |
143 | *len = sl.cur - len - 1; |
144 | *len = sl.cur - len - 1; |
144 | } |
145 | } |
145 | else |
146 | else |
146 | { |
147 | { |
147 | int len = min (head->custom_name.length (), 127); |
148 | int len = min (127, head->custom_name.length ()); |
148 | |
149 | |
149 | sl << uint8 (len * 2 + 1) |
150 | sl << uint8 (len * 2 + 1) |
150 | << data (head->custom_name, len) |
151 | << data_n (head->custom_name, len) |
151 | << uint8 (0) |
152 | << uint8 (0) |
152 | << data (head->custom_name, len); |
153 | << data_n (head->custom_name, len); |
153 | } |
154 | } |
154 | |
155 | |
155 | sl << uint16 (head->animation_id); |
156 | sl << uint16 (head->animation_id); |
156 | |
157 | |
157 | int anim_speed = !head->flag [FLAG_ANIMATE] ? 0 |
158 | int anim_speed = !head->flag [FLAG_ANIMATE] ? 0 |
… | |
… | |
178 | |
179 | |
179 | #define FINGER_UP "finger_up.x11" |
180 | #define FINGER_UP "finger_up.x11" |
180 | #define FINGER_DOWN "finger_down.x11" |
181 | #define FINGER_DOWN "finger_down.x11" |
181 | |
182 | |
182 | /** |
183 | /** |
183 | * Send the look window. Don't need to do animations here |
184 | * 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 |
185 | * This sends all the faces to the client, not just updates. This is |
185 | * because object ordering would otherwise be inconsistent. |
186 | * because object ordering would otherwise be inconsistent. |
186 | */ |
187 | */ |
187 | void |
188 | void |
188 | esrv_draw_look (player *pl) |
189 | esrv_draw_look (player *pl) |
… | |
… | |
207 | pl->ns->update_look = 0; |
208 | pl->ns->update_look = 0; |
208 | pl->ns->need_delinv0 = 1; |
209 | pl->ns->need_delinv0 = 1; |
209 | |
210 | |
210 | if (ob->flag [FLAG_REMOVED] |
211 | if (ob->flag [FLAG_REMOVED] |
211 | || !ob->map |
212 | || !ob->map |
212 | || ob->map->in_memory != MAP_ACTIVE |
213 | || ob->map->state != MAP_ACTIVE |
213 | || out_of_map (ob->map, ob->x, ob->y)) |
214 | || out_of_map (ob->map, ob->x, ob->y)) |
214 | return; |
215 | return; |
215 | |
216 | |
216 | packet sl; |
217 | packet sl; |
217 | sl.printf ("item%d ", pl->ns->itemcmd); |
218 | sl.printf ("item%d ", pl->ns->itemcmd); |
… | |
… | |
607 | { |
608 | { |
608 | std::string s = op->describe (pl->ob); |
609 | std::string s = op->describe (pl->ob); |
609 | |
610 | |
610 | packet sl ("ex"); |
611 | packet sl ("ex"); |
611 | sl << ber32 (tag) |
612 | sl << ber32 (tag) |
612 | << data (*pl->expand_cfpod (s.c_str ())); |
613 | << data_n (*pl->expand_cfpod (s.c_str ())); |
613 | |
614 | |
614 | pl->ns->send_packet (sl); |
615 | pl->ns->send_packet (sl); |
615 | } |
616 | } |
616 | } |
617 | } |
617 | |
618 | |
… | |
… | |
642 | tag_t tag = net_uint32 ((uint8 *)data + 1); |
643 | tag_t tag = net_uint32 ((uint8 *)data + 1); |
643 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
644 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
644 | |
645 | |
645 | if (!op) |
646 | if (!op) |
646 | { |
647 | { |
647 | pl->failmsg ("Could not find object to lock/unlock"); |
648 | pl->failmsgf ("Could not find object %d to lock/unlock", tag); |
648 | return; |
649 | return; |
649 | } |
650 | } |
650 | |
651 | |
651 | if (!flag) |
652 | if (!flag) |
652 | op->clr_flag (FLAG_INV_LOCKED); |
653 | op->clr_flag (FLAG_INV_LOCKED); |
… | |
… | |
663 | tag_t tag = net_uint32 ((uint8 *)data); |
664 | tag_t tag = net_uint32 ((uint8 *)data); |
664 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
665 | object *op = esrv_get_ob_from_count (pl->ob, tag); |
665 | |
666 | |
666 | if (!op) |
667 | if (!op) |
667 | { |
668 | { |
668 | pl->failmsg ("Could not find object to mark"); |
669 | pl->failmsgf ("Could not find object %d to mark", tag); |
669 | return; |
670 | return; |
670 | } |
671 | } |
671 | |
672 | |
672 | pl->mark = op; |
673 | pl->mark = op; |
673 | pl->ob->statusmsg (format ("Marked item %s", query_name (op))); |
674 | pl->ob->statusmsg (format ("Marked item %s", query_name (op))); |