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 | |
|
|
25 | #ifndef PLAYER_H_ |
|
|
26 | #define PLAYER_H_ |
|
|
27 | |
|
|
28 | //+GPL |
24 | |
29 | |
25 | enum bowtype_t |
30 | enum bowtype_t |
26 | { |
31 | { |
27 | bow_normal = 0, |
32 | bow_normal = 0, |
28 | bow_threewide = 1, |
33 | bow_threewide = 1, |
… | |
… | |
68 | |
73 | |
69 | /* not really the player, but tied pretty closely */ |
74 | /* not really the player, but tied pretty closely */ |
70 | INTERFACE_CLASS (partylist) |
75 | INTERFACE_CLASS (partylist) |
71 | struct partylist |
76 | struct partylist |
72 | { |
77 | { |
73 | char *ACC (RW, partyleader); |
78 | utf8_string ACC (RW, partyleader); |
74 | char ACC (RW, passwd)[9]; |
79 | char ACC (RW, passwd)[9]; |
75 | partylist *ACC (RW, next); |
80 | partylist *ACC (RW, next); |
76 | char *ACC (RW, partyname); |
81 | utf8_string ACC (RW, partyname); |
77 | |
82 | |
78 | struct party_kill |
83 | struct party_kill |
79 | { |
84 | { |
80 | char killer[MAX_NAME + 1], dead[MAX_NAME + 1]; |
85 | char killer[MAX_NAME + 1], dead[MAX_NAME + 1]; |
81 | sint64 exp; |
86 | sint64 exp; |
… | |
… | |
84 | sint64 ACC (RW, total_exp); |
89 | sint64 ACC (RW, total_exp); |
85 | uint32 ACC (RW, kills); |
90 | uint32 ACC (RW, kills); |
86 | }; |
91 | }; |
87 | |
92 | |
88 | // used for pet monster logic etc. |
93 | // used for pet monster logic etc. |
89 | static bool |
94 | static inline bool |
90 | same_party (partylist *a, partylist *b) |
95 | same_party (partylist *a, partylist *b) |
91 | { |
96 | { |
92 | return a == b && a; |
97 | return a == b && a; |
93 | } |
98 | } |
94 | |
99 | |
… | |
… | |
132 | 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 */ |
133 | |
138 | |
134 | 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 |
135 | 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 |
136 | object_ptr ACC (RW, golem); // the currently controlled golem |
141 | object_ptr ACC (RW, golem); // the currently controlled golem |
137 | 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) |
138 | |
144 | |
139 | 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) */ |
140 | 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 */ |
141 | shstr ACC (RW, maplevel); /* On which level is the player? */ |
147 | shstr ACC (RW, maplevel); /* On which level is the player? */ |
142 | 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 */ |
… | |
… | |
149 | sint8 ACC (RW, levsp[11]); /* Same for sp */ |
155 | sint8 ACC (RW, levsp[11]); /* Same for sp */ |
150 | sint8 ACC (RW, levgrace[11]); /* And same for grace */ |
156 | sint8 ACC (RW, levgrace[11]); /* And same for grace */ |
151 | |
157 | |
152 | 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) */ |
153 | |
159 | |
|
|
160 | float speed_left_save; // spee doptimisation, see process_players[12] |
154 | 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 */ |
155 | 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 */ |
156 | |
163 | |
157 | partylist *ACC (RW, party); /* Party this player is part of */ |
164 | partylist *ACC (RW, party); /* Party this player is part of */ |
158 | 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 */ |
159 | /* but we will have to get password first */ |
166 | /* but we will have to get password first */ |
160 | /* so we have to remember which party to */ |
167 | /* so we have to remember which party to */ |
161 | /* join */ |
168 | /* join */ |
162 | char ACC (RW, search_str)[MAX_BUF]; /* Item we are looking for */ |
169 | char ACC (RW, search_str)[256]; /* Item we are looking for */ |
163 | sint16 ACC (RW, encumbrance); /* How much our player is encumbered */ |
170 | sint16 ACC (RW, encumbrance); /* How much our player is encumbered */ |
164 | 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 */ |
165 | uint16 ACC (RW, outputs_count); /* Print if this count is exceeded */ |
172 | uint16 ACC (RW, outputs_count); /* Print if this count is exceeded */ |
166 | object_ptr ACC (RW, mark); /* marked object */ |
173 | object_ptr ACC (RW, mark); /* marked object */ |
167 | /* Special DM fields */ |
174 | /* Special DM fields */ |
… | |
… | |
169 | 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 */ |
170 | 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 */ |
171 | /* the player can see. For maps smaller than */ |
178 | /* the player can see. For maps smaller than */ |
172 | /* MAP_CLIENT_.., the center is used */ |
179 | /* MAP_CLIENT_.., the center is used */ |
173 | |
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 | |
|
|
195 | #if 0 |
|
|
196 | enum { |
|
|
197 | SA_SPELLS = 1<<0, |
|
|
198 | SA_EXP = 1<<1, |
|
|
199 | }; |
|
|
200 | |
|
|
201 | uint8 ACxC (RW, stat_update_flags); |
|
|
202 | |
|
|
203 | void need_stat_update (int flags) |
|
|
204 | { |
|
|
205 | stat_update_flags |= flags; |
|
|
206 | } |
|
|
207 | #endif |
|
|
208 | |
174 | // return the los value for the given coordinate |
209 | // return the los value for the given coordinate |
175 | MTH sint8 blocked_los (int dx, int dy) const |
210 | MTH sint8 blocked_los (int dx, int dy) const |
176 | { |
211 | { |
177 | dx += LOS_X0; |
212 | dx += LOS_X0; |
178 | dy += LOS_Y0; |
213 | dy += LOS_Y0; |
… | |
… | |
191 | MTH void clear_los (sint8 value = LOS_BLOCKED); |
226 | MTH void clear_los (sint8 value = LOS_BLOCKED); |
192 | MTH void update_los (); |
227 | MTH void update_los (); |
193 | |
228 | |
194 | shstr ACC (RW, invis_race); /* What race invisible to? */ |
229 | shstr ACC (RW, invis_race); /* What race invisible to? */ |
195 | |
230 | |
196 | MTH const char *killer_name () const; // makes a string out of ->killer |
231 | MTH const_utf8_string killer_name () const; // makes a string out of ->killer |
197 | |
232 | |
198 | MTH static player *create (); |
233 | MTH static player *create (); |
199 | static player *find (const_utf8_string name); |
234 | static player *find (const_utf8_string name); |
200 | |
235 | |
201 | static player *load_pl (object_thawer &thawer); |
236 | static player *load_pl (object_thawer &thawer); |
… | |
… | |
203 | |
238 | |
204 | MTH void link_skills (); |
239 | MTH void link_skills (); |
205 | MTH object *find_skill (shstr_cmp name) const; |
240 | MTH object *find_skill (shstr_cmp name) const; |
206 | |
241 | |
207 | bool save_pl (object_freezer &freezer); |
242 | bool save_pl (object_freezer &freezer); |
208 | MTH bool save_pl (const char *path); |
243 | MTH bool save_pl (const_octet_string path); |
209 | |
244 | |
210 | void do_destroy (); |
245 | void do_destroy (); |
211 | void gather_callbacks (AV *&callbacks, event_type event) const; |
246 | void gather_callbacks (AV *&callbacks, event_type event) const; |
212 | |
247 | |
213 | MTH dynbuf_text *expand_cfpod (const char *cfpod) const; |
248 | MTH dynbuf_text *expand_cfpod (const_utf8_string cfpod) const; |
214 | |
249 | |
215 | MTH void touch () { dirty = true; } // need to touch when logged out and changed |
250 | MTH void touch () { dirty = true; } // need to touch when logged out and changed |
216 | |
251 | |
217 | MTH void play_sound (faceidx sound, int dx = 0, int dy = 0) const |
252 | MTH void play_sound (faceidx sound, int dx = 0, int dy = 0) const |
218 | { |
253 | { |
… | |
… | |
232 | |
267 | |
233 | MTH void chargen_race_done (); |
268 | MTH void chargen_race_done (); |
234 | MTH void chargen_race_next (); |
269 | MTH void chargen_race_next (); |
235 | |
270 | |
236 | MTH void set_observe (object_ornull *ob); |
271 | MTH void set_observe (object_ornull *ob); |
|
|
272 | MTH void set_viewpoint (object_ornull *ob); |
237 | |
273 | |
238 | void send_msg (int color, const char *type, const char *msg) |
274 | void send_msg (int color, const_utf8_string type, const_utf8_string msg) |
239 | { |
275 | { |
240 | ns->send_msg (color, type, msg); |
276 | ns->send_msg (color, type, msg); |
241 | } |
277 | } |
242 | |
278 | |
243 | // a prominent box that can easily be escaped away or so |
279 | // a prominent box that can easily be escaped away or so |
244 | // should be used for informative output such as who, maps etc. |
280 | // should be used for informative output such as who, maps etc. |
245 | // will stay on-screen |
281 | // will stay on-screen |
246 | MTH void infobox (const char *title, const char *msg, int color = NDI_BLACK); |
282 | MTH void infobox (const_utf8_string title, const_utf8_string msg, int color = NDI_BLACK); |
247 | |
283 | |
248 | // a prominent msg that signifies some important event, |
284 | // a prominent msg that signifies some important event, |
249 | // an improvement potion effect potion. should not be long. |
285 | // an improvement potion effect potion. should not be long. |
250 | // might time out after a while |
286 | // might time out after a while |
251 | MTH void statusmsg (const char *msg, int color = NDI_BLACK); |
287 | MTH void statusmsg (const_utf8_string msg, int color = NDI_BLACK); |
252 | |
288 | |
253 | // a prominent box that signifies some error such as a failed |
289 | // a prominent box that signifies some error such as a failed |
254 | // improvement potion. should not be long. |
290 | // improvement potion. should not be long. |
255 | MTH void failmsg (const char *msg, int color = NDI_RED); |
291 | MTH void failmsg (const_utf8_string msg, int color = NDI_RED); |
|
|
292 | |
|
|
293 | MTH void update_spells () const |
|
|
294 | { |
|
|
295 | if (ns) |
|
|
296 | ns->update_spells = true; |
|
|
297 | } |
256 | |
298 | |
257 | ~player (); |
299 | ~player (); |
258 | |
300 | |
259 | private: |
301 | private: |
260 | void set_object (object *op); |
302 | void set_object (object *op); |
… | |
… | |
272 | #define for_all_players_on_map(var,mapp) \ |
314 | #define for_all_players_on_map(var,mapp) \ |
273 | for_all_players(var) \ |
315 | for_all_players(var) \ |
274 | if ((var)->ob->map == (mapp)) |
316 | if ((var)->ob->map == (mapp)) |
275 | |
317 | |
276 | inline void |
318 | inline void |
277 | object::statusmsg (const char *msg, int color) |
319 | object::statusmsg (const_utf8_string msg, int color) |
278 | { |
320 | { |
279 | if (expect_true (contr)) contr->statusmsg (msg, color); |
321 | if (expect_true (contr)) contr->statusmsg (msg, color); |
280 | } |
322 | } |
281 | |
323 | |
282 | inline void |
324 | inline void |
283 | object::failmsg (const char *msg, int color) |
325 | object::failmsg (const_utf8_string msg, int color) |
284 | { |
326 | { |
285 | if (expect_true (contr)) contr->failmsg (msg, color); |
327 | if (expect_true (contr)) contr->failmsg (msg, color); |
286 | } |
328 | } |
|
|
329 | |
|
|
330 | #endif |
|
|
331 | |