Crossfire Server, Trunk  R20513
Go to the documentation of this file.
6 #ifndef GLOBAL_H
7 #define GLOBAL_H
14 #ifndef EXTERN
15 #define EXTERN extern
16 #endif
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
30 #include <dmalloc.h>
31 #endif
33 #include <inttypes.h>
34 #include <stdbool.h>
35 #include <stdio.h>
36 #include <unistd.h>
37 #include "compat.h"
40 typedef const char *sstring;
42 #include "config.h"
43 #include "define.h"
44 #include "logger.h"
45 #include "shared/newclient.h"
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"
57 #include "skills.h"
59 /* This defines the Account_Char structure which is used in the socket */
60 #include "account_char.h"
62 /* Pull in the socket structure - used in the player structure */
63 #include "newserver.h"
65 #include "party.h"
67 /* Pull in the player structure */
68 #include "player.h"
70 /* pull in treasure structure */
71 #include "treasure.h"
73 #include "commands.h"
75 /* pull in book structures */
76 #include "book.h"
78 /* ob_methods and ob_types subsystem */
79 #include "ob_methods.h"
80 #include "ob_types.h"
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;
92 /* Pull in artifacts */
93 #include "artifact.h"
95 /* Now for gods */
96 #include "god.h"
98 /* Now for races */
99 #include "race.h"
101 /* Now for recipe/alchemy */
102 #include "recipe.h"
104 /* Now for spells */
105 #include "spells.h"
107 /*****************************************************************************
109  *****************************************************************************/
111 extern New_Face *new_faces;
128 /*
129  * Variables set by different flags (see init.c):
130  */
138 extern uint32_t pticks;
145 extern int reopen_logfile;
159 /*
160  * Used in treasure.c
161  */
163 EXTERN const char *undead_name; /* Used in hit_player() in main.c */
168 /* Rotate right from bsd sum. This is used in various places for checksumming */
169 #define ROTATE_RIGHT(c) if ((c)&01) (c) = ((c)>>1)+0x80000000; else (c) >>= 1;
171 #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]; } }
172 #define GET_ANIMATION(ob, anim) (ob->temp_animation_id ? animations[ob->temp_animation_id].faces[anim] : animations[ob->animation_id].faces[anim])
173 #define GET_ANIM_ID(ob) (ob->temp_animation_id ? ob->temp_animation_id : ob->animation_id)
174 /* NUM_ANIMATIONS returns the number of animations allocated. The last
175  * usuable animation will be NUM_ANIMATIONS-1 (for example, if an object
176  * has 8 animations, NUM_ANIMATIONS will return 8, but the values will
177  * range from 0 through 7.
178  */
179 #define NUM_ANIMATIONS(ob) (ob->temp_animation_id ? animations[ob->temp_animation_id].num_animations : animations[ob->animation_id].num_animations)
180 #define NUM_FACINGS(ob) (ob->temp_animation_id ? animations[ob->temp_animation_id].facings : animations[ob->animation_id].facings)
182 extern short freearr_x[SIZEOFFREE], freearr_y[SIZEOFFREE];
183 extern int maxfree[SIZEOFFREE], freedir[SIZEOFFREE];
184 extern int rightof_x[9], rightof_y[9];
185 extern int leftof_x[9], leftof_y[9];
187 extern New_Face *blank_face, *empty_face;
188 extern New_Face *smooth_face;
190 extern uint32_t max_time; /* loop time */
193 #include "stringbuffer.h"
194 #include "libproto.h"
195 #include "sockproto.h"
196 #include "typesproto.h"
203 #define FREE_AND_CLEAR(xyz) { free(xyz); xyz = NULL; }
208 #define FREE_AND_CLEAR_STR(xyz) { free_string(xyz); xyz = NULL; }
213 #define FREE_AND_COPY(sv, nv) { if (sv) free_string(sv); sv = add_string(nv); }
215 #ifndef WIN32 /* ---win32 we define this stuff in win32.h */
217 # include <dirent.h>
218 # define NAMLEN(dirent) strlen((dirent)->d_name)
219 #else
220 # define dirent direct
221 # define NAMLEN(dirent) (dirent)->d_namlen
222 # if HAVE_SYS_NDIR_H
223 # include <sys/ndir.h>
224 # endif
225 # if HAVE_SYS_DIR_H
226 # include <sys/dir.h>
227 # endif
228 # if HAVE_NDIR_H
229 # include <ndir.h>
230 # endif
231 #endif
232 #endif
237 typedef struct Settings {
238  const char *logfilename;
242  const char *dumparg;
243  const char *confdir;
244  const char *datadir;
245  const char *localdir;
246  const char *playerdir;
247  const char *mapdir;
248  const char *archetypes;
249  const char *regions;
250  const char *treasures;
251  const char *uniquedir;
252  const char *templatedir;
253  const char *tmpdir;
273  char who_format[MAX_BUF];
274  char who_wiz_format[MAX_BUF];
275  char motd[MAX_BUF];
276  const char *rules;
277  const char *news;
278  char dm_mail[MAX_BUF];
280  /* The meta_ is information for the metaserver. These are set in
281  * the lib/settings file.
282  */
283  unsigned int meta_on:1;
284  char meta_server[MAX_BUF];
285  char meta_host[MAX_BUF];
287  char meta_comment[MAX_BUF];
298  uint16_t emergency_x, emergency_y;
328 } Settings;
333 extern Settings settings;
345 typedef struct Statistics {
349 } Statistics;
354 extern Statistics statistics;
361 #define SCRIPT_FIX_ALL 1
362 #define SCRIPT_FIX_NOTHING 0
364 #include "plugin.h"
366 #endif /* GLOBAL_H */
EXTERN FILE * logfile
Used by server/daemon.c.
Definition: global.h:144
uint8_t not_permadeth
If true, death is non-permament.
Definition: global.h:260
const char * rules
Name of rules file.
Definition: global.h:276
One player.
Definition: player.h:92
uint8_t create_home_portals
If 1, can create portals in unique maps (apartments)
Definition: global.h:309
Spell-related defines: spellpath, subtypes, ...
uint8_t stat_loss_on_death
If true, chars lose a random stat when they die.
Definition: global.h:254
EXTERN long ob_count
Definition: global.h:156
uint8_t max_stat
Maximum stat value - 255 should be sufficient.
Definition: global.h:322
treasureliststruct represents one logical group of items to be generated together.
Definition: treasure.h:82
uint32_t worldmaptilesx
Number of tiles wide the worldmap is.
Definition: global.h:291
Used to link together several objects.
Definition: object.h:442
Material structures and defines.
uint8_t spell_encumbrance
Encumbrance effects spells.
Definition: global.h:266
int leftof_x[9]
uint32_t worldmaptilesizey
Number of squares high in a wm tile.
Definition: global.h:294
uint8_t starting_stat_min
Minimum value of a starting stat.
Definition: global.h:318
linked_char * disabled_plugins
List of disabled plugins, &#39;All&#39; means all.
Definition: global.h:324
unsigned char uint8_t
Definition: win32.h:161
uint16_t meta_port
Port number to use for updates.
Definition: global.h:286
Defines for the ingame clock, ticks management and weather system.
Contains information about a race.
Definition: race.h:12
uint8_t death_penalty_level
How many levels worth of exp may be lost on one death.
Definition: global.h:258
EXTERN int num_animations
Definition: global.h:166
Defines various flags that both the new client and new server use.
Statistics statistics
Merged spell statistics.
Definition: init.c:113
uint64_t spell_merges
Number of spell merges done.
Definition: global.h:346
EXTERN objectlink * first_friendly_object
Objects monsters will go after.
Definition: global.h:123
uint8_t spellpoint_level_depend
Spell costs go up with level.
Definition: global.h:271
uint16_t csport
Port for new client/server.
Definition: global.h:239
const char * playerdir
Where the player files are.
Definition: global.h:246
int16_t max_level
This is read out of exp_table.
Definition: global.h:300
uint32_t max_time
Gloabal variables:
Definition: time.c:35
uint32_t worldmapstarty
Starting y tile for the worldmap.
Definition: global.h:290
int reopen_logfile
Definition: logger.c:26
Socket structure, represents a client-server connection.
Definition: newserver.h:99
const char * regions
Name of the regions file - libdir is prepended.
Definition: global.h:249
int allow_broken_converters
If set, converters will work even if price of generated item is higher than the price of converted it...
Definition: global.h:314
Definitions for the plugin system.
int armor_max_enchant
Maximum number of times an armor can be enchanted.
Definition: global.h:303
int rightof_y[9]
Used to link together the gods.
Definition: god.h:12
This file contains various #defines that select various options.
God-related structure.
uint8_t starting_stat_max
Maximum value of a starting stat.
Definition: global.h:319
Race-related structure.
LogLevel debug
Default debugging level.
Definition: global.h:240
Settings settings
Server settings.
Definition: init.c:40
uint8_t death_penalty_ratio
Hhow much exp should be lost at death.
Definition: global.h:257
EXTERN char first_map_ext_path[MAX_BUF]
Path used for per-race start maps.
Definition: global.h:154
int leftof_y[9]
uint32_t worldmaptilesy
Number of tiles high the worldmap is.
Definition: global.h:292
const char * treasures
Location of the treasures file.
Definition: global.h:250
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:465
const char * logfilename
Logfile to use.
Definition: global.h:238
uint8_t casting_time
It takes awhile to cast a spell.
Definition: global.h:268
uint64_t spell_hash_full
Number of times spell hash was full.
Definition: global.h:347
uint8_t recycle_tmp_maps
Re-use tmp maps.
Definition: global.h:270
uint16_t emergency_y
Coordinates to use on that map.
Definition: global.h:298
Player-specific structures.
socket_struct * init_sockets
Established connections for clients not yet playing.
Definition: init.c:56
const char * news
Name of news file.
Definition: global.h:277
EXTERN archetype * amulet_arch
Definition: global.h:162
EXTERN archetype * empty_archetype
Nice to have fast access to it.
Definition: global.h:151
char * log_timestamp_format
Format for timestap, if log_timestamp is set.
Definition: global.h:317
int armor_speed_improvement
Speed improvement.
Definition: global.h:306
const char * dumparg
Additional argument for some dump functions.
Definition: global.h:242
EXTERN const char * undead_name
Definition: global.h:163
signed short int16_t
Definition: win32.h:160
uint8_t search_items
Search_items command.
Definition: global.h:265
Defines and variables used by the artifact generation routines.
int rightof_x[9]
This is used for various performance tracking statistics, or just how often certain events are done...
Definition: global.h:345
const char * tmpdir
Directory to use for temporary files.
Definition: global.h:253
int64_t pk_max_experience
Maximum experience one can get for PKing.
Definition: global.h:311
This is a game region.
Definition: map.h:276
struct linked_char * next
Definition: global.h:88
Party-specific structures.
uint8_t armor_weight_linear
If 1, weight reduction is linear, else exponantiel.
Definition: global.h:305
uint8_t balanced_stat_loss
If true, Death stat depletion based on level etc.
Definition: global.h:259
Characters associated with an account.n.
This represents one animation.
Definition: face.h:26
uint8_t armor_speed_linear
If 1, speed improvement is linear, else exponantiel.
Definition: global.h:307
Attack-related definitions.
New_Face * new_faces
Contains face information, with names, numbers, magicmap color and such.
Definition: image.c:33
int maxfree[SIZEOFFREE]
Number of spots around a location, including that location (except for 0)
Definition: object.c:77
Defines various structures and values that are used for the new client server communication method...
EXTERN racelink * first_race
Race list.
Definition: global.h:125
Definition: define.h:154
EXTERN long nroferrors
If it exceeds MAX_ERRORS, call fatal()
Definition: global.h:136
Face-related structures.
EXTERN Animations * animations
Definition: global.h:165
uint8_t real_wiz
Use mud-like wizards.
Definition: global.h:269
short freearr_y[SIZEOFFREE]
Y offset when searching around a spot.
Definition: object.c:71
Defines and structures related to commands the player can send.
uint8_t ignore_plugin_compatibility
If set, don&#39;t check plugin version.
Definition: global.h:325
const char * templatedir
Directory for the template map.
Definition: global.h:252
EXTERN godlink * first_god
God list.
Definition: global.h:124
This represents all archetypes for one particular object type.
Definition: artifact.h:26
const char * archetypes
Name of the archetypes file - libdir is prepended.
Definition: global.h:248
uint8_t simple_exp
If true, use the simple experience system.
Definition: global.h:261
EXTERN treasurelist * first_treasurelist
First treasure.
Definition: global.h:120
Alchemy recipe structures.
Server settings.
Definition: global.h:237
unsigned __int64 uint64_t
Definition: win32.h:167
EXTERN artifactlist * first_artifactlist
First artifact.
Definition: global.h:121
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
New_Face * empty_face
Definition: image.c:39
Compatibility implementations of useful nonstandard types and functions.
Log levels for the LOG() function.
Definition: logger.h:10
Skill-related defines, including subtypes.
Object type variables.
unsigned short uint16_t
Definition: win32.h:163
const char * confdir
Configuration files.
Definition: global.h:243
EXTERN archetype * crown_arch
Definition: global.h:162
signed __int64 int64_t
Definition: win32.h:168
Implements a general string buffer: it builds a string by concatenating.
New_Face * smooth_face
Definition: image.c:39
uint8_t account_block_create
Definition: global.h:326
const char * uniquedir
Directory for the unique items.
Definition: global.h:251
EXTERN long nrofartifacts
Only used in malloc_info().
Definition: global.h:148
const char * sstring
Strings that should be manipulated through add_string() and free_string().
Definition: global.h:40
uint8_t permanent_exp_ratio
How much exp should be &#39;permenant&#39; and unable to be lost.
Definition: global.h:256
int log_timestamp
If set, log will comport a timestamp.
Definition: global.h:316
unsigned int uint32_t
Definition: win32.h:162
const char * datadir
Read only data files.
Definition: global.h:244
EXTERN long nrofallowedstr
Only used in malloc_info().
Definition: global.h:149
uint8_t special_break_map
If set, then submaps in random maps can break the walls.
Definition: global.h:323
int freedir[SIZEOFFREE]
Direction we&#39;re pointing on this spot.
Definition: object.c:83
const char * name
Definition: global.h:87
Object structure, the core of Crossfire.
uint16_t set_friendly_fire
Percent of damage done by peaceful player vs player damage.
Definition: global.h:272
int armor_weight_reduction
Weight reduction per enchantment.
Definition: global.h:304
struct Settings Settings
Server settings.
#define EXTERN
Define external variables.
Definition: global.h:15
const char * localdir
Read/write data files.
Definition: global.h:245
Log levels.
uint8_t starting_stat_points
How many stat points character starts with.
Definition: global.h:320
uint8_t no_player_stealing
If 1, can not steal from other players.
Definition: global.h:308
EXTERN archetype * staff_arch
Definition: global.h:162
const char * mapdir
Where the map files are.
Definition: global.h:247
EXTERN int bmaps_checksum
Definition: global.h:166
EXTERN int exiting
True if the game is about to exit.
Definition: global.h:146
EXTERN long trying_emergency_save
True when emergency_save() is reached.
Definition: global.h:135
uint64_t spell_suppressions
Number of times ok_to_put_more() returned FALSE.
Definition: global.h:348
EXTERN int animations_allocated
Definition: global.h:166
This file contains basic map-related structures and macros.
EXTERN char first_map_path[MAX_BUF]
The start-level.
Definition: global.h:153
uint32_t pticks
Used by various function to determine how often to save the character.
Definition: time.c:45
uint8_t fastclock
If true, clock goes warp 9.
Definition: global.h:295
uint8_t dumpvalues
Set to dump various values/tables.
Definition: global.h:241
EXTERN player * first_player
First player.
Definition: global.h:117
New face structure - this enforces the notion that data is face by face only - you can not change the...
Definition: face.h:14
int reset_loc_time
Number of seconds to put player back at home.
Definition: global.h:262
struct linked_char linked_char
New_Face * blank_face
Following can just as easily be pointers, but it is easier to keep them like this.
Definition: image.c:39
EXTERN long init_done
Ignores signals until init_done is true.
Definition: global.h:134
uint8_t set_title
Players can set thier title.
Definition: global.h:263
EXTERN long warn_archetypes
If true, write warnings when failing to find archetypes when loading from file.
Definition: global.h:132
EXTERN archetype * ring_arch
Definition: global.h:162
EXTERN region * first_region
First region.
Definition: global.h:119
short freearr_x[SIZEOFFREE]
X offset when searching around a spot.
Definition: object.c:65
uint32_t worldmapstartx
Starting x tile for the worldmap.
Definition: global.h:289
Structure containing object statistics.
int allow_denied_spells_writing
If set, players can write spells they can&#39;t cast.
Definition: global.h:313
char * emergency_mapname
Map to return players to in emergency.
Definition: global.h:297
This is a game-map.
Definition: map.h:325
uint8_t roll_stat_points
How many stat points legacy (rolled) chars start with.
Definition: global.h:321
uint32_t worldmaptilesizex
Number of squares wide in a wm tile.
Definition: global.h:293
int pk_max_experience_percent
Percentage of experience of victim the killer gets.
Definition: global.h:312
Object type functions and variables.
uint8_t spell_failure_effects
Nasty backlash to spell failures.
Definition: global.h:267
Describes fundental parameters of &#39;books&#39; - objects with type==BOOK.
EXTERN mapstruct * first_map
First map.
Definition: global.h:118
Structures and types used to implement opendir/readdir/closedir on Windows 95/NT and set the loe leve...
EXTERN archetype * first_archetype
First archetype.
Definition: global.h:122
EXTERN archetype * map_archeytpe
Definition: global.h:152
Artifact-related structures.
float item_power_factor
See note in setings file.
Definition: global.h:301
struct Statistics Statistics
This is used for various performance tracking statistics, or just how often certain events are done...
uint8_t resurrection
Ressurection possible w/ permadeth on.
Definition: global.h:264
int16_t pk_luck_penalty
Amount by which player luck is reduced if they PK.
Definition: global.h:255
uint8_t personalized_blessings
If 1, blessed weapons get an owner and a willpower value.
Definition: global.h:310
Core defines: object types, flags, etc.
char * account_trusted_host
Block account creation for untrusted hosts.
Definition: global.h:327
EXTERN long nroftreasures
Only used in malloc_info().
Definition: global.h:147