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.39 by root, Mon Feb 26 20:36:15 2007 UTC vs.
Revision 1.45 by root, Mon May 28 21:22:26 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game for X-windows 2 * This file is part of Crossfire TRT, the Multiplayer Online Role Playing Game.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * Crossfire TRT is free software; you can redistribute it and/or modify it
9 * it under the terms of the GNU General Public License as published by 9 * under the terms of the GNU General Public License as published by the Free
10 * the Free Software Foundation; either version 2 of the License, or 10 * Software Foundation; either version 2 of the License, or (at your option)
11 * (at your option) any later version. 11 * 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, but
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * GNU General Public License for more details. 16 * for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License along
19 * along with this program; if not, write to the Free Software 19 * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * 21 *
22 * The author can be reached via e-mail to <crossfire@schmorp.de> 22 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23 */ 23 */
24 24
25/** 25/**
26 * \file 26 * \file
27 * Client/server logic. 27 * Client/server logic.
264 264
265 flags = query_flags (head); 265 flags = query_flags (head);
266 if (QUERY_FLAG (head, FLAG_NO_PICK)) 266 if (QUERY_FLAG (head, FLAG_NO_PICK))
267 flags |= F_NOPICK; 267 flags |= F_NOPICK;
268 268
269 if (!(ns.faces_sent[head->face->number] & NS_FACESENT_FACE)) 269 ns.send_face (head->face);
270 esrv_send_face (&ns, head->face->number, 0); 270 ns.flush_fx ();
271 271
272 if (QUERY_FLAG (head, FLAG_ANIMATE) && !ns.anims_sent[head->animation_id]) 272 if (QUERY_FLAG (head, FLAG_ANIMATE) && !ns.anims_sent[head->animation_id])
273 esrv_send_animation (&ns, head->animation_id); 273 ns.send_animation (head->animation_id);
274 274
275 sl << uint32 (head->count) 275 sl << uint32 (head->count)
276 << uint32 (flags) 276 << uint32 (flags)
277 << uint32 (QUERY_FLAG (head, FLAG_NO_PICK) ? -1 : WEIGHT (head)) 277 << uint32 (QUERY_FLAG (head, FLAG_NO_PICK) ? -1 : WEIGHT (head))
278 << uint32 (head->face->number); 278 << uint32 (head->face);
279 279
280 if (!head->custom_name) 280 if (!head->custom_name)
281 { 281 {
282 strncpy (item_n, query_base_name (head, 0), 127); 282 strncpy (item_n, query_base_name (head, 0), 127);
283 item_n[127] = 0; 283 item_n[127] = 0;
334 */ 334 */
335void 335void
336esrv_draw_look (object *pl) 336esrv_draw_look (object *pl)
337{ 337{
338 int got_one = 0, start_look = 0, end_look = 0; 338 int got_one = 0, start_look = 0, end_look = 0;
339 char buf[MAX_BUF];
340 339
341 if (!pl->contr->ns->update_look) 340 if (!pl->contr->ns->update_look)
342 { 341 {
343 LOG (llevDebug, "esrv_draw_look called when update_look was not set (player %s)\n", &pl->name); 342 LOG (llevDebug, "esrv_draw_look called when update_look was not set (player %s)\n", &pl->name);
344 return; 343 return;
357 packet sl; 356 packet sl;
358 sl.printf ("item%d ", pl->contr->ns->itemcmd); 357 sl.printf ("item%d ", pl->contr->ns->itemcmd);
359 358
360 sl << uint32 (0); 359 sl << uint32 (0);
361 360
362 if (!(pl->contr->ns->faces_sent[empty_face->number] & NS_FACESENT_FACE)) 361 pl->contr->ns->send_face (empty_face);
363 esrv_send_face (pl->contr->ns, empty_face->number, 0); 362 pl->contr->ns->flush_fx ();
364 363
365 if (pl->contr->ns->look_position) 364 if (pl->contr->ns->look_position)
366 { 365 {
367 char buf[80]; 366 char buf[80];
368 snprintf (buf, 80, "Apply this to see %d previous items", FLOORBOX_PAGESIZE); 367 snprintf (buf, 80, "Apply this to see %d previous items", FLOORBOX_PAGESIZE);
369 368
370 sl << uint32 (0x80000000 | (pl->contr->ns->look_position - FLOORBOX_PAGESIZE)) 369 sl << uint32 (0x80000000 | (pl->contr->ns->look_position - FLOORBOX_PAGESIZE))
371 << uint32 (0) 370 << uint32 (0)
372 << sint32 (-1) 371 << sint32 (-1)
373 << uint32 (empty_face->number) 372 << uint32 (empty_face)
374 << data8 (buf) 373 << data8 (buf)
375 << uint16 (0) 374 << uint16 (0)
376 << uint8 (0) 375 << uint8 (0)
377 << uint32 (0); 376 << uint32 (0);
378 377
405 * we notice the special tag the object has, and act accordingly. 404 * we notice the special tag the object has, and act accordingly.
406 */ 405 */
407 sl << uint32 (0x80000000 | (pl->contr->ns->look_position + FLOORBOX_PAGESIZE)) 406 sl << uint32 (0x80000000 | (pl->contr->ns->look_position + FLOORBOX_PAGESIZE))
408 << uint32 (0) 407 << uint32 (0)
409 << uint32 ((uint32) - 1) 408 << uint32 ((uint32) - 1)
410 << uint32 (empty_face->number) 409 << uint32 (empty_face)
411 << data8 ("Apply this to see next group of items") 410 << data8 ("Apply this to see next group of items")
412 << uint16 (0) 411 << uint16 (0)
413 << uint8 (0) 412 << uint8 (0)
414 << uint32 (0); 413 << uint32 (0);
415 414
556 ns->last_weight = weight; 555 ns->last_weight = weight;
557 } 556 }
558 557
559 if (flags & UPD_FACE) 558 if (flags & UPD_FACE)
560 { 559 {
561 if (!(ns->faces_sent[op->face->number] & NS_FACESENT_FACE)) 560 ns->send_face (op->face);
562 esrv_send_face (ns, op->face->number, 0); 561 ns->flush_fx ();
563
564 sl << uint32 (op->face->number); 562 sl << uint32 (op->face);
565 } 563 }
566 564
567 if (flags & UPD_NAME) 565 if (flags & UPD_NAME)
568 { 566 {
569 int len; 567 int len;
693 691
694/** 692/**
695 * Takes a player and object count (tag) and returns the actual object 693 * Takes a player and object count (tag) and returns the actual object
696 * pointer, or null if it can't be found. 694 * pointer, or null if it can't be found.
697 */ 695 */
698
699object * 696object *
700esrv_get_ob_from_count (object *pl, tag_t count) 697esrv_get_ob_from_count (object *pl, tag_t count)
701{ 698{
702 object *op, *tmp;
703
704 if (pl->count == count) 699 if (pl->count == count)
705 return pl; 700 return pl;
706 701
707 for (op = pl->inv; op; op = op->below) 702 for (object *op = pl->inv; op; op = op->below)
708 if (op->count == count) 703 if (op->count == count)
709 return op; 704 return op;
710 else if (op->type == CONTAINER && pl->container == op) 705 else if (op->type == CONTAINER && pl->container == op)
711 for (tmp = op->inv; tmp; tmp = tmp->below) 706 for (object *tmp = op->inv; tmp; tmp = tmp->below)
712 if (tmp->count == count) 707 if (tmp->count == count)
713 return tmp; 708 return tmp;
714 709
715 for (op = GET_MAP_OB (pl->map, pl->x, pl->y); op; op = op->above) 710 for (object *op = GET_MAP_OB (pl->map, pl->x, pl->y); op; op = op->above)
716 if (op->head && op->head->count == count) 711 if (op->head && op->head->count == count)
717 return op; 712 return op;
718 else if (op->count == count) 713 else if (op->count == count)
719 return op; 714 return op;
720 else if (op->type == CONTAINER && pl->container == op) 715 else if (op->type == CONTAINER && pl->container == op)
721 for (tmp = op->inv; tmp; tmp = tmp->below) 716 for (object *tmp = op->inv; tmp; tmp = tmp->below)
722 if (tmp->count == count) 717 if (tmp->count == count)
723 return tmp; 718 return tmp;
724 719
720#if 0
721 /* If the high bit is set, player examined a pseudo object. */
722 if (count & 0x80000000)
723 return 0;
724#endif
725
725 return 0; 726 return 0;
726} 727}
727 728
728
729/** Client wants to examine some object. So lets do so. */ 729/** Client wants to examine some object. So lets do so. */
730void 730void
731ExamineCmd (char *buf, int len, player *pl) 731ExamineCmd (char *buf, int len, player *pl)
732{ 732{
733 tag_t tag = atoi (buf); 733 tag_t tag = atoi (buf);
734
735 /* If the high bit is set, player examined a pseudo object. */
736 if (tag & 0x80000000)
737 return;
738 734
739 object *op = esrv_get_ob_from_count (pl->ob, tag); 735 object *op = esrv_get_ob_from_count (pl->ob, tag);
740 736
741 if (!op) 737 if (!op)
742 { 738 {
743 LOG (llevDebug, "Player '%s' tried to examine the unknown object (%ld)\n", &pl->ob->name, tag); 739 LOG (llevDebug, "Player '%s' tried to examine the unknown object (%ld)\n", &pl->ob->name, tag);
744 return; 740 return;
745 } 741 }
746 742
747 examine (pl->ob, op); 743 examine (pl->ob, op);
744}
745
746/** Client wants to examine some object. So lets do so. */
747void
748ExCmd (char *buf, int len, player *pl)
749{
750 tag_t tag = atoi (buf);
751
752 if (object *op = esrv_get_ob_from_count (pl->ob, tag))
753 {
754 std::string s = op->describe (pl->ob);
755
756 packet sl ("ex");
757 sl << ber32 (tag) << s.c_str ();
758
759 pl->ns->send_packet (sl);
760 }
748} 761}
749 762
750/** Client wants to apply some object. Lets do so. */ 763/** Client wants to apply some object. Lets do so. */
751void 764void
752ApplyCmd (char *buf, int len, player *pl) 765ApplyCmd (char *buf, int len, player *pl)
839 852
840 m = get_map_from_coord (op->map, &x, &y); 853 m = get_map_from_coord (op->map, &x, &y);
841 if (!m) 854 if (!m)
842 return; 855 return;
843 856
844 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL && tmp->above != NULL; tmp = tmp->above); 857 for (tmp = GET_MAP_OB (m, x, y); tmp && tmp->above; tmp = tmp->above)
858 ;
845 859
846 for (; tmp != NULL; tmp = tmp->below) 860 for (; tmp; tmp = tmp->below)
847 { 861 {
848 if (tmp->invisible && !QUERY_FLAG (op, FLAG_WIZ)) 862 if (tmp->invisible && !QUERY_FLAG (op, FLAG_WIZ))
849 continue; 863 continue;
850 864
851 if (!flag) 865 if (!flag)
889 int dx, dy; 903 int dx, dy;
890 char *cp; 904 char *cp;
891 905
892 dx = atoi (buf); 906 dx = atoi (buf);
893 if (!(cp = strchr (buf, ' '))) 907 if (!(cp = strchr (buf, ' ')))
894 {
895 return; 908 return;
896 } 909
897 dy = atoi (cp); 910 dy = atoi (cp);
898
899 if (fabs (dx) > pl->ns->mapx / 2 || fabs (dy) > pl->ns->mapy / 2) 911 if (fabs (dx) > pl->ns->mapx / 2 || fabs (dy) > pl->ns->mapy / 2)
900 return; 912 return;
901 913
902 if (pl->blocked_los[dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2]) 914 if (pl->blocked_los[dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2])
903 return; 915 return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines