Crossfire Server, Trunk  R22047
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 
123 
124 /*
125  * Variables set by different flags (see init.c):
126  */
127 
131 extern uint32_t pticks;
138 extern int reopen_logfile;
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 
172 extern short freearr_x[SIZEOFFREE], freearr_y[SIZEOFFREE];
173 extern int maxfree[SIZEOFFREE], freedir[SIZEOFFREE];
174 extern int rightof_x[9], rightof_y[9];
175 extern int leftof_x[9], leftof_y[9];
176 
177 extern const Face *blank_face, *empty_face;
178 extern const Face *smooth_face;
179 
180 extern uint32_t max_time; /* loop time */
182 
183 #include "stringbuffer.h"
184 #include "libproto.h"
185 #include "sockproto.h"
186 #include "typesproto.h"
187 
193 #define FREE_AND_CLEAR(xyz) { free(xyz); xyz = NULL; }
194 
198 #define FREE_AND_CLEAR_STR(xyz) { free_string(xyz); xyz = NULL; }
199 
200 #define FREE_AND_CLEAR_STR_IF(xyz) { if (xyz) { free_string(xyz); xyz = NULL; } }
201 
204 #define FREE_AND_COPY(sv, nv) { if (sv) free_string(sv); sv = add_string(nv); }
205 
206 #define FREE_AND_COPY_IF(sv, nv) { if (sv) free_string(sv); sv = nv ? add_string(nv) : NULL; }
207 
208 #ifndef WIN32 /* ---win32 we define this stuff in win32.h */
209 #if HAVE_DIRENT_H
210 # include <dirent.h>
211 # define NAMLEN(dirent) strlen((dirent)->d_name)
212 #else
213 # define dirent direct
214 # define NAMLEN(dirent) (dirent)->d_namlen
215 # if HAVE_SYS_NDIR_H
216 # include <sys/ndir.h>
217 # endif
218 # if HAVE_SYS_DIR_H
219 # include <sys/dir.h>
220 # endif
221 # if HAVE_NDIR_H
222 # include <ndir.h>
223 # endif
224 #endif
225 #endif
226 
230 #define PERM_EXP(exptotal) (exptotal * settings.permanent_exp_ratio / 100 )
231 #define MAX_TOTAL_EXPERIENCE (settings.permanent_exp_ratio ? (MAX_EXPERIENCE * 100 / settings.permanent_exp_ratio) : 0)
232 
233 typedef void(*collectorHook)(BufferReader *, const char *);
234 
238 typedef struct Settings {
239  const char *logfilename;
243  const char *dumparg;
244  const char *confdir;
245  const char *datadir;
246  const char *localdir;
247  const char *playerdir;
248  const char *mapdir;
249  const char *archetypes;
250  const char *regions;
251  const char *treasures;
252  const char *uniquedir;
253  const char *templatedir;
254  const char *tmpdir;
275  char who_format[MAX_BUF];
276  char who_wiz_format[MAX_BUF];
277  char motd[MAX_BUF];
278  const char *rules;
279  const char *news;
280  char dm_mail[MAX_BUF];
282  /* The meta_ is information for the metaserver. These are set in
283  * the lib/settings file.
284  */
285  unsigned int meta_on:1;
286  char meta_server[MAX_BUF];
287  char meta_host[MAX_BUF];
289  char meta_comment[MAX_BUF];
300  uint16_t emergency_x, emergency_y;
333  const char *hooks_filename[20];
334  collectorHook hooks[20];
337 } Settings;
338 
342 extern Settings settings;
343 
354 typedef struct Statistics {
358 } Statistics;
359 
363 extern Statistics statistics;
364 
369 #define SCRIPT_FIX_ACTIVATOR 2
370 #define SCRIPT_FIX_ALL 1
371 #define SCRIPT_FIX_NOTHING 0
372 
373 #include "plugin.h"
374 
375 #endif /* GLOBAL_H */
EXTERN FILE * logfile
Definition: global.h:137
uint8_t not_permadeth
Definition: global.h:261
const char * rules
Definition: global.h:278
int ignore_assets_errors
Definition: global.h:335
Definition: player.h:92
uint8_t create_home_portals
Definition: global.h:311
uint8_t stat_loss_on_death
Definition: global.h:255
const Face * empty_face
Definition: image.c:35
EXTERN long ob_count
Definition: global.h:148
uint8_t max_stat
Definition: global.h:324
uint32_t worldmaptilesx
Definition: global.h:293
uint8_t spell_encumbrance
Definition: global.h:267
int leftof_x[9]
uint32_t worldmaptilesizey
Definition: global.h:296
uint8_t starting_stat_min
Definition: global.h:320
unsigned int meta_on
Definition: global.h:285
linked_char * disabled_plugins
Definition: global.h:326
unsigned char uint8_t
Definition: win32.h:161
uint16_t meta_port
Definition: global.h:288
Definition: race.h:12
uint8_t death_penalty_level
Definition: global.h:259
Statistics statistics
Definition: init.c:101
uint64_t spell_merges
Definition: global.h:355
EXTERN objectlink * first_friendly_object
Definition: global.h:119
uint8_t spellpoint_level_depend
Definition: global.h:273
uint8_t hooks_count
Definition: global.h:332
uint16_t csport
Definition: global.h:240
Definition: face.h:14
const char * playerdir
Definition: global.h:247
int16_t max_level
Definition: global.h:302
uint32_t max_time
Definition: time.c:35
uint32_t worldmapstarty
Definition: global.h:292
int reopen_logfile
Definition: logger.c:26
const char * regions
Definition: global.h:250
int allow_broken_converters
Definition: global.h:316
int armor_max_enchant
Definition: global.h:305
const Face * smooth_face
Definition: image.c:35
int rightof_y[9]
Definition: god.h:12
uint8_t starting_stat_max
Definition: global.h:321
LogLevel debug
Definition: global.h:241
Settings settings
Definition: init.c:39
uint8_t death_penalty_ratio
Definition: global.h:258
EXTERN char first_map_ext_path[MAX_BUF]
Definition: global.h:146
int leftof_y[9]
uint32_t worldmaptilesy
Definition: global.h:294
const char * treasures
Definition: global.h:251
const char * logfilename
Definition: global.h:239
uint8_t casting_time
Definition: global.h:269
uint64_t spell_hash_full
Definition: global.h:356
uint8_t recycle_tmp_maps
Definition: global.h:271
uint16_t emergency_y
Definition: global.h:300
socket_struct * init_sockets
Definition: init.c:56
const char * news
Definition: global.h:279
EXTERN archetype * amulet_arch
Definition: global.h:154
void * archetypes_tracker
Definition: global.h:336
EXTERN archetype * empty_archetype
Definition: global.h:143
char * log_timestamp_format
Definition: global.h:319
int armor_speed_improvement
Definition: global.h:308
const char * dumparg
Definition: global.h:243
EXTERN const char * undead_name
Definition: global.h:155
signed short int16_t
Definition: win32.h:160
uint8_t search_items
Definition: global.h:266
int rightof_x[9]
uint8_t min_name
Definition: global.h:331
const char * tmpdir
Definition: global.h:254
int64_t pk_max_experience
Definition: global.h:313
uint8_t always_show_hp
Definition: global.h:272
Definition: map.h:277
const Face * blank_face
Definition: image.c:35
struct linked_char * next
Definition: global.h:88
uint8_t armor_weight_linear
Definition: global.h:307
uint8_t balanced_stat_loss
Definition: global.h:260
uint8_t armor_speed_linear
Definition: global.h:309
int maxfree[SIZEOFFREE]
Definition: object.c:77
EXTERN racelink * first_race
Definition: global.h:121
#define SIZEOFFREE
Definition: define.h:154
EXTERN long nroferrors
Definition: global.h:129
uint8_t real_wiz
Definition: global.h:270
void(* collectorHook)(BufferReader *, const char *)
Definition: global.h:233
short freearr_y[SIZEOFFREE]
Definition: object.c:71
uint8_t ignore_plugin_compatibility
Definition: global.h:327
const char * templatedir
Definition: global.h:253
EXTERN godlink * first_god
Definition: global.h:120
const char * archetypes
Definition: global.h:249
uint8_t simple_exp
Definition: global.h:262
unsigned __int64 uint64_t
Definition: win32.h:167
EXTERN artifactlist * first_artifactlist
Definition: global.h:118
#define MAX_BUF
Definition: define.h:35
LogLevel
Definition: logger.h:10
unsigned short uint16_t
Definition: win32.h:163
const char * confdir
Definition: global.h:244
EXTERN archetype * crown_arch
Definition: global.h:154
signed __int64 int64_t
Definition: win32.h:168
uint8_t account_block_create
Definition: global.h:328
const char * uniquedir
Definition: global.h:252
EXTERN long nrofartifacts
Definition: global.h:140
const char * sstring
Definition: global.h:40
uint8_t permanent_exp_ratio
Definition: global.h:257
int log_timestamp
Definition: global.h:318
unsigned int uint32_t
Definition: win32.h:162
const char * datadir
Definition: global.h:245
EXTERN long nrofallowedstr
Definition: global.h:141
uint8_t special_break_map
Definition: global.h:325
int freedir[SIZEOFFREE]
Definition: object.c:83
const char * name
Definition: global.h:87
uint16_t set_friendly_fire
Definition: global.h:274
int armor_weight_reduction
Definition: global.h:306
struct Settings Settings
#define EXTERN
Definition: global.h:15
const char * localdir
Definition: global.h:246
uint8_t starting_stat_points
Definition: global.h:322
uint8_t no_player_stealing
Definition: global.h:310
const char * mapdir
Definition: global.h:248
EXTERN int exiting
Definition: global.h:139
EXTERN long trying_emergency_save
Definition: global.h:128
uint64_t spell_suppressions
Definition: global.h:357
EXTERN char first_map_path[MAX_BUF]
Definition: global.h:145
uint32_t pticks
Definition: time.c:45
uint8_t fastclock
Definition: global.h:297
uint8_t crypt_mode
Definition: global.h:330
uint8_t dumpvalues
Definition: global.h:242
EXTERN player * first_player
Definition: global.h:115
int reset_loc_time
Definition: global.h:263
struct linked_char linked_char
uint8_t set_title
Definition: global.h:264
EXTERN archetype * ring_arch
Definition: global.h:154
EXTERN region * first_region
Definition: global.h:117
short freearr_x[SIZEOFFREE]
Definition: object.c:65
uint32_t worldmapstartx
Definition: global.h:291
int allow_denied_spells_writing
Definition: global.h:315
char * emergency_mapname
Definition: global.h:299
Definition: map.h:326
uint8_t roll_stat_points
Definition: global.h:323
uint32_t worldmaptilesizex
Definition: global.h:295
int pk_max_experience_percent
Definition: global.h:314
uint8_t spell_failure_effects
Definition: global.h:268
EXTERN mapstruct * first_map
Definition: global.h:116
EXTERN archetype * map_archeytpe
Definition: global.h:144
float item_power_factor
Definition: global.h:303
struct Statistics Statistics
uint8_t resurrection
Definition: global.h:265
int16_t pk_luck_penalty
Definition: global.h:256
uint8_t personalized_blessings
Definition: global.h:312
char * account_trusted_host
Definition: global.h:329