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.91 by root, Mon Apr 30 04:25:30 2007 UTC vs.
Revision 1.99 by root, Tue May 22 10:50:01 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_skill)
742 {
743 buf.printf (" Range: %s", &pl->ranged_skill->name);
744
745 if (pl->ranged_ob) 739 if (pl->ranged_ob)
746 buf.printf (" (%s)", query_base_name (pl->ranged_ob, 0)); 740 buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name;
747 }
748 741
749 if (pl->combat_skill)
750 {
751 buf.printf (" Combat: %s", &pl->combat_skill->name);
752
753 if (pl->combat_ob) 742 if (pl->combat_ob)
754 buf.printf (" (%s)", query_base_name (pl->combat_ob, 0)); 743 buf << " Combat" << (pl->ob->current_weapon == pl->combat_ob ? "*" : "") << ": " << pl->combat_ob->name;
755 }
756 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?
757 if (pl->golem) 750 if (pl->golem)
758 buf.printf (" Golem: %s", &pl->golem->name); 751 buf << " Golem*: " << pl->golem->name;
759 752
760 strcpy (obuf, buf.linearise () + 1); 753 buf.linearise (obuf);
754 obuf [buf.size ()] = 0;
761} 755}
762 756
763#define AddIfInt64(Old,New,Type) if (Old != New) {\ 757#define AddIfInt64(Old,New,Type) if (Old != New) {\
764 Old = New; \ 758 Old = New; \
765 sl << uint8 (Type) << uint64 (New); \ 759 sl << uint8 (Type) << uint64 (New); \
773#define AddIfShort(Old,New,Type) if (Old != New) {\ 767#define AddIfShort(Old,New,Type) if (Old != New) {\
774 Old = New; \ 768 Old = New; \
775 sl << uint8 (Type) << uint16 (New); \ 769 sl << uint8 (Type) << uint16 (New); \
776 } 770 }
777 771
778#define AddIfFloat(Old,New,Type) if (Old != New) {\ 772#define AddIfFloat(Old,New,Type,mult) if (Old != New) {\
779 Old = New; \ 773 Old = New; \
780 sl << uint8 (Type) << uint32 (New*FLOAT_MULTI); \ 774 sl << uint8 (Type) << uint32 (New*FLOAT_MULTI*mult); \
781 } 775 }
782 776
783#define AddIfString(Old,New,Type) if (Old == NULL || strcmp(Old,New)) {\ 777#define AddIfString(Old,New,Type) if (Old == NULL || strcmp(Old,New)) {\
784 free(Old); Old = strdup (New);\ 778 free(Old); Old = strdup (New);\
785 sl << uint8 (Type) << data8 (New); \ 779 sl << uint8 (Type) << data8 (New); \
838 AddIfInt64 (ns->last_stats.exp, ob->stats.exp, CS_STAT_EXP64); 832 AddIfInt64 (ns->last_stats.exp, ob->stats.exp, CS_STAT_EXP64);
839 AddIfShort (ns->last_level, ob->level, CS_STAT_LEVEL); 833 AddIfShort (ns->last_level, ob->level, CS_STAT_LEVEL);
840 AddIfShort (ns->last_stats.wc, ob->stats.wc, CS_STAT_WC); 834 AddIfShort (ns->last_stats.wc, ob->stats.wc, CS_STAT_WC);
841 AddIfShort (ns->last_stats.ac, ob->stats.ac, CS_STAT_AC); 835 AddIfShort (ns->last_stats.ac, ob->stats.ac, CS_STAT_AC);
842 AddIfShort (ns->last_stats.dam, ob->stats.dam, CS_STAT_DAM); 836 AddIfShort (ns->last_stats.dam, ob->stats.dam, CS_STAT_DAM);
843 AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED); 837 AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED, 1.f/TICK);
844 AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD); 838 AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD);
845 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);
846 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);
847 841
848 flags = 0; 842 flags = 0;
849 843
850 if (pl->fire_on) 844 if (pl->fire_on)
872 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);
873 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);
874 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);
875 } 869 }
876 870
877 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 */
878 AddIfString (ns->stats.range, buf, CS_STAT_RANGE); 872 AddIfString (ns->stats.range, buf, CS_STAT_RANGE);
879 set_title (ob, buf); 873 set_title (ob, buf);
880 AddIfString (ns->stats.title, buf, CS_STAT_TITLE); 874 AddIfString (ns->stats.title, buf, CS_STAT_TITLE);
881 875
882 /* 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