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.93 by root, Mon Oct 19 21:48:49 2009 UTC vs.
Revision 1.103 by root, Fri Mar 26 00:59:21 2010 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
19 * and the GNU General Public License along with this program. If not, see 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 20 * <http://www.gnu.org/licenses/>.
21 * 21 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 23 */
24
24#ifndef PLAYER_H_ 25#ifndef PLAYER_H_
25#define PLAYER_H_ 26#define PLAYER_H_
27
28//+GPL
26 29
27enum bowtype_t 30enum bowtype_t
28{ 31{
29 bow_normal = 0, 32 bow_normal = 0,
30 bow_threewide = 1, 33 bow_threewide = 1,
70 73
71/* not really the player, but tied pretty closely */ 74/* not really the player, but tied pretty closely */
72INTERFACE_CLASS (partylist) 75INTERFACE_CLASS (partylist)
73struct partylist 76struct partylist
74{ 77{
75 char *ACC (RW, partyleader); 78 utf8_string ACC (RW, partyleader);
76 char ACC (RW, passwd)[9]; 79 char ACC (RW, passwd)[9];
77 partylist *ACC (RW, next); 80 partylist *ACC (RW, next);
78 char *ACC (RW, partyname); 81 utf8_string ACC (RW, partyname);
79 82
80 struct party_kill 83 struct party_kill
81 { 84 {
82 char killer[MAX_NAME + 1], dead[MAX_NAME + 1]; 85 char killer[MAX_NAME + 1], dead[MAX_NAME + 1];
83 sint64 exp; 86 sint64 exp;
86 sint64 ACC (RW, total_exp); 89 sint64 ACC (RW, total_exp);
87 uint32 ACC (RW, kills); 90 uint32 ACC (RW, kills);
88}; 91};
89 92
90// used for pet monster logic etc. 93// used for pet monster logic etc.
91static bool 94static inline bool
92same_party (partylist *a, partylist *b) 95same_party (partylist *a, partylist *b)
93{ 96{
94 return a == b && a; 97 return a == b && a;
95} 98}
96 99
134 object_ptr ACC (RW, last_used); /* Pointer to object last picked or applied */ 137 object_ptr ACC (RW, last_used); /* Pointer to object last picked or applied */
135 138
136 object_ptr ACC (RW, combat_ob); // which weapon/bow/skill to use for direct attacks 139 object_ptr ACC (RW, combat_ob); // which weapon/bow/skill to use for direct attacks
137 object_ptr ACC (RW, ranged_ob); // which skill/item/spell to use for ranged attacks 140 object_ptr ACC (RW, ranged_ob); // which skill/item/spell to use for ranged attacks
138 object_ptr ACC (RW, golem); // the currently controlled golem 141 object_ptr ACC (RW, golem); // the currently controlled golem
139 object_ptr ACC (RW, observe); // the object that is being observed (or 0) 142 object_ptr ACC (RW, observe); // the object that is being observed (never 0)
143 object_ptr ACC (RW, viewpoint); // the object that is being viewed in the map (never 0)
140 144
141 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) */
142 shstr ACC (RW, savebed_map); /* map where player will respawn after death */ 146 shstr ACC (RW, savebed_map); /* map where player will respawn after death */
143 shstr ACC (RW, maplevel); /* On which level is the player? */ 147 shstr ACC (RW, maplevel); /* On which level is the player? */
144 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 */
151 sint8 ACC (RW, levsp[11]); /* Same for sp */ 155 sint8 ACC (RW, levsp[11]); /* Same for sp */
152 sint8 ACC (RW, levgrace[11]); /* And same for grace */ 156 sint8 ACC (RW, levgrace[11]); /* And same for grace */
153 157
154 object_ptr ACC (RW, killer); /* Who last tried to kill this player (this object is usually destroyed) */ 158 object_ptr ACC (RW, killer); /* Who last tried to kill this player (this object is usually destroyed) */
155 159
160 float speed_left_save; // spee doptimisation, see process_players[12]
156 char write_buf[MAX_BUF]; /* Holds arbitrary input from client */ /* should go */ 161 char write_buf[MAX_BUF]; /* Holds arbitrary input from client */ /* should go */
157 char ACC (RW, password)[16]; /* 2 (seed) + 11 (crypted) + 1 (EOS) + 2 (safety) = 16 */ 162 char ACC (RW, password)[16]; /* 2 (seed) + 11 (crypted) + 1 (EOS) + 2 (safety) = 16 */
158 163
159 partylist *ACC (RW, party); /* Party this player is part of */ 164 partylist *ACC (RW, party); /* Party this player is part of */
160 partylist *ACC (RW, party_to_join); /* used when player wants to join a party */ 165 partylist *ACC (RW, party_to_join); /* used when player wants to join a party */
161 /* but we will have to get password first */ 166 /* but we will have to get password first */
162 /* so we have to remember which party to */ 167 /* so we have to remember which party to */
163 /* join */ 168 /* join */
164 char ACC (RW, search_str)[MAX_BUF]; /* Item we are looking for */ 169 char ACC (RW, search_str)[256]; /* Item we are looking for */
165 sint16 ACC (RW, encumbrance); /* How much our player is encumbered */ 170 sint16 ACC (RW, encumbrance); /* How much our player is encumbered */
166 uint16 ACC (RW, outputs_sync); /* How often to print, no matter what */ 171 uint16 ACC (RW, outputs_sync); /* How often to print, no matter what */
167 uint16 ACC (RW, outputs_count); /* Print if this count is exceeded */ 172 uint16 ACC (RW, outputs_count); /* Print if this count is exceeded */
168 object_ptr ACC (RW, mark); /* marked object */ 173 object_ptr ACC (RW, mark); /* marked object */
169 /* Special DM fields */ 174 /* Special DM fields */
171 int ACC (RW, stack_position); /* Current stack position, 0 for no item */ 176 int ACC (RW, stack_position); /* Current stack position, 0 for no item */
172 sint8 los[MAP_CLIENT_X][MAP_CLIENT_Y]; /* array showing what spaces */ 177 sint8 los[MAP_CLIENT_X][MAP_CLIENT_Y]; /* array showing what spaces */
173 /* the player can see. For maps smaller than */ 178 /* the player can see. For maps smaller than */
174 /* MAP_CLIENT_.., the center is used */ 179 /* MAP_CLIENT_.., the center is used */
175 180
181//-GPL
182
183 // stats updates are very costly, so delay them if at all possible
184 bool ACC (RW, delayed_update);
185 void queue_stats_update ()
186 {
187 delayed_update = true;
188 }
189 void need_updated_stats ()
190 {
191 if (delayed_update)
192 ob->update_stats ();
193 }
194
176 // return the los value for the given coordinate 195 // return the los value for the given coordinate
177 MTH sint8 blocked_los (int dx, int dy) const 196 MTH sint8 blocked_los (int dx, int dy) const
178 { 197 {
179 dx += LOS_X0; 198 dx += LOS_X0;
180 dy += LOS_Y0; 199 dy += LOS_Y0;
193 MTH void clear_los (sint8 value = LOS_BLOCKED); 212 MTH void clear_los (sint8 value = LOS_BLOCKED);
194 MTH void update_los (); 213 MTH void update_los ();
195 214
196 shstr ACC (RW, invis_race); /* What race invisible to? */ 215 shstr ACC (RW, invis_race); /* What race invisible to? */
197 216
198 MTH const char *killer_name () const; // makes a string out of ->killer 217 MTH const_utf8_string killer_name () const; // makes a string out of ->killer
199 218
200 MTH static player *create (); 219 MTH static player *create ();
201 static player *find (const_utf8_string name); 220 static player *find (const_utf8_string name);
202 221
203 static player *load_pl (object_thawer &thawer); 222 static player *load_pl (object_thawer &thawer);
205 224
206 MTH void link_skills (); 225 MTH void link_skills ();
207 MTH object *find_skill (shstr_cmp name) const; 226 MTH object *find_skill (shstr_cmp name) const;
208 227
209 bool save_pl (object_freezer &freezer); 228 bool save_pl (object_freezer &freezer);
210 MTH bool save_pl (const char *path); 229 MTH bool save_pl (const_octet_string path);
211 230
212 void do_destroy (); 231 void do_destroy ();
213 void gather_callbacks (AV *&callbacks, event_type event) const; 232 void gather_callbacks (AV *&callbacks, event_type event) const;
214 233
215 MTH dynbuf_text *expand_cfpod (const char *cfpod) const; 234 MTH dynbuf_text *expand_cfpod (const_utf8_string cfpod) const;
216 235
217 MTH void touch () { dirty = true; } // need to touch when logged out and changed 236 MTH void touch () { dirty = true; } // need to touch when logged out and changed
218 237
219 MTH void play_sound (faceidx sound, int dx = 0, int dy = 0) const 238 MTH void play_sound (faceidx sound, int dx = 0, int dy = 0) const
220 { 239 {
234 253
235 MTH void chargen_race_done (); 254 MTH void chargen_race_done ();
236 MTH void chargen_race_next (); 255 MTH void chargen_race_next ();
237 256
238 MTH void set_observe (object_ornull *ob); 257 MTH void set_observe (object_ornull *ob);
258 MTH void set_viewpoint (object_ornull *ob);
239 259
240 void send_msg (int color, const char *type, const char *msg) 260 void send_msg (int color, const_utf8_string type, const_utf8_string msg)
241 { 261 {
242 ns->send_msg (color, type, msg); 262 ns->send_msg (color, type, msg);
243 } 263 }
244 264
245 // a prominent box that can easily be escaped away or so 265 // a prominent box that can easily be escaped away or so
246 // should be used for informative output such as who, maps etc. 266 // should be used for informative output such as who, maps etc.
247 // will stay on-screen 267 // will stay on-screen
248 MTH void infobox (const char *title, const char *msg, int color = NDI_BLACK); 268 MTH void infobox (const_utf8_string title, const_utf8_string msg, int color = NDI_BLACK);
249 269
250 // a prominent msg that signifies some important event, 270 // a prominent msg that signifies some important event,
251 // an improvement potion effect potion. should not be long. 271 // an improvement potion effect potion. should not be long.
252 // might time out after a while 272 // might time out after a while
253 MTH void statusmsg (const char *msg, int color = NDI_BLACK); 273 MTH void statusmsg (const_utf8_string msg, int color = NDI_BLACK);
254 274
255 // a prominent box that signifies some error such as a failed 275 // a prominent box that signifies some error such as a failed
256 // improvement potion. should not be long. 276 // improvement potion. should not be long.
257 MTH void failmsg (const char *msg, int color = NDI_RED); 277 MTH void failmsg (const_utf8_string msg, int color = NDI_RED);
278
279 MTH void update_spells () const
280 {
281 if (ns)
282 ns->update_spells = true;
283 }
258 284
259 ~player (); 285 ~player ();
260 286
261private: 287private:
262 void set_object (object *op); 288 void set_object (object *op);
274#define for_all_players_on_map(var,mapp) \ 300#define for_all_players_on_map(var,mapp) \
275 for_all_players(var) \ 301 for_all_players(var) \
276 if ((var)->ob->map == (mapp)) 302 if ((var)->ob->map == (mapp))
277 303
278inline void 304inline void
279object::statusmsg (const char *msg, int color) 305object::statusmsg (const_utf8_string msg, int color)
280{ 306{
281 if (expect_true (contr)) contr->statusmsg (msg, color); 307 if (expect_true (contr)) contr->statusmsg (msg, color);
282} 308}
283 309
284inline void 310inline void
285object::failmsg (const char *msg, int color) 311object::failmsg (const_utf8_string msg, int color)
286{ 312{
287 if (expect_true (contr)) contr->failmsg (msg, color); 313 if (expect_true (contr)) contr->failmsg (msg, color);
288} 314}
289 315
290#endif 316#endif
317

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines