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