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 | */ |
734 | static void |
734 | static void |
735 | rangetostring (object *ob, char *obuf) |
735 | rangetostring (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: maybe golem should become the current_weapon, quite simply? |
753 | if (pl->golem) |
746 | if (pl->golem) |
754 | buf << " Golem: " << pl->golem->name; |
747 | buf << " Golem*: " << pl->golem->name; |
755 | |
748 | |
756 | if (buf.empty ()) |
749 | buf.linearise (obuf); |
757 | *obuf = 0; |
750 | obuf [buf.size ()] = 0; |
758 | else |
|
|
759 | memcpy (obuf, buf.linearise () + 1, buf.size () - 1); |
|
|
760 | } |
751 | } |
761 | |
752 | |
762 | #define AddIfInt64(Old,New,Type) if (Old != New) {\ |
753 | #define AddIfInt64(Old,New,Type) if (Old != New) {\ |
763 | Old = New; \ |
754 | Old = New; \ |
764 | sl << uint8 (Type) << uint64 (New); \ |
755 | sl << uint8 (Type) << uint64 (New); \ |
… | |
… | |
871 | 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); |
872 | 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); |
873 | 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); |
874 | } |
865 | } |
875 | |
866 | |
876 | 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 */ |
877 | AddIfString (ns->stats.range, buf, CS_STAT_RANGE); |
868 | AddIfString (ns->stats.range, buf, CS_STAT_RANGE); |
878 | set_title (ob, buf); |
869 | set_title (ob, buf); |
879 | AddIfString (ns->stats.title, buf, CS_STAT_TITLE); |
870 | AddIfString (ns->stats.title, buf, CS_STAT_TITLE); |
880 | |
871 | |
881 | /* Only send it away if we have some actual data */ |
872 | /* Only send it away if we have some actual data */ |