Crossfire Server  1.75.0
player.h
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2022 the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
19 #ifndef PLAYER_H
20 #define PLAYER_H
21 
28 enum rangetype {
29  range_bottom = -1,
30  range_none = 0,
31  range_bow = 1,
33  range_misc = 3,
38 };
39 
41 enum bowtype_t {
42  bow_normal = 0,
45  bow_n = 3,
46  bow_ne = 4,
47  bow_e = 5,
48  bow_se = 6,
49  bow_s = 7,
50  bow_sw = 8,
51  bow_w = 9,
52  bow_nw = 10,
54 };
55 
57 enum petmode_t {
58  pet_normal = 0,
59  pet_sad = 1,
60  pet_defend = 2,
61  pet_arena = 3
62 };
63 
65 enum usekeytype {
67  keyrings = 1,
69 };
70 
82 };
83 
87 struct client_spell {
88  object *spell;
89  int16_t last_sp;
90  int16_t last_grace;
91  int16_t last_dam;
92  struct client_spell *next;
93 };
94 
102 };
103 
104 typedef bool (*repeat_cb)(player *, void *data);
105 
107 struct player {
111  char maplevel[MAX_BUF];
112  char savebed_map[MAX_BUF];
113  int16_t bed_x, bed_y;
115  char spellparam[MAX_BUF];
118  object *ranges[range_size];
121  uint32_t golem_count;
124  uint32_t count;
125  uint32_t mode;
127  int16_t digestion;
128  int16_t gen_hp;
129  int16_t gen_sp;
130  int16_t gen_sp_armour;
131  int16_t gen_grace;
132  int16_t item_power;
133  uint8_t state;
135  uint8_t listening;
136  int8_t last_level;
140  /* Try to put all the bitfields together - saves some small amount of memory */
141  uint32_t braced:1;
142  uint32_t tmp_invis:1;
143  uint32_t do_los:1;
144  uint32_t fire_on:1;
145  uint32_t run_on:1;
146  uint32_t has_hit:1;
147  uint32_t name_changed:1;
148  uint32_t peaceful:1;
149  uint32_t hidden:1;
150  uint32_t no_shout:1;
151  uint32_t has_directory:1;
152  uint32_t partial_commands:1;
153  const char *invis_race;
155  object *last_skill_ob[MAX_SKILLS];
156  int64_t last_skill_exp[MAX_SKILLS];
159  uint16_t last_flags;
160  int32_t last_weight;
162  uint32_t last_path_attuned;
164  uint32_t last_path_denied;
166  uint16_t last_item_power;
175  float last_speed;
176  int16_t last_resist[NROFATTACKS];
177  int16_t last_golem_hp;
179  object *ob;
180  int8_t blocked_los[MAP_CLIENT_X][MAP_CLIENT_Y];
184  char own_title[MAX_NAME];
186  char title[BIG_NAME];
188  int8_t levhp[11];
189  int8_t levsp[11];
190  int8_t levgrace[11];
192  char killer[BIG_NAME];
193  char last_tell[MAX_NAME];
195  char password[16];
196  char new_password[16];
198  int16_t encumbrance;
199 #ifdef SAVE_INTERVAL
200  time_t last_save_time;
201 #endif /* SAVE_INTERVAL */
202 #ifdef AUTOSAVE
203  uint32_t last_save_tick;
204 #endif
210  object *last_exit;
213  char search_str[MAX_BUF];
214  uint32_t mark_count;
215  object *mark;
216  object *transport;
218  /* Special DM fields */
223  const char *unarmed_skill;
224  uint32_t ticks_played;
229  bool is_wraith;
234 };
235 
241 
242 #define FIND_PLAYER_PARTIAL_NAME 0x1
243 #define FIND_PLAYER_NO_HIDDEN_DM 0x2
246 
247 
252 #define ADD_PLAYER_NEW 0x1
253 #define ADD_PLAYER_NO_MAP 0x2
254 #define ADD_PLAYER_NO_STATS_ROLL 0x4
256 
257 void commit_crime(object *op, const char *description);
258 bool is_criminal(object *op);
259 void player_start_repeat(player *pl, const char *action, repeat_cb cb);
260 void player_cancel_repeat(player *pl);
261 
262 #endif /* PLAYER_H */
Fire north-west whatever the facing direction.
Definition: player.h:52
Use skill.
Definition: player.h:35
Will unapply whatever is necessary - this goes beyond no choice - if there are multiple ojbect of the...
Definition: player.h:78
int16_t gen_hp
Bonuses to regeneration speed of hp.
Definition: player.h:128
uint8_t delayed_buffers_allocated
Number of items in delayed_buffers_used.
Definition: player.h:226
Use keys in inventory and active containers.
Definition: player.h:68
int stack_position
Current stack position, 0 for no item.
Definition: player.h:221
living orig_stats
Permanent real stats of player.
Definition: player.h:169
int16_t last_sp
Last spell cost.
Definition: player.h:89
float last_weapon_sp
if diff than weapon_sp, update client.
Definition: player.h:158
Standard mode/.
Definition: player.h:58
uint32_t hidden
If True, player (DM) is hidden from view.
Definition: player.h:149
int16_t last_dam
Last damage.
Definition: player.h:91
uint32_t last_path_attuned
Last spell attunment sent to client.
Definition: player.h:162
void * language_t
Strings that should be manipulated through add_string() and free_string().
Definition: global.h:69
uint32_t peaceful
If set, won&#39;t attack friendly creatures.
Definition: player.h:148
No range selected.
Definition: player.h:30
bool(* repeat_cb)(player *, void *data)
Definition: player.h:104
object * spell
Spell object this structure is about.
Definition: player.h:88
#define BIG_NAME
Definition: define.h:42
unapplymode
This is used to control what to do when we need to unapply an object before we can apply another one...
Definition: player.h:75
uint32_t count
Any numbers typed before a command.
Definition: player.h:124
partylist * party
Party this player is part of.
Definition: player.h:205
Socket structure, represents a client-server connection.
Definition: newserver.h:93
living last_orig_stats
Last permanent stats sent to client.
Definition: player.h:171
uint32_t mode
Mode of player for pickup.
Definition: player.h:125
Fire three arrows in a cone.
Definition: player.h:44
Misc items.
Definition: player.h:33
This stores, for a spell a player knows, the last sp/gr/dam information sent to client.
Definition: player.h:87
living applied_stats
Stat changes due to gear or skills.
Definition: player.h:173
int swap_first
First stat player has selected to swap.
Definition: player.h:168
Attack other players in arena.
Definition: player.h:61
Use keys in inventory and active key rings.
Definition: player.h:67
Fire three arrows in the same direction.
Definition: player.h:43
object * last_exit
Last exit used by player or NULL.
Definition: player.h:210
bowtype_t
Bow firing mode.
Definition: player.h:41
client_spell * spell_state
Spell information sent to client.
Definition: player.h:217
Will not unapply objects automatically.
Definition: player.h:77
bool is_criminal(object *op)
Definition: player.cpp:313
Minimum, exclusive, value.
Definition: player.h:29
partylist * party_to_join
Used when player wants to join a party but we will have to get password first so we have to remember ...
Definition: player.h:206
object * transport
Transport the player is in.
Definition: player.h:216
repeat_cb repeat_func
If not NULL, automatically repeat the action repeat_func until interrupted.
Definition: player.h:231
rangetype shoottype
Which range-attack is being used by player.
Definition: player.h:114
#define NROFATTACKS
Definition: attack.h:15
int32_t last_weight_limit
Last weight limit transmitted to client.
Definition: player.h:161
party_rejoin_mode
Whether to rejoin party at login or not.
Definition: player.h:98
player * next
Pointer to next player, NULL if this is last.
Definition: player.h:108
One party.
Definition: party.h:10
tag_t * stack_items
Item stack for patch/dump/...
Definition: player.h:219
uint32_t do_los
If true, need to call update_los() in draw(), and clear.
Definition: player.h:143
uint16_t last_item_power
Last value for item_power.
Definition: player.h:166
float character_load
Value between 0 and 1 indicating how much the character is overloaded.
Definition: player.h:137
usekeytype
How to use keys.
Definition: player.h:65
sstring repeat_action
Shared string with textual description of current repeat action (e.g.
Definition: player.h:232
Fire south-west whatever the facing direction.
Definition: player.h:50
void player_start_repeat(player *pl, const char *action, repeat_cb cb)
Start repeating an action.
Definition: player.cpp:4545
void commit_crime(object *op, const char *description)
Definition: player.cpp:308
If party doesn&#39;t exist, form it.
Definition: player.h:101
int16_t encumbrance
How much our player is encumbered.
Definition: player.h:198
int16_t digestion
Any bonuses/penalties to digestion.
Definition: player.h:127
tag_t last_examined
Tag of most recently &#39;examined object.
Definition: player.h:167
Information on one title.
Definition: readable.cpp:108
int16_t last_golem_hp
Last golem hp value sent to the client.
Definition: player.h:177
Fire south-east whatever the facing direction.
Definition: player.h:48
Map builder.
Definition: player.h:36
uint32_t has_directory
If 0, the player was not yet saved, its directory doesn&#39;t exist.
Definition: player.h:151
Control golem.
Definition: player.h:34
uint32_t last_character_flags
Last character flags (CS_STAT_CHARACTER_FLAGS) sent to client.
Definition: player.h:165
socket_struct * socket
Socket information for this player.
Definition: player.h:109
uint32_t golem_count
To track the golem.
Definition: player.h:121
Rejoin if party exists.
Definition: player.h:100
Try to find an arrow matching the target.
Definition: player.h:53
language_t language
The language the player wishes to use.
Definition: player.h:222
uint8_t state
Input state of the player (name, password, etc).
Definition: player.h:133
object * ob
The object representing the player.
Definition: player.h:179
int16_t last_grace
Last grace cost.
Definition: player.h:90
uint32_t fire_on
Player should fire object, not move.
Definition: player.h:144
uint32_t mark_count
Count of marked object.
Definition: player.h:214
uint32_t braced
Will not move if braced, only attack.
Definition: player.h:141
float last_speed
Last speed as sent to client.
Definition: player.h:175
int32_t last_weight
Last weight as sent to client; -1 means do not send weight.
Definition: player.h:160
usekeytype usekeys
Method for finding keys for doors.
Definition: player.h:122
int8_t last_level
Last level we sent to client.
Definition: player.h:136
float last_character_load
Last value sent to the client.
Definition: player.h:138
int16_t bed_y
x,y - coordinates of respawn (savebed).
Definition: player.h:113
Don&#39;t rejoin.
Definition: player.h:99
uint32_t tag_t
Object tag, unique during the whole game.
Definition: object.h:14
unapplymode unapply
Method for auto unapply.
Definition: player.h:123
uint32_t last_path_denied
Last spell denied sent to client.
Definition: player.h:164
int16_t gen_sp_armour
Penalty to sp regen from armour.
Definition: player.h:130
uint32_t ticks_played
How many ticks this player has played.
Definition: player.h:224
uint8_t listening
Which priority will be used in info_all.
Definition: player.h:135
living last_stats
Last stats as sent to client.
Definition: player.h:170
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
Standard mode, one random arrow.
Definition: player.h:42
int16_t last_golem_maxhp
Last golem max hp value sent to the client.
Definition: player.h:178
Fire north whatever the facing direction.
Definition: player.h:45
uint32_t last_path_repelled
Last spell repelled sent to client.
Definition: player.h:163
#define MAP_CLIENT_X
This determines the maximum map size the client can request (and thus what the server will send to th...
Definition: config.h:237
object * mark
Marked object.
Definition: player.h:215
Various statistics of objects.
Definition: living.h:35
struct client_spell * next
Next spell information.
Definition: player.h:92
Maximum, exclusive, value.
Definition: player.h:37
#define MAP_CLIENT_Y
Definition: config.h:238
bool is_old_wraith
Whether this player is a "old" wraith, initialized at load time and updated when eating.
Definition: player.h:230
uint32_t name_changed
If true, the player has set a name.
Definition: player.h:147
int16_t gen_grace
Bonuses to regeneration speed of grace.
Definition: player.h:131
Stay close to the owner.
Definition: player.h:60
Fire south whatever the facing direction.
Definition: player.h:49
uint32_t no_shout
if True, player is *not *able to use shout command.
Definition: player.h:150
uint16_t last_flags
Fire/run on flags for last tick.
Definition: player.h:159
Fire north-east whatever the facing direction.
Definition: player.h:46
uint32_t run_on
Player should keep moving in dir until run is off.
Definition: player.h:145
bowtype_t bowtype
Which firemode?
Definition: player.h:116
rangetype
What range is currently selected by the player.
Definition: player.h:28
uint8_t delayed_buffers_used
Used items in delayed_buffers_used.
Definition: player.h:227
petmode_t
Petmode.
Definition: player.h:57
int16_t gen_sp
Bonuses to regeneration speed of sp.
Definition: player.h:129
living last_applied_stats
Last applied stats sent to the client.
Definition: player.h:174
void player_cancel_repeat(player *pl)
If the player is repeating an action, cancel it.
Definition: player.cpp:320
Bow.
Definition: player.h:31
Fire west whatever the facing direction.
Definition: player.h:51
Will unapply objects when there no choice to unapply.
Definition: player.h:76
SockList ** delayed_buffers
Buffers which will be sent after the player&#39;s tick completes.
Definition: player.h:228
uint32_t tmp_invis
Will invis go away when we attack?
Definition: player.h:142
uint32_t partial_commands
If 1, then first letters of a command are enough if no ambiguity in name.
Definition: player.h:152
Spells.
Definition: player.h:32
One player.
Definition: player.h:107
uint32_t has_hit
If set, weapon_sp instead of speed will count.
Definition: player.h:146
#define MAX_NAME
Definition: define.h:41
const char * invis_race
What race invisible to?
Definition: player.h:153
const char * unarmed_skill
Prefered skill to use in unarmed combat.
Definition: player.h:223
Only use keys in inventory.
Definition: player.h:66
#define MAX_SKILLS
This is the maximum number of skills the game may handle.
Definition: skills.h:70
Contains the base information we use to make up a packet we want to send.
Definition: newclient.h:721
int16_t item_power
Total item power of objects equipped.
Definition: player.h:132
const char * sstring
Definition: sstring.h:2
petmode_t petmode
Which petmode?
Definition: player.h:117
Try to find enemies.
Definition: player.h:59
living last_race_stats
Last race stats sent to the client.
Definition: player.h:172
bool is_wraith
Whether this player is a wraith or not, initialized at load time.
Definition: player.h:229
Fire east whatever the facing direction.
Definition: player.h:47
void * repeat_func_data
Arguments to pass into repeat_func.
Definition: player.h:233
sstring followed_player
Player the DM is following.
Definition: player.h:220
party_rejoin_mode rejoin_party
Whether to rejoin or not party at login.
Definition: player.h:212