ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/request.C
(Generate patch)

Comparing deliantra/server/socket/request.C (file contents):
Revision 1.92 by root, Mon Apr 30 17:39:59 2007 UTC vs.
Revision 1.100 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) 2001 Mark Wedel 5 * Copyright (©) 2001,2007 Mark Wedel
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 handling. 27 * Client handling.
730 730
731/** 731/**
732 * Get player's current range attack in obuf. 732 * Get player's current range attack in obuf.
733 */ 733 */
734static void 734static void
735rangetostring (object *ob, char *obuf) 735rangetostring (player *pl, char *obuf)
736{ 736{
737 dynbuf_text buf; 737 dynbuf_text buf;
738 738
739 player *pl = ob->contr;
740
741 if (pl->ranged_skill) 739 if (pl->ranged_ob)
742 buf << " Range: " 740 buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name;
743 << (pl->ranged_ob
744 ? pl->ranged_ob->name
745 : pl->ranged_skill->name);
746 741
747 if (pl->combat_skill) 742 if (pl->combat_ob)
748 buf << " Combat: " 743 buf << " Combat" << (pl->ob->current_weapon == pl->combat_ob ? "*" : "") << ": " << pl->combat_ob->name;
749 << (pl->combat_ob
750 ? pl->combat_ob->name
751 : pl->combat_skill->name);
752 744
745 //TODO: remove this when slot system is working, this is only for debugging
746 if (pl->ob->chosen_skill)
747 buf << " Skill*: " << pl->ob->chosen_skill->name;
748
749 //TODO: maybe golem should become the current_weapon, quite simply?
753 if (pl->golem) 750 if (pl->golem)
754 buf << " Golem: " << pl->golem->name; 751 buf << " Golem*: " << pl->golem->name;
755 752
756 if (buf.empty ()) 753 buf.linearise (obuf);
757 *obuf = 0; 754 obuf [buf.size ()] = 0;
758 else
759 memcpy (obuf, buf.linearise () + 1, buf.size () - 1);
760} 755}
761 756
762#define AddIfInt64(Old,New,Type) if (Old != New) {\ 757#define AddIfInt64(Old,New,Type) if (Old != New) {\
763 Old = New; \ 758 Old = New; \
764 sl << uint8 (Type) << uint64 (New); \ 759 sl << uint8 (Type) << uint64 (New); \
772#define AddIfShort(Old,New,Type) if (Old != New) {\ 767#define AddIfShort(Old,New,Type) if (Old != New) {\
773 Old = New; \ 768 Old = New; \
774 sl << uint8 (Type) << uint16 (New); \ 769 sl << uint8 (Type) << uint16 (New); \
775 } 770 }
776 771
777#define AddIfFloat(Old,New,Type) if (Old != New) {\ 772#define AddIfFloat(Old,New,Type,mult) if (Old != New) {\
778 Old = New; \ 773 Old = New; \
779 sl << uint8 (Type) << uint32 (New*FLOAT_MULTI); \ 774 sl << uint8 (Type) << uint32 (New*FLOAT_MULTI*mult); \
780 } 775 }
781 776
782#define AddIfString(Old,New,Type) if (Old == NULL || strcmp(Old,New)) {\ 777#define AddIfString(Old,New,Type) if (Old == NULL || strcmp(Old,New)) {\
783 free(Old); Old = strdup (New);\ 778 free(Old); Old = strdup (New);\
784 sl << uint8 (Type) << data8 (New); \ 779 sl << uint8 (Type) << data8 (New); \
837 AddIfInt64 (ns->last_stats.exp, ob->stats.exp, CS_STAT_EXP64); 832 AddIfInt64 (ns->last_stats.exp, ob->stats.exp, CS_STAT_EXP64);
838 AddIfShort (ns->last_level, ob->level, CS_STAT_LEVEL); 833 AddIfShort (ns->last_level, ob->level, CS_STAT_LEVEL);
839 AddIfShort (ns->last_stats.wc, ob->stats.wc, CS_STAT_WC); 834 AddIfShort (ns->last_stats.wc, ob->stats.wc, CS_STAT_WC);
840 AddIfShort (ns->last_stats.ac, ob->stats.ac, CS_STAT_AC); 835 AddIfShort (ns->last_stats.ac, ob->stats.ac, CS_STAT_AC);
841 AddIfShort (ns->last_stats.dam, ob->stats.dam, CS_STAT_DAM); 836 AddIfShort (ns->last_stats.dam, ob->stats.dam, CS_STAT_DAM);
842 AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED); 837 AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED, 1.f/TICK);
843 AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD); 838 AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD);
844 AddIfFloat (ns->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP); 839 AddIfFloat (ns->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP, 1.f/TICK);
845 AddIfInt (ns->last_weight_limit, weight_limit[ob->stats.Str], CS_STAT_WEIGHT_LIM); 840 AddIfInt (ns->last_weight_limit, weight_limit[ob->stats.Str], CS_STAT_WEIGHT_LIM);
846 841
847 flags = 0; 842 flags = 0;
848 843
849 if (pl->fire_on) 844 if (pl->fire_on)
871 AddIfInt (ns->last_path_attuned, ob->path_attuned, CS_STAT_SPELL_ATTUNE); 866 AddIfInt (ns->last_path_attuned, ob->path_attuned, CS_STAT_SPELL_ATTUNE);
872 AddIfInt (ns->last_path_repelled, ob->path_repelled, CS_STAT_SPELL_REPEL); 867 AddIfInt (ns->last_path_repelled, ob->path_repelled, CS_STAT_SPELL_REPEL);
873 AddIfInt (ns->last_path_denied, ob->path_denied, CS_STAT_SPELL_DENY); 868 AddIfInt (ns->last_path_denied, ob->path_denied, CS_STAT_SPELL_DENY);
874 } 869 }
875 870
876 rangetostring (ob, buf); /* we want use the new fire & run system in new client */ 871 rangetostring (pl, buf); /* we want use the new fire & run system in new client */
877 AddIfString (ns->stats.range, buf, CS_STAT_RANGE); 872 AddIfString (ns->stats.range, buf, CS_STAT_RANGE);
878 set_title (ob, buf); 873 set_title (ob, buf);
879 AddIfString (ns->stats.title, buf, CS_STAT_TITLE); 874 AddIfString (ns->stats.title, buf, CS_STAT_TITLE);
880 875
881 /* Only send it away if we have some actual data */ 876 /* Only send it away if we have some actual data */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines