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) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
7 | * |
7 | * |
… | |
… | |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | * |
21 | * |
22 | * 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 |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #define NUM_OUTPUT_BUFS 5 |
|
|
26 | struct Output_Buf |
|
|
27 | { |
|
|
28 | shstr buf; /* Actual string pointer */ |
|
|
29 | uint32 first_update; /* First time this message was stored */ |
|
|
30 | uint16 count; /* How many times we got this message */ |
|
|
31 | }; |
|
|
32 | |
|
|
33 | /* 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 |
34 | * anyways. |
26 | * anyways. |
35 | */ |
27 | */ |
36 | enum rangetype |
28 | enum rangetype |
37 | { |
29 | { |
38 | range_bottom = -1, |
30 | range_bottom = -1, |
39 | range_none = 0, |
31 | range_none, |
40 | range_bow = 1, |
32 | range_bow, |
41 | range_magic = 2, |
33 | range_magic, |
42 | range_misc = 3, |
34 | range_misc, |
43 | range_golem = 4, |
35 | range_golem, |
44 | range_skill = 5, |
36 | range_skill, |
45 | range_builder = 6, |
37 | range_builder, |
46 | range_size = 7 |
38 | range_size |
47 | }; |
39 | }; |
48 | |
40 | |
49 | enum bowtype_t |
41 | enum bowtype_t |
50 | { |
42 | { |
51 | bow_normal = 0, |
43 | bow_normal = 0, |
52 | bow_threewide = 1, |
44 | bow_threewide = 1, |
53 | bow_spreadshot = 2, |
45 | bow_spreadshot = 2, |
54 | bow_n = 3, /* must stay at 3 */ |
46 | bow_n = 3, /* must stay at 3 */ |
55 | bow_ne = 4, |
47 | bow_ne = 4, |
56 | bow_e = 5, |
48 | bow_e = 5, |
57 | bow_se = 6, |
49 | bow_se = 6, |
58 | bow_s = 7, |
50 | bow_s = 7, |
59 | bow_sw = 8, |
51 | bow_sw = 8, |
60 | bow_w = 9, |
52 | bow_w = 9, |
61 | bow_nw = 10, /* must stay at 10 */ |
53 | bow_nw = 10, /* must stay at 10 */ |
62 | bow_bestarrow = 11 |
54 | bow_bestarrow = 11 |
63 | }; |
55 | }; |
64 | |
56 | |
65 | enum petmode_t |
57 | enum petmode_t |
66 | { |
58 | { |
67 | pet_normal = 0, |
59 | pet_normal = 0, |
68 | pet_sad = 1, |
60 | pet_sad = 1, |
69 | pet_defend = 2, |
61 | pet_defend = 2, |
70 | pet_arena = 3 |
62 | pet_arena = 3, |
71 | }; |
63 | }; |
72 | |
64 | |
73 | enum usekeytype |
65 | enum usekeytype |
74 | { |
66 | { |
75 | key_inventory = 0, |
67 | key_inventory = 0, |
76 | keyrings = 1, |
68 | keyrings = 1, |
77 | containers = 2 |
69 | containers = 2, |
78 | }; |
70 | }; |
79 | |
71 | |
80 | /* 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 |
81 | * an object before we can apply another one. |
73 | * an object before we can apply another one. |
82 | */ |
74 | */ |
… | |
… | |
184 | 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 */ |
185 | /* the player can see. For maps smaller than */ |
177 | /* the player can see. For maps smaller than */ |
186 | /* MAP_CLIENT_.., the upper left is used */ |
178 | /* MAP_CLIENT_.., the upper left is used */ |
187 | |
179 | |
188 | shstr ACC (RW, invis_race); /* What race invisible to? */ |
180 | shstr ACC (RW, invis_race); /* What race invisible to? */ |
189 | Output_Buf outputs[NUM_OUTPUT_BUFS]; /* holds output strings to client */ |
|
|
190 | |
181 | |
191 | MTH static player *create (); |
182 | MTH static player *create (); |
192 | |
183 | |
193 | static player *load_pl (object_thawer &thawer); |
184 | static player *load_pl (object_thawer &thawer); |
194 | MTH static player *load_pl (const char *path); |
185 | MTH static player *load_pl (const char *path); |
… | |
… | |
197 | MTH bool save_pl (const char *path); |
188 | MTH bool save_pl (const char *path); |
198 | |
189 | |
199 | void do_destroy (); |
190 | void do_destroy (); |
200 | void gather_callbacks (AV *&callbacks, event_type event) const; |
191 | void gather_callbacks (AV *&callbacks, event_type event) const; |
201 | |
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 | |
202 | MTH void connect (client *ns); |
197 | MTH void connect (client *ns); |
203 | MTH void disconnect (); |
198 | MTH void disconnect (); |
204 | |
199 | |
205 | MTH void activate (); |
200 | MTH void activate (); |
206 | MTH void deactivate (); |
201 | MTH void deactivate (); |
207 | |
202 | |
208 | // enters the initial map, after login or creation |
203 | // enters the initial map, after login or creation |
209 | 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 (); |
210 | |
211 | |
211 | ~player (); |
212 | ~player (); |
212 | |
213 | |
213 | private: |
214 | private: |
214 | void set_object (object *op); |
215 | void set_object (object *op); |
… | |
… | |
218 | typedef object_vector<player, &player::active> playervec; |
219 | typedef object_vector<player, &player::active> playervec; |
219 | |
220 | |
220 | extern playervec players; |
221 | extern playervec players; |
221 | |
222 | |
222 | #define for_all_players(var) \ |
223 | #define for_all_players(var) \ |
223 | for (int _i = 0; _i < players.size (); ++_i) \ |
224 | for (unsigned _i = 0; _i < players.size (); ++_i) \ |
224 | declvar (player *, var, players [_i]) |
225 | declvar (player *, var, players [_i]) |
225 | |
226 | |