1 | /* |
|
|
2 | * static char *rcsid_player_h = |
|
|
3 | * "$Id: player.h,v 1.1 2006/02/03 07:12:50 root Exp $"; |
|
|
4 | */ |
|
|
5 | |
|
|
6 | /* |
1 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
8 | |
3 | |
9 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
10 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
26 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
21 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
27 | */ |
22 | */ |
28 | |
23 | |
29 | #define NUM_OUTPUT_BUFS 5 |
24 | #define NUM_OUTPUT_BUFS 5 |
30 | typedef struct { |
25 | typedef struct { |
31 | const char *buf; /* Actual string pointer */ |
26 | shstr buf; /* Actual string pointer */ |
32 | uint32 first_update; /* First time this message was stored */ |
27 | uint32 first_update; /* First time this message was stored */ |
33 | uint16 count; /* How many times we got this message */ |
28 | uint16 count; /* How many times we got this message */ |
34 | } Output_Buf; |
29 | } Output_Buf; |
35 | |
30 | |
36 | |
31 | |
37 | /* wand/rod/horn rolled into range_misc. They all use the same body location |
32 | /* wand/rod/horn rolled into range_misc. They all use the same body location |
38 | * anyways. |
33 | * anyways. |
39 | */ |
34 | */ |
40 | typedef enum rangetype { |
35 | enum rangetype { |
41 | range_bottom = -1, |
36 | range_bottom = -1, |
42 | range_none = 0, |
37 | range_none = 0, |
43 | range_bow = 1, |
38 | range_bow = 1, |
44 | range_magic = 2, |
39 | range_magic = 2, |
45 | range_misc = 3, |
40 | range_misc = 3, |
46 | range_golem = 4, |
41 | range_golem = 4, |
47 | range_skill = 5, |
42 | range_skill = 5, |
48 | range_builder = 6, |
43 | range_builder = 6, |
49 | range_size = 7 |
44 | range_size = 7 |
50 | } rangetype; |
45 | }; |
51 | |
46 | |
52 | typedef enum _bowtype { |
47 | enum bowtype_t { |
53 | bow_normal = 0, |
48 | bow_normal = 0, |
54 | bow_threewide = 1, |
49 | bow_threewide = 1, |
55 | bow_spreadshot = 2, |
50 | bow_spreadshot = 2, |
56 | bow_n = 3, /* must stay at 3 */ |
51 | bow_n = 3, /* must stay at 3 */ |
57 | bow_ne = 4, |
52 | bow_ne = 4, |
… | |
… | |
59 | bow_se = 6, |
54 | bow_se = 6, |
60 | bow_s = 7, |
55 | bow_s = 7, |
61 | bow_sw = 8, |
56 | bow_sw = 8, |
62 | bow_w = 9, |
57 | bow_w = 9, |
63 | bow_nw = 10, /* must stay at 10 */ |
58 | bow_nw = 10, /* must stay at 10 */ |
64 | bow_bestarrow = 11 |
59 | bow_bestarrow = 11 |
65 | } bowtype_t; |
60 | }; |
66 | |
61 | |
67 | typedef enum _petmode { |
62 | typedef enum _petmode { |
68 | pet_normal = 0, |
63 | pet_normal = 0, |
69 | pet_sad = 1, |
64 | pet_sad = 1, |
70 | pet_defend = 2, |
65 | pet_defend = 2, |
… | |
… | |
82 | */ |
77 | */ |
83 | typedef enum unapplymode { |
78 | typedef enum unapplymode { |
84 | unapply_nochoice=0, /* Will unapply objects when there no choice to unapply */ |
79 | unapply_nochoice=0, /* Will unapply objects when there no choice to unapply */ |
85 | unapply_never=1, /* will not unapply objects automatically */ |
80 | unapply_never=1, /* will not unapply objects automatically */ |
86 | unapply_always=2 /* Will unapply whatever is necessary - this goes beyond */ |
81 | unapply_always=2 /* Will unapply whatever is necessary - this goes beyond */ |
87 | /* no choice - if there are multiple ojbect of the same type */ |
82 | /* no choice - if there are multiple ojbect of the same type */ |
88 | /* that need to be unapplied, there is no way for the player */ |
83 | /* that need to be unapplied, there is no way for the player */ |
89 | /* to control which of these will be unapplied. */ |
84 | /* to control which of these will be unapplied. */ |
90 | } unapplymode; |
85 | } unapplymode; |
91 | |
86 | |
92 | /* not really the player, but tied pretty closely */ |
87 | /* not really the player, but tied pretty closely */ |
93 | typedef struct party_struct { |
88 | typedef struct party_struct { |
94 | char * partyleader; |
89 | char * partyleader; |
… | |
… | |
96 | struct party_struct *next; |
91 | struct party_struct *next; |
97 | char *partyname; |
92 | char *partyname; |
98 | |
93 | |
99 | #ifdef PARTY_KILL_LOG |
94 | #ifdef PARTY_KILL_LOG |
100 | struct party_kill { |
95 | struct party_kill { |
101 | char killer[MAX_NAME+1],dead[MAX_NAME+1]; |
96 | char killer[MAX_NAME+1],dead[MAX_NAME+1]; |
102 | sint64 exp; |
97 | sint64 exp; |
103 | } party_kills[PARTY_KILL_LOG]; |
98 | } party_kills[PARTY_KILL_LOG]; |
104 | #endif |
99 | #endif |
105 | sint64 total_exp; |
100 | sint64 total_exp; |
106 | uint32 kills; |
101 | uint32 kills; |
107 | } partylist; |
102 | } partylist; |
108 | |
103 | |
109 | typedef struct pl { |
104 | // memsettable part of player |
110 | struct pl *next; /* Pointer to next player, NULL if this is last */ |
105 | struct player_memset : zero_initialised |
111 | NewSocket socket; /* Socket information for this player */ |
106 | { |
112 | char maplevel[MAX_BUF]; /* On which level is the player? */ |
107 | object *ob; /* The object representing the player */ |
113 | struct mapdef *loading; /* When entering a map in progress of loading, not really used */ |
108 | mapstruct *loading; /* When entering a map in progress of loading, not really used */ |
114 | char savebed_map[MAX_BUF]; /* map where player will respawn after death */ |
|
|
115 | sint16 bed_x, bed_y; /* x,y - coordinates of respawn (savebed) */ |
|
|
116 | rangetype shoottype; /* Which range-attack is being used by player */ |
109 | rangetype shoottype; /* Which range-attack is being used by player */ |
117 | char spellparam[MAX_BUF]; /* What param to add to spells */ |
|
|
118 | bowtype_t bowtype; /* which firemode? */ |
110 | bowtype_t bowtype; /* which firemode? */ |
119 | petmode_t petmode; /* which petmode? */ |
111 | petmode_t petmode; /* which petmode? */ |
120 | object *ranges[range_size];/* object for each range. Set up in fix player. Note */ |
112 | object *ranges[range_size];/* object for each range. Set up in fix player. Note */ |
121 | /* That not all are used, it is just nice to map this 1:1 */ |
113 | /* That not all are used, it is just nice to map this 1:1 */ |
122 | /* With the range names */ |
114 | /* With the range names */ |
123 | uint32 golem_count; /* To track the golem */ |
115 | uint32 golem_count; /* To track the golem */ |
124 | usekeytype usekeys; /* Method for finding keys for doors */ |
116 | usekeytype usekeys; /* Method for finding keys for doors */ |
125 | unapplymode unapply; /* Method for auto unapply */ |
117 | unapplymode unapply; /* Method for auto unapply */ |
126 | uint32 count; /* Any numbers typed before a command */ |
118 | uint32 count; /* Any numbers typed before a command */ |
127 | uint32 mode; /* Mode of player for pickup. */ |
119 | uint32 mode; /* Mode of player for pickup. */ |
… | |
… | |
137 | sint8 last_level; /* Last level we sent to client */ |
129 | sint8 last_level; /* Last level we sent to client */ |
138 | |
130 | |
139 | /* Try to put all the bitfields together - saves some small amount of memory */ |
131 | /* Try to put all the bitfields together - saves some small amount of memory */ |
140 | uint32 braced:1; /* Will not move if braced, only attack */ |
132 | uint32 braced:1; /* Will not move if braced, only attack */ |
141 | uint32 tmp_invis:1; /* Will invis go away when we attack ? */ |
133 | uint32 tmp_invis:1; /* Will invis go away when we attack ? */ |
142 | const char *invis_race;/* What race invisible to? */ |
134 | shstr invis_race; /* What race invisible to? */ |
143 | uint32 do_los:1; /* If true, need to call update_los() in draw(), and clear */ |
135 | uint32 do_los:1; /* If true, need to call update_los() in draw(), and clear */ |
144 | uint32 fire_on:1; /* Player should fire object, not move */ |
136 | uint32 fire_on:1; /* Player should fire object, not move */ |
145 | uint32 run_on:1; /* Player should keep moving in dir until run is off */ |
137 | uint32 run_on:1; /* Player should keep moving in dir until run is off */ |
146 | uint32 has_hit:1; /* If set, weapon_sp instead of speed will count */ |
138 | uint32 has_hit:1; /* If set, weapon_sp instead of speed will count */ |
147 | uint32 name_changed:1; /* If true, the player has set a name. */ |
139 | uint32 name_changed:1; /* If true, the player has set a name. */ |
… | |
… | |
164 | living orig_stats; /* Permanent real stats of player */ |
156 | living orig_stats; /* Permanent real stats of player */ |
165 | living last_stats; /* Last stats as sent to client */ |
157 | living last_stats; /* Last stats as sent to client */ |
166 | float last_speed; /* Last speed as sent to client */ |
158 | float last_speed; /* Last speed as sent to client */ |
167 | sint16 last_resist[NROFATTACKS]; /* last resist values sent to client */ |
159 | sint16 last_resist[NROFATTACKS]; /* last resist values sent to client */ |
168 | int Swap_First; /* First stat player has selected to swap */ |
160 | int Swap_First; /* First stat player has selected to swap */ |
169 | object *ob; /* The object representing the player */ |
|
|
170 | object *last_used; /* Pointer to object last picked or applied */ |
161 | object *last_used; /* Pointer to object last picked or applied */ |
171 | uint32 last_used_id; /* Safety measures to be sure it's the same */ |
162 | uint32 last_used_id; /* Safety measures to be sure it's the same */ |
172 | sint8 blocked_los[MAP_CLIENT_X][MAP_CLIENT_Y]; /* array showing what spaces */ |
163 | sint8 blocked_los[MAP_CLIENT_X][MAP_CLIENT_Y]; /* array showing what spaces */ |
173 | /* the player can see. For maps smaller than */ |
164 | /* the player can see. For maps smaller than */ |
174 | /* MAP_CLIENT_.., the upper left is used */ |
165 | /* MAP_CLIENT_.., the upper left is used */ |
|
|
166 | |
|
|
167 | sint16 bed_x, bed_y; /* x,y - coordinates of respawn (savebed) */ |
|
|
168 | char savebed_map[MAX_BUF]; /* map where player will respawn after death */ |
|
|
169 | char maplevel[MAX_BUF]; /* On which level is the player? */ |
|
|
170 | char spellparam[MAX_BUF]; /* What param to add to spells */ |
175 | |
171 | |
176 | char own_title[MAX_NAME]; /* Title the player has chosen for themself */ |
172 | char own_title[MAX_NAME]; /* Title the player has chosen for themself */ |
177 | /* Note that for dragon players, this is filled in for them */ |
173 | /* Note that for dragon players, this is filled in for them */ |
178 | char title[BIG_NAME]; /* Default title, like fighter, wizard, etc */ |
174 | char title[BIG_NAME]; /* Default title, like fighter, wizard, etc */ |
179 | |
175 | |
180 | sint8 levhp[11]; /* What the player gained on that level */ |
176 | sint8 levhp[11]; /* What the player gained on that level */ |
181 | sint8 levsp[11]; /* Same for sp */ |
177 | sint8 levsp[11]; /* Same for sp */ |
182 | sint8 levgrace[11]; /* And same for grace */ |
178 | sint8 levgrace[11]; /* And same for grace */ |
… | |
… | |
194 | #ifdef AUTOSAVE |
190 | #ifdef AUTOSAVE |
195 | uint32 last_save_tick; |
191 | uint32 last_save_tick; |
196 | #endif |
192 | #endif |
197 | partylist *party; /* Party this player is part of */ |
193 | partylist *party; /* Party this player is part of */ |
198 | partylist *party_to_join; /* used when player wants to join a party */ |
194 | partylist *party_to_join; /* used when player wants to join a party */ |
199 | /* but we will have to get password first */ |
195 | /* but we will have to get password first */ |
200 | /* so we have to remember which party to */ |
196 | /* so we have to remember which party to */ |
201 | /* join */ |
197 | /* join */ |
202 | char search_str[MAX_BUF]; /* Item we are looking for */ |
198 | char search_str[MAX_BUF]; /* Item we are looking for */ |
203 | sint16 encumbrance; /* How much our player is encumbered */ |
199 | sint16 encumbrance; /* How much our player is encumbered */ |
204 | Output_Buf outputs[NUM_OUTPUT_BUFS]; /* holds output strings to client */ |
200 | Output_Buf outputs[NUM_OUTPUT_BUFS]; /* holds output strings to client */ |
205 | uint16 outputs_sync; /* How often to print, no matter what */ |
201 | uint16 outputs_sync; /* How often to print, no matter what */ |
206 | uint16 outputs_count; /* Print if this count is exceeded */ |
202 | uint16 outputs_count; /* Print if this count is exceeded */ |
207 | object *mark; /* marked object */ |
203 | object *mark; /* marked object */ |
208 | uint32 mark_count; /* count of mark object */ |
204 | uint32 mark_count; /* count of mark object */ |
209 | /* Special DM fields */ |
205 | /* Special DM fields */ |
210 | tag_t* stack_items; /* Item stack for patch/dump/... commands */ |
206 | tag_t* stack_items; /* Item stack for patch/dump/... commands */ |
211 | int stack_position; /* Current stack position, 0 for no item */ |
207 | int stack_position; /* Current stack position, 0 for no item */ |
|
|
208 | }; |
|
|
209 | |
|
|
210 | typedef struct pl : player_memset, attachable<struct pl> |
|
|
211 | { |
|
|
212 | static data_type get_dt () { return DT_PLAYER; } |
|
|
213 | |
|
|
214 | struct pl *next; /* Pointer to next player, NULL if this is last */ |
|
|
215 | NewSocket socket; /* Socket information for this player */ |
212 | } player; |
216 | } player; |
|
|
217 | |