ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/player.h
(Generate patch)

Comparing deliantra/server/include/player.h (file contents):
Revision 1.37 by root, Sat Dec 30 21:15:59 2006 UTC vs.
Revision 1.50 by root, Sun Apr 29 21:44:35 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) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 11 * (at your option) any later version.
11 12 *
12 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,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 16 * GNU General Public License for more details.
16 17 *
17 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
18 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 21 *
21 The authors can be reached via e-mail at crossfire@schmorp.de 22 * The authors can be reached via e-mail at crossfire@schmorp.de
22*/ 23 */
23
24#define NUM_OUTPUT_BUFS 5
25struct Output_Buf
26{
27 shstr buf; /* Actual string pointer */
28 uint32 first_update; /* First time this message was stored */
29 uint16 count; /* How many times we got this message */
30};
31 24
32/* wand/rod/horn rolled into range_misc. They all use the same body location 25/* wand/rod/horn rolled into range_misc. They all use the same body location
33 * anyways. 26 * anyways.
34 */ 27 */
35enum rangetype 28enum rangetype
36{ 29{
37 range_bottom = -1, 30 range_bottom = -1,
38 range_none = 0, 31 range_none,
39 range_bow = 1, 32 range_bow,
40 range_magic = 2, 33 range_magic,
41 range_misc = 3, 34 range_misc,
42 range_golem = 4, 35 range_golem,
43 range_skill = 5, 36 range_skill,
44 range_builder = 6, 37 range_builder,
45 range_size = 7 38 range_size
46}; 39};
47 40
48enum bowtype_t 41enum bowtype_t
49{ 42{
50 bow_normal = 0, 43 bow_normal = 0,
51 bow_threewide = 1, 44 bow_threewide = 1,
52 bow_spreadshot = 2, 45 bow_spreadshot = 2,
53 bow_n = 3, /* must stay at 3 */ 46 bow_n = 3, /* must stay at 3 */
54 bow_ne = 4, 47 bow_ne = 4,
55 bow_e = 5, 48 bow_e = 5,
56 bow_se = 6, 49 bow_se = 6,
57 bow_s = 7, 50 bow_s = 7,
58 bow_sw = 8, 51 bow_sw = 8,
59 bow_w = 9, 52 bow_w = 9,
60 bow_nw = 10, /* must stay at 10 */ 53 bow_nw = 10, /* must stay at 10 */
61 bow_bestarrow = 11 54 bow_bestarrow = 11
62}; 55};
63 56
64enum petmode_t 57enum petmode_t
65{ 58{
66 pet_normal = 0, 59 pet_normal = 0,
67 pet_sad = 1, 60 pet_sad = 1,
68 pet_defend = 2, 61 pet_defend = 2,
69 pet_arena = 3 62 pet_arena = 3,
70}; 63};
71 64
72enum usekeytype 65enum usekeytype
73{ 66{
74 key_inventory = 0, 67 key_inventory = 0,
75 keyrings = 1, 68 keyrings = 1,
76 containers = 2 69 containers = 2,
77}; 70};
78 71
79/* This is used to control what to do when we need to unapply 72/* This is used to control what to do when we need to unapply
80 * an object before we can apply another one. 73 * an object before we can apply another one.
81 */ 74 */
88 /* that need to be unapplied, there is no way for the player */ 81 /* that need to be unapplied, there is no way for the player */
89 /* to control which of these will be unapplied. */ 82 /* to control which of these will be unapplied. */
90}; 83};
91 84
92/* not really the player, but tied pretty closely */ 85/* not really the player, but tied pretty closely */
86INTERFACE_CLASS (partylist)
93struct partylist 87struct partylist
94{ 88{
95 char *partyleader; 89 char *ACC (RW, partyleader);
96 char passwd[9]; 90 char ACC (RW, passwd)[9];
97 partylist *next; 91 partylist *ACC (RW, next);
98 char *partyname; 92 char *ACC (RW, partyname);
99 93
100#ifdef PARTY_KILL_LOG
101 struct party_kill 94 struct party_kill
102 { 95 {
103 char killer[MAX_NAME + 1], dead[MAX_NAME + 1]; 96 char killer[MAX_NAME + 1], dead[MAX_NAME + 1];
104 sint64 exp; 97 sint64 exp;
105 } party_kills[PARTY_KILL_LOG]; 98 } party_kills[PARTY_KILL_LOG];
106#endif 99
107 sint64 total_exp; 100 sint64 ACC (RW, total_exp);
108 uint32 kills; 101 uint32 ACC (RW, kills);
109}; 102};
110
111#define for_all_players(var) for (player *var = first_player; var; var = var->next)
112 103
113INTERFACE_CLASS (player) 104INTERFACE_CLASS (player)
114struct player : zero_initialised, attachable 105struct player : zero_initialised, attachable
115{ 106{
116 player *ACC (RW, next); /* Pointer to next player, NULL if this is last */
117 client_ptr ACC (RO, ns); /* Socket information for this player */ 107 client *ACC (RO, ns); /* Socket information for this player */
118 object_ptr ACC (RW, ob); /* The object representing the player */ 108 object *ACC (RW, ob); /* The object representing the player */
119 maptile *loading; /* When entering a map in progress of loading, not really used */ 109 int ACC (RO, active);
110
120 rangetype ACC (RW, shoottype); /* Which range-attack is being used by player */ 111 rangetype ACC (RW, shoottype); /* Which range-attack is being used by player */
121 bowtype_t ACC (RW, bowtype); /* which firemode? */ 112 bowtype_t ACC (RW, bowtype); /* which firemode? */
122 petmode_t ACC (RW, petmode); /* which petmode? */ 113 petmode_t ACC (RW, petmode); /* which petmode? */
123 object_ptr ACC (RW, ranges[range_size]); /* object for each range. Set up in fix player. Note */ 114 object_ptr ACC (RW, ranges[range_size]); /* object for each range. Set up in fix player. Note */
124 /* That not all are used, it is just nice to map this 1:1 */ 115 /* That not all are used, it is just nice to map this 1:1 */
125 /* With the range names */ 116 /* With the range names */
126 usekeytype ACC (RW, usekeys); /* Method for finding keys for doors */ 117 usekeytype ACC (RW, usekeys); /* Method for finding keys for doors */
127 unapplymode ACC (RW, unapply); /* Method for auto unapply */ 118 unapplymode ACC (RW, unapply); /* Method for auto unapply */
128 uint32 ACC (RW, count); /* Any numbers typed before a command */ 119 uint32 ACC (RW, count); /* Any numbers typed before a command */
129 uint32 ACC (RW, mode); /* Mode of player for pickup. */ 120 uint32 ACC (RW, mode); /* Mode of player for pickup. */
130 121
133 sint8 ACC (RW, gen_sp); /* Bonuses to regeneration speed of sp */ 124 sint8 ACC (RW, gen_sp); /* Bonuses to regeneration speed of sp */
134 sint8 ACC (RW, gen_sp_armour); /* Penalty to sp regen from armour */ 125 sint8 ACC (RW, gen_sp_armour); /* Penalty to sp regen from armour */
135 sint8 ACC (RW, gen_grace); /* Bonuses to regeneration speed of grace */ 126 sint8 ACC (RW, gen_grace); /* Bonuses to regeneration speed of grace */
136 sint16 ACC (RW, item_power); /* Total item power of objects equipped */ 127 sint16 ACC (RW, item_power); /* Total item power of objects equipped */
137 uint8 ACC (RW, listening); /* Which priority will be used in info_all */ 128 uint8 ACC (RW, listening); /* Which priority will be used in info_all */
138 sint8 ACC (RW, last_level); /* Last level we sent to client */
139 129
140 /* Try to put all the bitfields together - saves some small amount of memory */ 130 /* Try to put all the bitfields together - saves some small amount of memory */
141 uint32 ACC (RO, braced):1; /* Will not move if braced, only attack */ 131 bool ACC (RW, braced); /* Will not move if braced, only attack */
142 uint32 ACC (RO, tmp_invis):1; /* Will invis go away when we attack ? */ 132 bool ACC (RW, tmp_invis); /* Will invis go away when we attack ? */
143 uint32 ACC (RO, do_los):1; /* If true, need to call update_los() in draw(), and clear */ 133 bool ACC (RW, do_los); /* If true, need to call update_los() in draw(), and clear */
144 uint32 ACC (RO, fire_on):1; /* Player should fire object, not move */ 134 bool ACC (RW, fire_on); /* Player should fire object, not move */
145 uint32 ACC (RO, run_on):1; /* Player should keep moving in dir until run is off */ 135 bool ACC (RW, run_on); /* Player should keep moving in dir until run is off */
146 uint32 ACC (RO, has_hit):1; /* If set, weapon_sp instead of speed will count */ 136 bool ACC (RW, has_hit); /* If set, weapon_sp instead of speed will count */
147 uint32 ACC (RO, peaceful):1; /* If set, won't attack friendly creatures */ 137 bool ACC (RW, peaceful); /* If set, won't attack friendly creatures */
148 uint32 ACC (RO, hidden):1; /* If True, player (DM) is hidden from view */ 138 bool ACC (RW, hidden); /* If True, player (DM) is hidden from view */
149 uint32 ACC (RO, explore):1; /* if True, player is in explore mode */
150
151 object_ptr last_skill_ob[NUM_SKILLS]; /* the exp object */
152 sint64 last_skill_exp[NUM_SKILLS]; /* shadow register. if != exp. obj update client */
153 139
154 float ACC (RW, weapon_sp); /* Penalties to speed when fighting w speed >ws/10 */ 140 float ACC (RW, weapon_sp); /* Penalties to speed when fighting w speed >ws/10 */
155 float ACC (RW, last_weapon_sp); /* if diff than weapon_sp, update client */
156 uint16 ACC (RW, last_flags); /* fire/run on flags for last tick */
157 sint32 ACC (RW, last_weight); /* Last weight as sent to client; -1 means do not send weight */
158 sint32 ACC (RW, last_weight_limit); /* Last weight limit transmitted to client */
159 uint32 ACC (RW, last_path_attuned); /* Last spell attunment sent to client */
160 uint32 ACC (RW, last_path_repelled); /* Last spell repelled sent to client */
161 uint32 ACC (RW, last_path_denied); /* Last spell denied sent to client */
162 living ACC (RO, orig_stats); /* Permanent real stats of player */ 141 living ACC (RO, orig_stats); /* Permanent real stats of player */
163 living ACC (RO, last_stats); /* Last stats as sent to client */ 142 object_ptr last_skill_ob[NUM_SKILLS]; /* the exp object */
164 float ACC (RW, last_speed); /* Last speed as sent to client */
165 sint16 ACC (RW, last_resist[NROFATTACKS]); /* last resist values sent to client */
166 object_ptr ACC (RW, last_used); /* Pointer to object last picked or applied */ 143 object_ptr ACC (RW, last_used); /* Pointer to object last picked or applied */
167 144
168 sint16 ACC (RW, bed_x), ACC (RW, bed_y); /* x,y - coordinates of respawn (savebed) */ 145 sint16 ACC (RW, bed_x), ACC (RW, bed_y); /* x,y - coordinates of respawn (savebed) */
169 char ACC (RW, savebed_map)[MAX_BUF]; /* map where player will respawn after death */ 146 shstr ACC (RW, savebed_map); /* map where player will respawn after death */
170 char ACC (RW, maplevel)[MAX_BUF]; /* On which level is the player? */ 147 shstr ACC (RW, maplevel); /* On which level is the player? */
171 char ACC (RW, spellparam)[MAX_BUF]; /* What param to add to spells */ 148 char ACC (RW, spellparam)[MAX_BUF]; /* What param to add to spells */
172 149
173 char ACC (RW, own_title)[MAX_NAME]; /* Title the player has chosen for themself */ 150 char ACC (RW, own_title)[MAX_NAME]; /* Title the player has chosen for themself */
174 /* Note that for dragon players, this is filled in for them */ 151 /* Note that for dragon players, this is filled in for them */
175 char ACC (RW, title)[64]; /* Default title, like fighter, wizard, etc */ 152 char ACC (RW, title)[64]; /* Default title, like fighter, wizard, etc */
181 char ACC (RW, killer)[64]; /* Who killed this player. */ 158 char ACC (RW, killer)[64]; /* Who killed this player. */
182 159
183 char write_buf[MAX_BUF]; /* Holds arbitrary input from client */ /* should go */ 160 char write_buf[MAX_BUF]; /* Holds arbitrary input from client */ /* should go */
184 char ACC (RW, password)[16]; /* 2 (seed) + 11 (crypted) + 1 (EOS) + 2 (safety) = 16 */ 161 char ACC (RW, password)[16]; /* 2 (seed) + 11 (crypted) + 1 (EOS) + 2 (safety) = 16 */
185 162
186 time_t ACC (RW, last_save_time);
187 uint32 ACC (RW, last_save_tick);
188 partylist *ACC (RW, party); /* Party this player is part of */ 163 partylist *ACC (RW, party); /* Party this player is part of */
189 partylist *ACC (RW, party_to_join); /* used when player wants to join a party */ 164 partylist *ACC (RW, party_to_join); /* used when player wants to join a party */
190 /* but we will have to get password first */ 165 /* but we will have to get password first */
191 /* so we have to remember which party to */ 166 /* so we have to remember which party to */
192 /* join */ 167 /* join */
201 sint8 blocked_los[MAP_CLIENT_X][MAP_CLIENT_Y]; /* array showing what spaces */ 176 sint8 blocked_los[MAP_CLIENT_X][MAP_CLIENT_Y]; /* array showing what spaces */
202 /* the player can see. For maps smaller than */ 177 /* the player can see. For maps smaller than */
203 /* MAP_CLIENT_.., the upper left is used */ 178 /* MAP_CLIENT_.., the upper left is used */
204 179
205 shstr ACC (RW, invis_race); /* What race invisible to? */ 180 shstr ACC (RW, invis_race); /* What race invisible to? */
206 bool ACC (RW, enable_save);
207 Output_Buf outputs[NUM_OUTPUT_BUFS]; /* holds output strings to client */
208 181
209 MTH static player *create (); 182 MTH static player *create ();
183
184 static player *load_pl (object_thawer &thawer);
210 MTH static player *load (const char *path); 185 MTH static player *load_pl (const char *path);
211 MTH void save (bool final = false); 186
187 bool save_pl (object_freezer &freezer);
188 MTH bool save_pl (const char *path);
189
212 void do_destroy (); 190 void do_destroy ();
213 void gather_callbacks (AV *&callbacks, event_type event) const; 191 void gather_callbacks (AV *&callbacks, event_type event) const;
214 192
193 // wether the player can "see" this mapspace or not, decided by los
194 // 0 - nothing see, 100 - fully visible
195 MTH sint8 visibility_at (maptile *map, int x, int y) const;
196
215 MTH void connect (client *ns); 197 MTH void connect (client *ns);
216 MTH void disconnect (); 198 MTH void disconnect ();
217 199
200 MTH void activate ();
201 MTH void deactivate ();
202
218 // enters the initial map, after login or creation 203 // enters the initial map, after login or creation
219 MTH void enter_map (); 204 MTH void enter_map ();
205
206 MTH void set_range (rangetype r);
207 MTH bool legal_range (rangetype r) const;
208
209 MTH void chargen_race_done ();
210 MTH void chargen_race_next ();
220 211
221 ~player (); 212 ~player ();
222 213
223private: 214private:
224 void set_object (object *op); 215 void set_object (object *op);
225 player (); 216 player ();
226}; 217};
227 218
219typedef object_vector<player, &player::active> playervec;
220
221extern playervec players;
222
223#define for_all_players(var) \
224 for (unsigned _i = 0; _i < players.size (); ++_i) \
225 declvar (player *, var, players [_i])
226

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines