Crossfire Server, Trunk  R20739
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 #ifdef WIN32 /* ---win32 exclude this, config comes from VC ide */
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 
111 extern New_Face *new_faces;
112 
127 
128 /*
129  * Variables set by different flags (see init.c):
130  */
131 
136 extern uint32_t pticks;
143 extern int reopen_logfile;
157 /*
158  * Used in treasure.c
159  */
161 EXTERN const char *undead_name; /* Used in hit_player() in main.c */
162 
165 
166 /* Rotate right from bsd sum. This is used in various places for checksumming */
167 #define ROTATE_RIGHT(c) if ((c)&01) (c) = ((c)>>1)+0x80000000; else (c) >>= 1;
168 
169 #define SET_ANIMATION(ob, newanim) { if (ob->temp_animation_id) { ob->face = animations[ob->temp_animation_id].faces[newanim]; } else { ob->face = animations[ob->animation_id].faces[newanim]; } }
170 #define GET_ANIMATION(ob, anim) (ob->temp_animation_id ? animations[ob->temp_animation_id].faces[anim] : animations[ob->animation_id].faces[anim])
171 #define GET_ANIM_ID(ob) (ob->temp_animation_id ? ob->temp_animation_id : ob->animation_id)
172 /* NUM_ANIMATIONS returns the number of animations allocated. The last
173  * usuable animation will be NUM_ANIMATIONS-1 (for example, if an object
174  * has 8 animations, NUM_ANIMATIONS will return 8, but the values will
175  * range from 0 through 7.
176  */
177 #define NUM_ANIMATIONS(ob) (ob->temp_animation_id ? animations[ob->temp_animation_id].num_animations : animations[ob->animation_id].num_animations)
178 #define NUM_FACINGS(ob) (ob->temp_animation_id ? animations[ob->temp_animation_id].facings : animations[ob->animation_id].facings)
179 
180 extern short freearr_x[SIZEOFFREE], freearr_y[SIZEOFFREE];
181 extern int maxfree[SIZEOFFREE], freedir[SIZEOFFREE];
182 extern int rightof_x[9], rightof_y[9];
183 extern int leftof_x[9], leftof_y[9];
184 
185 extern New_Face *blank_face, *empty_face;
186 extern New_Face *smooth_face;
187 
188 extern uint32_t max_time; /* loop time */
190 
191 #include "stringbuffer.h"
192 #include "libproto.h"
193 #include "sockproto.h"
194 #include "typesproto.h"
195 
201 #define FREE_AND_CLEAR(xyz) { free(xyz); xyz = NULL; }
202 
206 #define FREE_AND_CLEAR_STR(xyz) { free_string(xyz); xyz = NULL; }
207 
211 #define FREE_AND_COPY(sv, nv) { if (sv) free_string(sv); sv = add_string(nv); }
212 
213 #ifndef WIN32 /* ---win32 we define this stuff in win32.h */
214 #if HAVE_DIRENT_H
215 # include <dirent.h>
216 # define NAMLEN(dirent) strlen((dirent)->d_name)
217 #else
218 # define dirent direct
219 # define NAMLEN(dirent) (dirent)->d_namlen
220 # if HAVE_SYS_NDIR_H
221 # include <sys/ndir.h>
222 # endif
223 # if HAVE_SYS_DIR_H
224 # include <sys/dir.h>
225 # endif
226 # if HAVE_NDIR_H
227 # include <ndir.h>
228 # endif
229 #endif
230 #endif
231 
235 typedef struct Settings {
236  const char *logfilename;
240  const char *dumparg;
241  const char *confdir;
242  const char *datadir;
243  const char *localdir;
244  const char *playerdir;
245  const char *mapdir;
246  const char *archetypes;
247  const char *regions;
248  const char *treasures;
249  const char *uniquedir;
250  const char *templatedir;
251  const char *tmpdir;
272  char who_format[MAX_BUF];
273  char who_wiz_format[MAX_BUF];
274  char motd[MAX_BUF];
275  const char *rules;
276  const char *news;
277  char dm_mail[MAX_BUF];
279  /* The meta_ is information for the metaserver. These are set in
280  * the lib/settings file.
281  */
282  unsigned int meta_on:1;
283  char meta_server[MAX_BUF];
284  char meta_host[MAX_BUF];
286  char meta_comment[MAX_BUF];
297  uint16_t emergency_x, emergency_y;
328 } Settings;
329 
333 extern Settings settings;
334 
345 typedef struct Statistics {
349 } Statistics;
350 
354 extern Statistics statistics;
355 
360 #define SCRIPT_FIX_ACTIVATOR 2
361 #define SCRIPT_FIX_ALL 1
362 #define SCRIPT_FIX_NOTHING 0
363 
364 #include "plugin.h"
365 
366 #endif /* GLOBAL_H */
EXTERN FILE * logfile
Definition: global.h:142
uint8_t not_permadeth
Definition: global.h:258
const char * rules
Definition: global.h:275
Definition: player.h:92
uint8_t create_home_portals
Definition: global.h:308
uint8_t stat_loss_on_death
Definition: global.h:252
EXTERN long ob_count
Definition: global.h:154
uint8_t max_stat
Definition: global.h:321
uint32_t worldmaptilesx
Definition: global.h:290
Definition: object.h:442
uint8_t spell_encumbrance
Definition: global.h:264
int leftof_x[9]
uint32_t worldmaptilesizey
Definition: global.h:293
uint8_t starting_stat_min
Definition: global.h:317
unsigned int meta_on
Definition: global.h:282
linked_char * disabled_plugins
Definition: global.h:323
unsigned char uint8_t
Definition: win32.h:161
uint16_t meta_port
Definition: global.h:285
Definition: race.h:12
uint8_t death_penalty_level
Definition: global.h:256
EXTERN int num_animations
Definition: global.h:164
Statistics statistics
Definition: init.c:115
uint64_t spell_merges
Definition: global.h:346
EXTERN objectlink * first_friendly_object
Definition: global.h:123
uint8_t spellpoint_level_depend
Definition: global.h:270
uint16_t csport
Definition: global.h:237
const char * playerdir
Definition: global.h:244
int16_t max_level
Definition: global.h:299
uint32_t max_time
Definition: time.c:35
uint32_t worldmapstarty
Definition: global.h:289
int reopen_logfile
Definition: logger.c:26
const char * regions
Definition: global.h:247
int allow_broken_converters
Definition: global.h:313
int armor_max_enchant
Definition: global.h:302
int rightof_y[9]
Definition: god.h:12
uint8_t starting_stat_max
Definition: global.h:318
LogLevel debug
Definition: global.h:238
Settings settings
Definition: init.c:40
uint8_t death_penalty_ratio
Definition: global.h:255
EXTERN char first_map_ext_path[MAX_BUF]
Definition: global.h:152
int leftof_y[9]
uint32_t worldmaptilesy
Definition: global.h:291
const char * treasures
Definition: global.h:248
Definition: object.h:465
const char * logfilename
Definition: global.h:236
uint8_t casting_time
Definition: global.h:266
uint64_t spell_hash_full
Definition: global.h:347
uint8_t recycle_tmp_maps
Definition: global.h:268
uint16_t emergency_y
Definition: global.h:297
socket_struct * init_sockets
Definition: init.c:56
const char * news
Definition: global.h:276
EXTERN archetype * amulet_arch
Definition: global.h:160
EXTERN archetype * empty_archetype
Definition: global.h:149
char * log_timestamp_format
Definition: global.h:316
int armor_speed_improvement
Definition: global.h:305
const char * dumparg
Definition: global.h:240
EXTERN const char * undead_name
Definition: global.h:161
signed short int16_t
Definition: win32.h:160
uint8_t search_items
Definition: global.h:263
int rightof_x[9]
const char * tmpdir
Definition: global.h:251
int64_t pk_max_experience
Definition: global.h:310
uint8_t always_show_hp
Definition: global.h:269
Definition: map.h:276
struct linked_char * next
Definition: global.h:88
uint8_t armor_weight_linear
Definition: global.h:304
uint8_t balanced_stat_loss
Definition: global.h:257
uint8_t armor_speed_linear
Definition: global.h:306
New_Face * new_faces
Definition: image.c:33
int maxfree[SIZEOFFREE]
Definition: object.c:77
EXTERN racelink * first_race
Definition: global.h:125
#define SIZEOFFREE
Definition: define.h:154
EXTERN long nroferrors
Definition: global.h:134
EXTERN Animations * animations
Definition: global.h:163
uint8_t real_wiz
Definition: global.h:267
short freearr_y[SIZEOFFREE]
Definition: object.c:71
uint8_t ignore_plugin_compatibility
Definition: global.h:324
const char * templatedir
Definition: global.h:250
EXTERN godlink * first_god
Definition: global.h:124
const char * archetypes
Definition: global.h:246
uint8_t simple_exp
Definition: global.h:259
EXTERN treasurelist * first_treasurelist
Definition: global.h:120
unsigned __int64 uint64_t
Definition: win32.h:167
EXTERN artifactlist * first_artifactlist
Definition: global.h:121
#define MAX_BUF
Definition: define.h:35
New_Face * empty_face
Definition: image.c:39
LogLevel
Definition: logger.h:10
unsigned short uint16_t
Definition: win32.h:163
const char * confdir
Definition: global.h:241
EXTERN archetype * crown_arch
Definition: global.h:160
signed __int64 int64_t
Definition: win32.h:168
New_Face * smooth_face
Definition: image.c:39
uint8_t account_block_create
Definition: global.h:325
const char * uniquedir
Definition: global.h:249
EXTERN long nrofartifacts
Definition: global.h:146
const char * sstring
Definition: global.h:40
uint8_t permanent_exp_ratio
Definition: global.h:254
int log_timestamp
Definition: global.h:315
unsigned int uint32_t
Definition: win32.h:162
const char * datadir
Definition: global.h:242
EXTERN long nrofallowedstr
Definition: global.h:147
uint8_t special_break_map
Definition: global.h:322
int freedir[SIZEOFFREE]
Definition: object.c:83
const char * name
Definition: global.h:87
uint16_t set_friendly_fire
Definition: global.h:271
int armor_weight_reduction
Definition: global.h:303
struct Settings Settings
#define EXTERN
Definition: global.h:15
const char * localdir
Definition: global.h:243
uint8_t starting_stat_points
Definition: global.h:319
uint8_t no_player_stealing
Definition: global.h:307
EXTERN archetype * staff_arch
Definition: global.h:160
const char * mapdir
Definition: global.h:245
EXTERN int bmaps_checksum
Definition: global.h:164
EXTERN int exiting
Definition: global.h:144
EXTERN long trying_emergency_save
Definition: global.h:133
uint64_t spell_suppressions
Definition: global.h:348
EXTERN int animations_allocated
Definition: global.h:164
EXTERN char first_map_path[MAX_BUF]
Definition: global.h:151
uint32_t pticks
Definition: time.c:45
uint8_t fastclock
Definition: global.h:294
uint8_t crypt_mode
Definition: global.h:327
uint8_t dumpvalues
Definition: global.h:239
EXTERN player * first_player
Definition: global.h:117
int reset_loc_time
Definition: global.h:260
struct linked_char linked_char
New_Face * blank_face
Definition: image.c:39
EXTERN long init_done
Definition: global.h:132
uint8_t set_title
Definition: global.h:261
EXTERN archetype * ring_arch
Definition: global.h:160
EXTERN region * first_region
Definition: global.h:119
short freearr_x[SIZEOFFREE]
Definition: object.c:65
uint32_t worldmapstartx
Definition: global.h:288
int allow_denied_spells_writing
Definition: global.h:312
char * emergency_mapname
Definition: global.h:296
Definition: map.h:325
uint8_t roll_stat_points
Definition: global.h:320
uint32_t worldmaptilesizex
Definition: global.h:292
int pk_max_experience_percent
Definition: global.h:311
uint8_t spell_failure_effects
Definition: global.h:265
EXTERN mapstruct * first_map
Definition: global.h:118
EXTERN archetype * first_archetype
Definition: global.h:122
EXTERN archetype * map_archeytpe
Definition: global.h:150
float item_power_factor
Definition: global.h:300
struct Statistics Statistics
uint8_t resurrection
Definition: global.h:262
int16_t pk_luck_penalty
Definition: global.h:253
uint8_t personalized_blessings
Definition: global.h:309
char * account_trusted_host
Definition: global.h:326
EXTERN long nroftreasures
Definition: global.h:145