1 | /* |
|
|
2 | * static char *rcsid_player_h = |
|
|
3 | * "$Id: player.h,v 1.5 2006/08/25 17:11:53 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 |
… | |
… | |
25 | |
20 | |
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 | struct Output_Buf { |
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 | }; |
35 | |
|
|
36 | |
30 | |
37 | /* wand/rod/horn rolled into range_misc. They all use the same body location |
31 | /* wand/rod/horn rolled into range_misc. They all use the same body location |
38 | * anyways. |
32 | * anyways. |
39 | */ |
33 | */ |
40 | enum rangetype { |
34 | enum rangetype { |
… | |
… | |
59 | bow_se = 6, |
53 | bow_se = 6, |
60 | bow_s = 7, |
54 | bow_s = 7, |
61 | bow_sw = 8, |
55 | bow_sw = 8, |
62 | bow_w = 9, |
56 | bow_w = 9, |
63 | bow_nw = 10, /* must stay at 10 */ |
57 | bow_nw = 10, /* must stay at 10 */ |
64 | bow_bestarrow = 11 |
58 | bow_bestarrow = 11 |
65 | }; |
59 | }; |
66 | |
60 | |
67 | typedef enum _petmode { |
61 | typedef enum _petmode { |
68 | pet_normal = 0, |
62 | pet_normal = 0, |
69 | pet_sad = 1, |
63 | pet_sad = 1, |
… | |
… | |
82 | */ |
76 | */ |
83 | typedef enum unapplymode { |
77 | typedef enum unapplymode { |
84 | unapply_nochoice=0, /* Will unapply objects when there no choice to unapply */ |
78 | unapply_nochoice=0, /* Will unapply objects when there no choice to unapply */ |
85 | unapply_never=1, /* will not unapply objects automatically */ |
79 | unapply_never=1, /* will not unapply objects automatically */ |
86 | unapply_always=2 /* Will unapply whatever is necessary - this goes beyond */ |
80 | unapply_always=2 /* Will unapply whatever is necessary - this goes beyond */ |
87 | /* no choice - if there are multiple ojbect of the same type */ |
81 | /* no choice - if there are multiple ojbect of the same type */ |
88 | /* that need to be unapplied, there is no way for the player */ |
82 | /* that need to be unapplied, there is no way for the player */ |
89 | /* to control which of these will be unapplied. */ |
83 | /* to control which of these will be unapplied. */ |
90 | } unapplymode; |
84 | } unapplymode; |
91 | |
85 | |
92 | /* not really the player, but tied pretty closely */ |
86 | /* not really the player, but tied pretty closely */ |
93 | typedef struct party_struct { |
87 | typedef struct party_struct { |
94 | char * partyleader; |
88 | char * partyleader; |
… | |
… | |
96 | struct party_struct *next; |
90 | struct party_struct *next; |
97 | char *partyname; |
91 | char *partyname; |
98 | |
92 | |
99 | #ifdef PARTY_KILL_LOG |
93 | #ifdef PARTY_KILL_LOG |
100 | struct party_kill { |
94 | struct party_kill { |
101 | char killer[MAX_NAME+1],dead[MAX_NAME+1]; |
95 | char killer[MAX_NAME+1],dead[MAX_NAME+1]; |
102 | sint64 exp; |
96 | sint64 exp; |
103 | } party_kills[PARTY_KILL_LOG]; |
97 | } party_kills[PARTY_KILL_LOG]; |
104 | #endif |
98 | #endif |
105 | sint64 total_exp; |
99 | sint64 total_exp; |
106 | uint32 kills; |
100 | uint32 kills; |
107 | } partylist; |
101 | } partylist; |
108 | |
102 | |
109 | // the layout of this structure cnanot be changed unless adjusting the inialisation code |
103 | // memsettable part of player |
110 | // in server/player.c:get_player has been verified. |
104 | struct player_pod |
111 | typedef struct pl { |
105 | { |
112 | struct pl *next; /* Pointer to next player, NULL if this is last */ |
|
|
113 | NewSocket socket; /* Socket information for this player */ |
|
|
114 | object *ob; /* The object representing the player */ |
106 | object *ob; /* The object representing the player */ |
115 | mapstruct *loading; /* When entering a map in progress of loading, not really used */ |
107 | mapstruct *loading; /* When entering a map in progress of loading, not really used */ |
116 | rangetype shoottype; /* Which range-attack is being used by player */ |
108 | rangetype shoottype; /* Which range-attack is being used by player */ |
117 | bowtype_t bowtype; /* which firemode? */ |
109 | bowtype_t bowtype; /* which firemode? */ |
118 | petmode_t petmode; /* which petmode? */ |
110 | petmode_t petmode; /* which petmode? */ |
119 | object *ranges[range_size];/* object for each range. Set up in fix player. Note */ |
111 | object *ranges[range_size];/* object for each range. Set up in fix player. Note */ |
120 | /* That not all are used, it is just nice to map this 1:1 */ |
112 | /* That not all are used, it is just nice to map this 1:1 */ |
121 | /* With the range names */ |
113 | /* With the range names */ |
122 | uint32 golem_count; /* To track the golem */ |
114 | uint32 golem_count; /* To track the golem */ |
123 | usekeytype usekeys; /* Method for finding keys for doors */ |
115 | usekeytype usekeys; /* Method for finding keys for doors */ |
124 | unapplymode unapply; /* Method for auto unapply */ |
116 | unapplymode unapply; /* Method for auto unapply */ |
125 | uint32 count; /* Any numbers typed before a command */ |
117 | uint32 count; /* Any numbers typed before a command */ |
126 | uint32 mode; /* Mode of player for pickup. */ |
118 | uint32 mode; /* Mode of player for pickup. */ |
… | |
… | |
136 | sint8 last_level; /* Last level we sent to client */ |
128 | sint8 last_level; /* Last level we sent to client */ |
137 | |
129 | |
138 | /* 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 */ |
139 | uint32 braced:1; /* Will not move if braced, only attack */ |
131 | uint32 braced:1; /* Will not move if braced, only attack */ |
140 | uint32 tmp_invis:1; /* Will invis go away when we attack ? */ |
132 | uint32 tmp_invis:1; /* Will invis go away when we attack ? */ |
141 | const char *invis_race; /* What race invisible to? */ |
133 | shstr invis_race; /* What race invisible to? */ |
142 | uint32 do_los:1; /* If true, need to call update_los() in draw(), and clear */ |
134 | uint32 do_los:1; /* If true, need to call update_los() in draw(), and clear */ |
143 | uint32 fire_on:1; /* Player should fire object, not move */ |
135 | uint32 fire_on:1; /* Player should fire object, not move */ |
144 | uint32 run_on:1; /* Player should keep moving in dir until run is off */ |
136 | uint32 run_on:1; /* Player should keep moving in dir until run is off */ |
145 | uint32 has_hit:1; /* If set, weapon_sp instead of speed will count */ |
137 | uint32 has_hit:1; /* If set, weapon_sp instead of speed will count */ |
146 | uint32 name_changed:1; /* If true, the player has set a name. */ |
138 | uint32 name_changed:1; /* If true, the player has set a name. */ |
… | |
… | |
166 | sint16 last_resist[NROFATTACKS]; /* last resist values sent to client */ |
158 | sint16 last_resist[NROFATTACKS]; /* last resist values sent to client */ |
167 | int Swap_First; /* First stat player has selected to swap */ |
159 | int Swap_First; /* First stat player has selected to swap */ |
168 | object *last_used; /* Pointer to object last picked or applied */ |
160 | object *last_used; /* Pointer to object last picked or applied */ |
169 | uint32 last_used_id; /* Safety measures to be sure it's the same */ |
161 | uint32 last_used_id; /* Safety measures to be sure it's the same */ |
170 | sint8 blocked_los[MAP_CLIENT_X][MAP_CLIENT_Y]; /* array showing what spaces */ |
162 | sint8 blocked_los[MAP_CLIENT_X][MAP_CLIENT_Y]; /* array showing what spaces */ |
171 | /* the player can see. For maps smaller than */ |
163 | /* the player can see. For maps smaller than */ |
172 | /* MAP_CLIENT_.., the upper left is used */ |
164 | /* MAP_CLIENT_.., the upper left is used */ |
173 | |
165 | |
174 | sint16 bed_x, bed_y; /* x,y - coordinates of respawn (savebed) */ |
166 | sint16 bed_x, bed_y; /* x,y - coordinates of respawn (savebed) */ |
175 | char savebed_map[MAX_BUF]; /* map where player will respawn after death */ |
167 | char savebed_map[MAX_BUF]; /* map where player will respawn after death */ |
176 | char maplevel[MAX_BUF]; /* On which level is the player? */ |
168 | char maplevel[MAX_BUF]; /* On which level is the player? */ |
177 | char spellparam[MAX_BUF]; /* What param to add to spells */ |
169 | char spellparam[MAX_BUF]; /* What param to add to spells */ |
178 | |
170 | |
179 | char own_title[MAX_NAME]; /* Title the player has chosen for themself */ |
171 | char own_title[MAX_NAME]; /* Title the player has chosen for themself */ |
180 | /* Note that for dragon players, this is filled in for them */ |
172 | /* Note that for dragon players, this is filled in for them */ |
181 | char title[BIG_NAME]; /* Default title, like fighter, wizard, etc */ |
173 | char title[BIG_NAME]; /* Default title, like fighter, wizard, etc */ |
182 | |
174 | |
183 | sint8 levhp[11]; /* What the player gained on that level */ |
175 | sint8 levhp[11]; /* What the player gained on that level */ |
184 | sint8 levsp[11]; /* Same for sp */ |
176 | sint8 levsp[11]; /* Same for sp */ |
185 | sint8 levgrace[11]; /* And same for grace */ |
177 | sint8 levgrace[11]; /* And same for grace */ |
… | |
… | |
197 | #ifdef AUTOSAVE |
189 | #ifdef AUTOSAVE |
198 | uint32 last_save_tick; |
190 | uint32 last_save_tick; |
199 | #endif |
191 | #endif |
200 | partylist *party; /* Party this player is part of */ |
192 | partylist *party; /* Party this player is part of */ |
201 | partylist *party_to_join; /* used when player wants to join a party */ |
193 | partylist *party_to_join; /* used when player wants to join a party */ |
202 | /* but we will have to get password first */ |
194 | /* but we will have to get password first */ |
203 | /* so we have to remember which party to */ |
195 | /* so we have to remember which party to */ |
204 | /* join */ |
196 | /* join */ |
205 | char search_str[MAX_BUF]; /* Item we are looking for */ |
197 | char search_str[MAX_BUF]; /* Item we are looking for */ |
206 | sint16 encumbrance; /* How much our player is encumbered */ |
198 | sint16 encumbrance; /* How much our player is encumbered */ |
207 | Output_Buf outputs[NUM_OUTPUT_BUFS]; /* holds output strings to client */ |
|
|
208 | uint16 outputs_sync; /* How often to print, no matter what */ |
199 | uint16 outputs_sync; /* How often to print, no matter what */ |
209 | uint16 outputs_count; /* Print if this count is exceeded */ |
200 | uint16 outputs_count; /* Print if this count is exceeded */ |
210 | object *mark; /* marked object */ |
201 | object *mark; /* marked object */ |
211 | uint32 mark_count; /* count of mark object */ |
202 | uint32 mark_count; /* count of mark object */ |
212 | object *transport; /* transport the player is in */ |
|
|
213 | /* Special DM fields */ |
203 | /* Special DM fields */ |
214 | tag_t* stack_items; /* Item stack for patch/dump/... commands */ |
204 | tag_t* stack_items; /* Item stack for patch/dump/... commands */ |
215 | int stack_position; /* Current stack position, 0 for no item */ |
205 | int stack_position; /* Current stack position, 0 for no item */ |
|
|
206 | }; |
216 | |
207 | |
217 | void *self, *cb; // CF+ perl's self and callback registry |
208 | typedef struct pl : zero_initialised, attachable<struct pl>, player_pod |
|
|
209 | { |
|
|
210 | struct pl *next; /* Pointer to next player, NULL if this is last */ |
|
|
211 | NewSocket socket; /* Socket information for this player */ |
|
|
212 | Output_Buf outputs[NUM_OUTPUT_BUFS]; /* holds output strings to client */ |
|
|
213 | |
|
|
214 | void clear () |
|
|
215 | { |
|
|
216 | memset (static_cast<player_pod *>(this), 0, sizeof (player_pod)); |
|
|
217 | attachable_clear (); |
|
|
218 | |
|
|
219 | for (int i = 0; i < NUM_OUTPUT_BUFS; i++) |
|
|
220 | outputs[i].buf = 0; |
|
|
221 | } |
218 | } player; |
222 | } player; |
|
|
223 | |
|
|
224 | |