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.93 by root, Tue May 1 05:48:21 2007 UTC vs.
Revision 1.98 by root, Fri May 18 15:05:09 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
5 * Copyright (C) 2001 Mark Wedel 5 * Copyright (C) 2001 Mark Wedel
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
7 * 7 *
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_ob) 739 if (pl->ranged_ob)
742 buf << " Range: " << pl->ranged_ob->name; 740 buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name;
743 741
744 if (pl->combat_ob) 742 if (pl->combat_ob)
745 buf << " Combat: " << pl->combat_ob->name; 743 buf << " Combat" << (pl->ob->current_weapon == pl->combat_ob ? "*" : "") << ": " << pl->combat_ob->name;
746 744
745 //TODO: maybe golem should become the current_weapon, quite simply?
747 if (pl->golem) 746 if (pl->golem)
748 buf << " Golem: " << pl->golem->name; 747 buf << " Golem*: " << pl->golem->name;
749 748
750 if (buf.empty ()) 749 buf.linearise (obuf);
751 *obuf = 0;
752 else
753 {
754 memcpy (obuf, buf.linearise () + 1, buf.size () - 1);
755 obuf [buf.size ()] = 0; 750 obuf [buf.size ()] = 0;
756 }
757} 751}
758 752
759#define AddIfInt64(Old,New,Type) if (Old != New) {\ 753#define AddIfInt64(Old,New,Type) if (Old != New) {\
760 Old = New; \ 754 Old = New; \
761 sl << uint8 (Type) << uint64 (New); \ 755 sl << uint8 (Type) << uint64 (New); \
769#define AddIfShort(Old,New,Type) if (Old != New) {\ 763#define AddIfShort(Old,New,Type) if (Old != New) {\
770 Old = New; \ 764 Old = New; \
771 sl << uint8 (Type) << uint16 (New); \ 765 sl << uint8 (Type) << uint16 (New); \
772 } 766 }
773 767
774#define AddIfFloat(Old,New,Type) if (Old != New) {\ 768#define AddIfFloat(Old,New,Type,mult) if (Old != New) {\
775 Old = New; \ 769 Old = New; \
776 sl << uint8 (Type) << uint32 (New*FLOAT_MULTI); \ 770 sl << uint8 (Type) << uint32 (New*FLOAT_MULTI*mult); \
777 } 771 }
778 772
779#define AddIfString(Old,New,Type) if (Old == NULL || strcmp(Old,New)) {\ 773#define AddIfString(Old,New,Type) if (Old == NULL || strcmp(Old,New)) {\
780 free(Old); Old = strdup (New);\ 774 free(Old); Old = strdup (New);\
781 sl << uint8 (Type) << data8 (New); \ 775 sl << uint8 (Type) << data8 (New); \
834 AddIfInt64 (ns->last_stats.exp, ob->stats.exp, CS_STAT_EXP64); 828 AddIfInt64 (ns->last_stats.exp, ob->stats.exp, CS_STAT_EXP64);
835 AddIfShort (ns->last_level, ob->level, CS_STAT_LEVEL); 829 AddIfShort (ns->last_level, ob->level, CS_STAT_LEVEL);
836 AddIfShort (ns->last_stats.wc, ob->stats.wc, CS_STAT_WC); 830 AddIfShort (ns->last_stats.wc, ob->stats.wc, CS_STAT_WC);
837 AddIfShort (ns->last_stats.ac, ob->stats.ac, CS_STAT_AC); 831 AddIfShort (ns->last_stats.ac, ob->stats.ac, CS_STAT_AC);
838 AddIfShort (ns->last_stats.dam, ob->stats.dam, CS_STAT_DAM); 832 AddIfShort (ns->last_stats.dam, ob->stats.dam, CS_STAT_DAM);
839 AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED); 833 AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED, 1.f/TICK);
840 AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD); 834 AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD);
841 AddIfFloat (ns->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP); 835 AddIfFloat (ns->last_weapon_sp, pl->weapon_sp, CS_STAT_WEAP_SP, 1.f/TICK);
842 AddIfInt (ns->last_weight_limit, weight_limit[ob->stats.Str], CS_STAT_WEIGHT_LIM); 836 AddIfInt (ns->last_weight_limit, weight_limit[ob->stats.Str], CS_STAT_WEIGHT_LIM);
843 837
844 flags = 0; 838 flags = 0;
845 839
846 if (pl->fire_on) 840 if (pl->fire_on)
868 AddIfInt (ns->last_path_attuned, ob->path_attuned, CS_STAT_SPELL_ATTUNE); 862 AddIfInt (ns->last_path_attuned, ob->path_attuned, CS_STAT_SPELL_ATTUNE);
869 AddIfInt (ns->last_path_repelled, ob->path_repelled, CS_STAT_SPELL_REPEL); 863 AddIfInt (ns->last_path_repelled, ob->path_repelled, CS_STAT_SPELL_REPEL);
870 AddIfInt (ns->last_path_denied, ob->path_denied, CS_STAT_SPELL_DENY); 864 AddIfInt (ns->last_path_denied, ob->path_denied, CS_STAT_SPELL_DENY);
871 } 865 }
872 866
873 rangetostring (ob, buf); /* we want use the new fire & run system in new client */ 867 rangetostring (pl, buf); /* we want use the new fire & run system in new client */
874 AddIfString (ns->stats.range, buf, CS_STAT_RANGE); 868 AddIfString (ns->stats.range, buf, CS_STAT_RANGE);
875 set_title (ob, buf); 869 set_title (ob, buf);
876 AddIfString (ns->stats.title, buf, CS_STAT_TITLE); 870 AddIfString (ns->stats.title, buf, CS_STAT_TITLE);
877 871
878 /* Only send it away if we have some actual data */ 872 /* Only send it away if we have some actual data */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines