Crossfire Server, Trunk
global.h
Go to the documentation of this file.
1 
6 #ifndef GLOBAL_H
7 #define GLOBAL_H
8 
14 #ifndef EXTERN
15 #define EXTERN extern
16 #endif
17 
18 /* Include this first, because it lets us know what we are missing */
19 #if defined(WIN32) || defined(_WIN32) || defined(WIN64)
20 #include "win32.h"
21 #else
22 #include "autoconf.h"
23 /* socklen_t is defined in this file on some systems, and that type is
24  * used in newserver.h, which is used in all other files
25  */
26 #include <sys/socket.h>
27 #endif
28 
29 #ifdef HAVE_LIBDMALLOC
30 #include <dmalloc.h>
31 #endif
32 
33 #include <inttypes.h>
34 #include <stdbool.h>
35 #include <stdio.h>
36 #include <unistd.h>
37 #include "compat.h"
38 
40 typedef const char *sstring;
41 
42 #include "config.h"
43 #include "define.h"
44 #include "logger.h"
45 #include "shared/newclient.h"
46 
47 /* This blob, in this order, is needed to actually define maps */
48 #include "face.h"
49 /* Include the basic defines from spells.h */
50 #include "attack.h" /* needs to be before material.h */
51 #include "material.h"
52 #include "living.h"
53 #include "object.h"
54 #include "map.h"
55 #include "tod.h"
56 
57 #include "skills.h"
58 
59 /* This defines the Account_Char structure which is used in the socket */
60 #include "account_char.h"
61 
62 /* Pull in the socket structure - used in the player structure */
63 #include "newserver.h"
64 
65 #include "party.h"
66 
67 /* Pull in the player structure */
68 #include "player.h"
69 
70 /* pull in treasure structure */
71 #include "treasure.h"
72 
73 #include "commands.h"
74 
75 /* pull in book structures */
76 #include "book.h"
77 
78 /* ob_methods and ob_types subsystem */
79 #include "ob_methods.h"
80 #include "ob_types.h"
81 
82 /*
83  * So far only used when dealing with artifacts.
84  * (now used by alchemy and other code too. Nov 95 b.t).
85  */
86 typedef struct linked_char {
87  const char *name;
88  struct linked_char *next;
89 } linked_char;
90 
91 
92 /* Pull in artifacts */
93 #include "artifact.h"
94 
95 /* Now for gods */
96 #include "god.h"
97 
98 /* Now for races */
99 #include "race.h"
100 
101 /* Now for recipe/alchemy */
102 #include "recipe.h"
103 
104 /* Now for spells */
105 #include "spells.h"
106 
107 /*****************************************************************************
108  * GLOBAL VARIABLES: *
109  *****************************************************************************/
110 
122 
123 /*
124  * Variables set by different flags (see init.c):
125  */
126 
130 extern uint32_t pticks;
137 extern int reopen_logfile;
147 #define SPELL_MAPPINGS 206
148 extern const char *const spell_mapping[SPELL_MAPPINGS];
151 /*
152  * Used in treasure.c
153  */
155 EXTERN const char *undead_name; /* Used in hit_player() in main.c */
156 
157 /* Rotate right from bsd sum. This is used in various places for checksumming */
158 #define ROTATE_RIGHT(c) if ((c)&01) (c) = ((c)>>1)+0x80000000; else (c) >>= 1;
159 
160 #define SET_ANIMATION(ob, newanim) { ob->face = (ob->temp_animation ? ob->temp_animation : ob->animation)->faces[newanim]; }
161 #define GET_ANIMATION(ob, anim) ((ob->temp_animation ? ob->temp_animation : ob->animation)->faces[anim])
162 #define GET_ANIM(ob) (ob->temp_animation ? ob->temp_animation : ob->animation)
163 #define GET_ANIM_ID(ob) (ob->temp_animation ? ob->temp_animation->num : (ob->animation ? ob->animation->num : 0))
164 /* NUM_ANIMATIONS returns the number of animations allocated. The last
165  * usuable animation will be NUM_ANIMATIONS-1 (for example, if an object
166  * has 8 animations, NUM_ANIMATIONS will return 8, but the values will
167  * range from 0 through 7.
168  */
169 #define NUM_ANIMATIONS(ob) ((ob->temp_animation ? ob->temp_animation : ob->animation)->num_animations)
170 #define NUM_FACINGS(ob) ((ob->temp_animation ? ob->temp_animation : ob->animation)->facings)
171 
174 
175 extern const Face *blank_face, *empty_face;
176 extern const Face *smooth_face;
177 
178 extern uint32_t max_time; /* loop time */
180 
181 #include "stringbuffer.h"
182 #include "libproto.h"
183 #include "sockproto.h"
184 #include "typesproto.h"
185 
191 #define FREE_AND_CLEAR(xyz) { free(xyz); xyz = NULL; }
192 
196 #define FREE_AND_CLEAR_STR(xyz) { free_string(xyz); xyz = NULL; }
197 
198 #define FREE_AND_CLEAR_STR_IF(xyz) { if (xyz) { free_string(xyz); xyz = NULL; } }
199 
202 #define FREE_AND_COPY(sv, nv) { if (sv) free_string(sv); sv = add_string(nv); }
203 
204 #define FREE_AND_COPY_IF(sv, nv) { if (sv) free_string(sv); sv = nv ? add_string(nv) : NULL; }
205 
206 #ifndef WIN32 /* ---win32 we define this stuff in win32.h */
207 #if HAVE_DIRENT_H
208 # include <dirent.h>
209 # define NAMLEN(dirent) strlen((dirent)->d_name)
210 #else
211 # define dirent direct
212 # define NAMLEN(dirent) (dirent)->d_namlen
213 # if HAVE_SYS_NDIR_H
214 # include <sys/ndir.h>
215 # endif
216 # if HAVE_SYS_DIR_H
217 # include <sys/dir.h>
218 # endif
219 # if HAVE_NDIR_H
220 # include <ndir.h>
221 # endif
222 #endif
223 #endif
224 
228 #define PERM_EXP(exptotal) (exptotal * settings.permanent_exp_ratio / 100 )
229 #define MAX_TOTAL_EXPERIENCE (settings.permanent_exp_ratio ? (MAX_EXPERIENCE * 100 / settings.permanent_exp_ratio) : 0)
230 
231 typedef void(*collectorHook)(BufferReader *, const char *);
232 
236 typedef struct Settings {
237  const char *logfilename;
238  uint16_t csport;
240  uint8_t dumpvalues;
241  const char *dumparg;
242  const char *confdir;
243  const char *datadir;
244  const char *localdir;
245  const char *playerdir;
246  const char *mapdir;
247  const char *regions;
248  const char *uniquedir;
249  const char *templatedir;
250  const char *tmpdir;
252  int16_t pk_luck_penalty;
257  uint8_t not_permadeth;
258  uint8_t simple_exp;
260  uint8_t set_title;
261  uint8_t resurrection;
262  uint8_t search_items;
265  uint8_t casting_time;
266  uint8_t real_wiz;
268  uint8_t always_show_hp;
270  uint16_t set_friendly_fire;
273  char motd[MAX_BUF];
274  const char *rules;
275  const char *news;
277  /* The meta_ is information for the metaserver. These are set in
278  * the lib/settings file.
279  */
280  unsigned int meta_on:1;
283  uint16_t meta_port;
286  uint32_t worldmapstartx;
287  uint32_t worldmapstarty;
288  uint32_t worldmaptilesx;
289  uint32_t worldmaptilesy;
290  uint32_t worldmaptilesizex;
291  uint32_t worldmaptilesizey;
292  uint8_t fastclock;
297  int16_t max_level;
319  uint8_t max_stat;
325  uint8_t crypt_mode;
326  uint8_t min_name;
327  uint8_t hooks_count;
328  const char *hooks_filename[20];
332 } Settings;
333 
337 extern Settings settings;
338 
349 typedef struct Statistics {
350  uint64_t spell_merges;
351  uint64_t spell_hash_full;
353 } Statistics;
354 
358 extern Statistics statistics;
359 
364 #define SCRIPT_FIX_ACTIVATOR 2
365 #define SCRIPT_FIX_ALL 1
366 #define SCRIPT_FIX_NOTHING 0
367 
368 #include "plugin.h"
369 
370 #endif /* GLOBAL_H */
Settings::casting_time
uint8_t casting_time
Definition: global.h:265
Face
Definition: face.h:14
Settings::special_break_map
uint8_t special_break_map
Definition: global.h:320
Settings::meta_comment
char meta_comment[MAX_BUF]
Definition: global.h:284
nrofallowedstr
EXTERN long nrofallowedstr
Definition: global.h:140
empty_archetype
EXTERN archetype * empty_archetype
Definition: global.h:142
Settings::mapdir
const char * mapdir
Definition: global.h:246
max_time
uint32_t max_time
Definition: time.c:35
Settings::meta_server
char meta_server[MAX_BUF]
Definition: global.h:281
Settings::hooks_count
uint8_t hooks_count
Definition: global.h:327
Settings::simple_exp
uint8_t simple_exp
Definition: global.h:258
empty_face
const Face * empty_face
Definition: global.h:175
spell_arrow.archetype
archetype
Definition: spell_arrow.py:11
Settings::max_level
int16_t max_level
Definition: global.h:297
Settings::recycle_tmp_maps
uint8_t recycle_tmp_maps
Definition: global.h:267
Settings::archetypes_tracker
void * archetypes_tracker
Definition: global.h:331
Settings::emergency_y
uint16_t emergency_y
Definition: global.h:295
Settings::regions
const char * regions
Definition: global.h:247
Settings::allow_broken_converters
int allow_broken_converters
Definition: global.h:311
init_sockets
socket_struct * init_sockets
Definition: init.c:58
Settings::log_timestamp_format
char * log_timestamp_format
Definition: global.h:314
Settings::armor_speed_linear
uint8_t armor_speed_linear
Definition: global.h:304
settings
Settings settings
Definition: init.c:39
Settings::resurrection
uint8_t resurrection
Definition: global.h:261
Statistics::spell_merges
uint64_t spell_merges
Definition: global.h:350
win32.h
sockproto.h
Settings::set_title
uint8_t set_title
Definition: global.h:260
ob_count
EXTERN long ob_count
Definition: global.h:146
face.h
Settings::ignore_plugin_compatibility
uint8_t ignore_plugin_compatibility
Definition: global.h:322
socket_struct
Definition: newserver.h:89
logger.h
Settings::not_permadeth
uint8_t not_permadeth
Definition: global.h:257
smooth_face
const Face * smooth_face
Definition: image.c:35
Settings::permanent_exp_ratio
uint8_t permanent_exp_ratio
Definition: global.h:253
Settings::crypt_mode
uint8_t crypt_mode
Definition: global.h:325
Settings::dumpvalues
uint8_t dumpvalues
Definition: global.h:240
Settings::datadir
const char * datadir
Definition: global.h:243
pl
Definition: player.h:92
recipe.h
god.h
Settings::worldmaptilesy
uint32_t worldmaptilesy
Definition: global.h:289
Settings::min_name
uint8_t min_name
Definition: global.h:326
linked_char
struct linked_char linked_char
Settings::worldmapstartx
uint32_t worldmapstartx
Definition: global.h:286
typesproto.h
first_artifactlist
EXTERN artifactlist * first_artifactlist
Definition: global.h:118
Settings::starting_stat_min
uint8_t starting_stat_min
Definition: global.h:315
artifact.h
Settings::roll_stat_points
uint8_t roll_stat_points
Definition: global.h:318
Settings::pk_luck_penalty
int16_t pk_luck_penalty
Definition: global.h:252
plugin.h
Settings::emergency_x
uint16_t emergency_x
Definition: global.h:295
Settings
struct Settings Settings
first_map_path
EXTERN char first_map_path[MAX_BUF]
Definition: global.h:143
skills.h
first_map
EXTERN mapstruct * first_map
Definition: global.h:116
Settings::csport
uint16_t csport
Definition: global.h:238
Statistics
Definition: global.h:349
Statistics::spell_hash_full
uint64_t spell_hash_full
Definition: global.h:351
Settings::ignore_assets_errors
int ignore_assets_errors
Definition: global.h:330
first_friendly_object
EXTERN objectlink * first_friendly_object
Definition: global.h:119
amulet_arch
EXTERN archetype * amulet_arch
Definition: global.h:154
maxfree
int maxfree[SIZEOFFREE]
Definition: object.c:300
Settings::meta_host
char meta_host[MAX_BUF]
Definition: global.h:282
linked_char
Definition: global.h:86
Settings::worldmaptilesx
uint32_t worldmaptilesx
Definition: global.h:288
Settings::pk_max_experience
int64_t pk_max_experience
Definition: global.h:308
undead_name
const EXTERN char * undead_name
Definition: global.h:155
Settings::spell_encumbrance
uint8_t spell_encumbrance
Definition: global.h:263
stringbuffer.h
Settings::meta_port
uint16_t meta_port
Definition: global.h:283
Settings::balanced_stat_loss
uint8_t balanced_stat_loss
Definition: global.h:256
Settings::debug
LogLevel debug
Definition: global.h:239
Settings::pk_max_experience_percent
int pk_max_experience_percent
Definition: global.h:309
linked_char::name
const char * name
Definition: global.h:87
blank_face
const Face * blank_face
Definition: image.c:35
attack.h
Settings::death_penalty_ratio
uint8_t death_penalty_ratio
Definition: global.h:254
statistics
Statistics statistics
Definition: init.c:99
Settings::set_friendly_fire
uint16_t set_friendly_fire
Definition: global.h:270
Settings::account_block_create
uint8_t account_block_create
Definition: global.h:323
Settings::logfilename
const char * logfilename
Definition: global.h:237
Settings::worldmapstarty
uint32_t worldmapstarty
Definition: global.h:287
party.h
glnk
Definition: god.h:12
compat.h
Settings::motd
char motd[MAX_BUF]
Definition: global.h:273
material.h
Settings::rules
const char * rules
Definition: global.h:274
Settings::armor_weight_reduction
int armor_weight_reduction
Definition: global.h:301
Settings::news
const char * news
Definition: global.h:275
first_player
EXTERN player * first_player
Definition: global.h:115
crown_arch
EXTERN archetype * crown_arch
Definition: global.h:154
Settings::stat_loss_on_death
uint8_t stat_loss_on_death
Definition: global.h:251
book.h
linked_char::next
struct linked_char * next
Definition: global.h:88
artifactliststruct
Definition: artifact.h:26
Settings::item_power_factor
float item_power_factor
Definition: global.h:298
freearr_y
short freearr_y[SIZEOFFREE]
Definition: global.h:172
Settings::dumparg
const char * dumparg
Definition: global.h:241
collectorHook
void(* collectorHook)(BufferReader *, const char *)
Definition: global.h:231
sstring
const typedef char * sstring
Definition: global.h:40
Settings::hooks_filename
const char * hooks_filename[20]
Definition: global.h:328
Settings::confdir
const char * confdir
Definition: global.h:242
nroferrors
EXTERN long nroferrors
Definition: global.h:128
mapdef
Definition: map.h:324
logfile
EXTERN FILE * logfile
Definition: global.h:136
Settings::death_penalty_level
uint8_t death_penalty_level
Definition: global.h:255
map.h
Settings::reset_loc_time
int reset_loc_time
Definition: global.h:259
SIZEOFFREE
#define SIZEOFFREE
Definition: define.h:154
treasure.h
MAX_BUF
#define MAX_BUF
Definition: define.h:35
Statistics::spell_suppressions
uint64_t spell_suppressions
Definition: global.h:352
race.h
spell_mapping
const char *const spell_mapping[SPELL_MAPPINGS]
Definition: object.c:63
Settings::playerdir
const char * playerdir
Definition: global.h:245
Settings::spell_failure_effects
uint8_t spell_failure_effects
Definition: global.h:264
Settings::starting_stat_points
uint8_t starting_stat_points
Definition: global.h:317
freearr_x
short freearr_x[SIZEOFFREE]
Definition: object.c:288
Settings
Definition: global.h:236
ob_types.h
Settings::meta_on
unsigned int meta_on
Definition: global.h:280
Settings::allow_denied_spells_writing
int allow_denied_spells_writing
Definition: global.h:310
Settings::disabled_plugins
linked_char * disabled_plugins
Definition: global.h:321
Settings::emergency_mapname
char * emergency_mapname
Definition: global.h:294
spells.h
SPELL_MAPPINGS
#define SPELL_MAPPINGS
Definition: global.h:147
Settings::who_wiz_format
char who_wiz_format[MAX_BUF]
Definition: global.h:272
reopen_logfile
int reopen_logfile
Definition: logger.c:26
EXTERN
#define EXTERN
Definition: global.h:15
Settings::spellpoint_level_depend
uint8_t spellpoint_level_depend
Definition: global.h:269
Settings::fastclock
uint8_t fastclock
Definition: global.h:292
player.h
newserver.h
Settings::personalized_blessings
uint8_t personalized_blessings
Definition: global.h:307
define.h
Settings::max_stat
uint8_t max_stat
Definition: global.h:319
Statistics
struct Statistics Statistics
Settings::armor_max_enchant
int armor_max_enchant
Definition: global.h:300
Settings::hooks
collectorHook hooks[20]
Definition: global.h:329
Settings::armor_weight_linear
uint8_t armor_weight_linear
Definition: global.h:302
Settings::worldmaptilesizex
uint32_t worldmaptilesizex
Definition: global.h:290
newclient.h
Settings::real_wiz
uint8_t real_wiz
Definition: global.h:266
account_char.h
config.h
first_map_ext_path
EXTERN char first_map_ext_path[MAX_BUF]
Definition: global.h:144
Settings::templatedir
const char * templatedir
Definition: global.h:249
trying_emergency_save
EXTERN long trying_emergency_save
Definition: global.h:127
Settings::worldmaptilesizey
uint32_t worldmaptilesizey
Definition: global.h:291
freedir
int freedir[SIZEOFFREE]
Definition: global.h:173
nrofartifacts
EXTERN long nrofartifacts
Definition: global.h:139
commands.h
exiting
EXTERN int exiting
Definition: global.h:138
pticks
uint32_t pticks
Definition: time.c:45
ob_methods.h
Settings::no_player_stealing
uint8_t no_player_stealing
Definition: global.h:305
Settings::account_trusted_host
char * account_trusted_host
Definition: global.h:324
Settings::search_items
uint8_t search_items
Definition: global.h:262
LogLevel
LogLevel
Definition: logger.h:10
Settings::tmpdir
const char * tmpdir
Definition: global.h:250
tod.h
Settings::always_show_hp
uint8_t always_show_hp
Definition: global.h:268
first_god
EXTERN godlink * first_god
Definition: global.h:120
ring_arch
EXTERN archetype * ring_arch
Definition: global.h:154
Settings::create_home_portals
uint8_t create_home_portals
Definition: global.h:306
first_region
EXTERN region * first_region
Definition: global.h:117
living.h
BufferReader
Definition: bufferreader.c:21
Settings::armor_speed_improvement
int armor_speed_improvement
Definition: global.h:303
Settings::log_timestamp
int log_timestamp
Definition: global.h:313
Settings::who_format
char who_format[MAX_BUF]
Definition: global.h:271
object.h
libproto.h
autoconf.h
Settings::starting_stat_max
uint8_t starting_stat_max
Definition: global.h:316
Settings::uniquedir
const char * uniquedir
Definition: global.h:248
Settings::localdir
const char * localdir
Definition: global.h:244
regiondef
Definition: map.h:275