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. |
… | |
… | |
735 | rangetostring (player *pl, char *obuf) |
735 | rangetostring (player *pl, char *obuf) |
736 | { |
736 | { |
737 | dynbuf_text buf; |
737 | dynbuf_text buf; |
738 | |
738 | |
739 | if (pl->ranged_ob) |
739 | if (pl->ranged_ob) |
740 | buf << " Range: " << pl->ranged_ob->name; |
740 | buf << " Range" << (pl->ob->current_weapon == pl->ranged_ob ? "*" : "") << ": " << pl->ranged_ob->name; |
741 | |
741 | |
742 | if (pl->combat_ob) |
742 | if (pl->combat_ob) |
743 | buf << " Combat: " << pl->combat_ob->name; |
743 | buf << " Combat" << (pl->ob->current_weapon == pl->combat_ob ? "*" : "") << ": " << pl->combat_ob->name; |
744 | |
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? |
745 | if (pl->golem) |
750 | if (pl->golem) |
746 | buf << " Golem: " << pl->golem->name; |
751 | buf << " Golem*: " << pl->golem->name; |
747 | |
752 | |
748 | buf.linearise (obuf); |
753 | buf.linearise (obuf); |
749 | obuf [buf.size ()] = 0; |
754 | obuf [buf.size ()] = 0; |
750 | } |
755 | } |
751 | |
756 | |
… | |
… | |
762 | #define AddIfShort(Old,New,Type) if (Old != New) {\ |
767 | #define AddIfShort(Old,New,Type) if (Old != New) {\ |
763 | Old = New; \ |
768 | Old = New; \ |
764 | sl << uint8 (Type) << uint16 (New); \ |
769 | sl << uint8 (Type) << uint16 (New); \ |
765 | } |
770 | } |
766 | |
771 | |
767 | #define AddIfFloat(Old,New,Type) if (Old != New) {\ |
772 | #define AddIfFloat(Old,New,Type,mult) if (Old != New) {\ |
768 | Old = New; \ |
773 | Old = New; \ |
769 | sl << uint8 (Type) << uint32 (New*FLOAT_MULTI); \ |
774 | sl << uint8 (Type) << uint32 (New*FLOAT_MULTI*mult); \ |
770 | } |
775 | } |
771 | |
776 | |
772 | #define AddIfString(Old,New,Type) if (Old == NULL || strcmp(Old,New)) {\ |
777 | #define AddIfString(Old,New,Type) if (Old == NULL || strcmp(Old,New)) {\ |
773 | free(Old); Old = strdup (New);\ |
778 | free(Old); Old = strdup (New);\ |
774 | sl << uint8 (Type) << data8 (New); \ |
779 | sl << uint8 (Type) << data8 (New); \ |
… | |
… | |
827 | AddIfInt64 (ns->last_stats.exp, ob->stats.exp, CS_STAT_EXP64); |
832 | AddIfInt64 (ns->last_stats.exp, ob->stats.exp, CS_STAT_EXP64); |
828 | AddIfShort (ns->last_level, ob->level, CS_STAT_LEVEL); |
833 | AddIfShort (ns->last_level, ob->level, CS_STAT_LEVEL); |
829 | AddIfShort (ns->last_stats.wc, ob->stats.wc, CS_STAT_WC); |
834 | AddIfShort (ns->last_stats.wc, ob->stats.wc, CS_STAT_WC); |
830 | AddIfShort (ns->last_stats.ac, ob->stats.ac, CS_STAT_AC); |
835 | AddIfShort (ns->last_stats.ac, ob->stats.ac, CS_STAT_AC); |
831 | AddIfShort (ns->last_stats.dam, ob->stats.dam, CS_STAT_DAM); |
836 | AddIfShort (ns->last_stats.dam, ob->stats.dam, CS_STAT_DAM); |
832 | AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED); |
837 | AddIfFloat (ns->last_speed, ob->speed, CS_STAT_SPEED, 1.f/TICK); |
833 | AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD); |
838 | AddIfShort (ns->last_stats.food, ob->stats.food, CS_STAT_FOOD); |
834 | 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); |
835 | 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); |
836 | |
841 | |
837 | flags = 0; |
842 | flags = 0; |
838 | |
843 | |
839 | if (pl->fire_on) |
844 | if (pl->fire_on) |