00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00034 #ifndef GLOBAL_H
00035 #define GLOBAL_H
00036
00037 #ifndef EXTERN
00038 #define EXTERN extern
00039 #endif
00040
00041 #include "includes.h"
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 typedef unsigned int uint32;
00059
00060 #ifndef UINT32_MAX
00061 #define UINT32_MAX 4294967295U
00062 #endif
00063
00064 typedef signed int sint32;
00065 #define SINT32_MAX 2147483647
00066
00067 typedef unsigned short uint16;
00068 #ifndef UINT16_MAX
00069 #define UINT16_MAX 65535
00070 #endif
00071
00072 typedef signed short sint16;
00073 #define SINT16_MAX 32767
00074
00075 typedef unsigned char uint8;
00076 #ifndef UINT8_MAX
00077 #define UINT8_MAX 255
00078 #endif
00079
00080 typedef signed char sint8;
00081 #define SINT8_MAX 127
00082
00084 typedef const char *sstring;
00085
00086 typedef unsigned short Fontindex;
00087
00088 #ifdef WIN32
00089
00090
00091 typedef unsigned __int64 uint64;
00092 typedef signed __int64 sint64;
00093
00094 #define atoll _atoi64
00095
00096 #define FMT64 "I64d"
00097 #define FMT64U "I64u"
00098
00099
00100 #pragma warning(disable: 4244)
00101 #pragma warning(disable: 4305)
00102
00103 #else
00104
00105 #if SIZEOF_LONG == 8
00106
00107 typedef unsigned long uint64;
00108 typedef signed long sint64;
00109 #define FMT64 "ld"
00110 #define FMT64U "lu"
00111
00112 #elif SIZEOF_LONG_LONG == 8
00113 typedef unsigned long long uint64;
00114 typedef signed long long sint64;
00115 #define FMT64 "lld"
00116 #define FMT64U "llu"
00117
00118 #else
00119 #error do not know how to get a 64 bit value on this system.
00120 #error correct and send mail to crossfire-devel on how to do this
00121 #endif
00122
00123 #endif
00124
00125
00126 #include "face.h"
00127
00128 #include "attack.h"
00129 #include "material.h"
00130 #include "living.h"
00131 #include "object.h"
00132 #include "map.h"
00133 #include "tod.h"
00134
00135 #include "skills.h"
00136
00137
00138 #include "newserver.h"
00139
00140
00141 #include "player.h"
00142
00143
00144 #include "treasure.h"
00145
00146 #include "commands.h"
00147
00148
00149 #include "book.h"
00150
00151
00152 #include "ob_methods.h"
00153 #include "ob_types.h"
00154
00155
00156
00157
00158
00159 typedef struct linked_char {
00160 const char *name;
00161 struct linked_char *next;
00162 } linked_char;
00163
00164
00165
00166 #include "artifact.h"
00167
00168
00169 #include "god.h"
00170
00171
00172 #include "race.h"
00173
00174
00175 #include "recipe.h"
00176
00177
00178 #include "spells.h"
00179
00180
00181
00182
00183
00184 extern New_Face *new_faces;
00185
00190 EXTERN player *first_player;
00191 EXTERN mapstruct *first_map;
00192 EXTERN region *first_region;
00193 EXTERN treasurelist *first_treasurelist;
00194 EXTERN artifactlist *first_artifactlist;
00195 EXTERN archetype *first_archetype;
00196 EXTERN objectlink *first_friendly_object;
00197 EXTERN godlink *first_god;
00198 EXTERN racelink *first_race;
00200
00201 #define NROF_COMPRESS_METHODS 4
00202 extern const char *uncomp[NROF_COMPRESS_METHODS][3];
00203
00204
00205
00206
00207
00208 EXTERN long warn_archetypes;
00210 EXTERN long init_done;
00211 EXTERN long trying_emergency_save;
00212 EXTERN long nroferrors;
00214 extern uint32 pticks;
00220 EXTERN FILE *logfile;
00221 extern int reopen_logfile;
00222 EXTERN int exiting;
00223 EXTERN long nroftreasures;
00224 EXTERN long nrofartifacts;
00225 EXTERN long nrofallowedstr;
00227 EXTERN archetype *empty_archetype;
00228 EXTERN archetype *map_archeytpe;
00229 EXTERN char first_map_path[MAX_BUF];
00230 EXTERN char first_map_ext_path[MAX_BUF];
00232 EXTERN long ob_count;
00235
00236
00237
00238 EXTERN archetype *ring_arch, *amulet_arch, *staff_arch, *crown_arch;
00239 EXTERN const char *undead_name;
00240
00241 EXTERN Animations *animations;
00242 EXTERN int num_animations, animations_allocated, bmaps_checksum;
00243
00244
00245 #define ROTATE_RIGHT(c) if ((c)&01) (c) = ((c)>>1)+0x80000000; else (c) >>= 1;
00246
00247 #define SET_ANIMATION(ob, newanim) { if (ob->temp_animation_id) { ob->face = &new_faces[animations[ob->temp_animation_id].faces[newanim]]; } else { ob->face = &new_faces[animations[ob->animation_id].faces[newanim]]; } }
00248 #define GET_ANIMATION(ob, anim) (ob->temp_animation_id ? animations[ob->temp_animation_id].faces[anim] : animations[ob->animation_id].faces[anim])
00249 #define GET_ANIM_ID(ob) (ob->temp_animation_id ? ob->temp_animation_id : ob->animation_id)
00250
00251
00252
00253
00254
00255 #define NUM_ANIMATIONS(ob) (ob->temp_animation_id ? animations[ob->temp_animation_id].num_animations : animations[ob->animation_id].num_animations)
00256 #define NUM_FACINGS(ob) (ob->temp_animation_id ? animations[ob->temp_animation_id].facings : animations[ob->animation_id].facings)
00257
00258 extern short freearr_x[SIZEOFFREE], freearr_y[SIZEOFFREE];
00259 extern int maxfree[SIZEOFFREE], freedir[SIZEOFFREE];
00260 extern int rightof_x[9], rightof_y[9];
00261 extern int leftof_x[9], leftof_y[9];
00262
00263 extern New_Face *blank_face, *empty_face;
00264 extern New_Face *smooth_face;
00265
00266 extern uint32 max_time;
00267 extern socket_struct *init_sockets;
00268
00269 #ifndef __CEXTRACT__
00270 #include "stringbuffer.h"
00271 #include "libproto.h"
00272 #include "sockproto.h"
00273 #include "typesproto.h"
00274 #endif
00275
00276 #define decrease_ob(xyz) decrease_ob_nr(xyz, 1)
00277
00278
00279
00280
00281
00282 #define FREE_AND_CLEAR(xyz) { free((void *)xyz); xyz = NULL; }
00283 #define FREE_AND_CLEAR_STR(xyz) { free_string(xyz); xyz = NULL; }
00284
00285
00286
00287
00288 #define FREE_AND_COPY(sv, nv) { if (sv) free_string(sv); sv = add_string(nv); }
00289
00290 #ifdef CALLOC
00291 #undef CALLOC
00292 #endif
00293
00294 #ifdef USE_CALLOC
00295 # define CALLOC(x, y) calloc(x, y)
00296 # define CFREE(x) free(x)
00297 #else
00298 # define CALLOC(x, y) malloc(x*y)
00299 # define CFREE(x) free(x)
00300 #endif
00301
00302 #ifndef WIN32
00303 #if HAVE_DIRENT_H
00304 # include <dirent.h>
00305 # define NAMLEN(dirent) strlen((dirent)->d_name)
00306 #else
00307 # define dirent direct
00308 # define NAMLEN(dirent) (dirnet)->d_namlen
00309 # if HAVE_SYS_NDIR_H
00310 # include <sys/ndir.h>
00311 # endif
00312 # if HAVE_SYS_DIR_H
00313 # include <sys/dir.h>
00314 # endif
00315 # if HAVE_NDIR_H
00316 # include <ndir.h>
00317 # endif
00318 #endif
00319 #endif
00320
00324 typedef struct Settings {
00325 const char *logfilename;
00326 uint16 csport;
00327 LogLevel debug;
00328 uint8 dumpvalues;
00329 const char *dumparg;
00330 uint8 daemonmode;
00331 int argc;
00332 char **argv;
00333 const char *confdir;
00334 const char *datadir;
00335 const char *localdir;
00336 const char *playerdir;
00337 const char *mapdir;
00338 const char *archetypes;
00339 const char *regions;
00340 const char *treasures;
00341 const char *uniquedir;
00342 const char *templatedir;
00343 const char *tmpdir;
00344 uint8 stat_loss_on_death;
00345 sint16 pk_luck_penalty;
00346 uint8 permanent_exp_ratio;
00347 uint8 death_penalty_ratio;
00348 uint8 death_penalty_level;
00349 uint8 balanced_stat_loss;
00350 uint8 not_permadeth;
00351 uint8 simple_exp;
00352 int reset_loc_time;
00353 uint8 set_title;
00354 uint8 resurrection;
00355 uint8 search_items;
00356 uint8 spell_encumbrance;
00357 uint8 spell_failure_effects;
00358 uint8 casting_time;
00359 uint8 real_wiz;
00360 uint8 recycle_tmp_maps;
00361 uint8 explore_mode;
00362 uint8 spellpoint_level_depend;
00363 uint16 set_friendly_fire;
00364 char who_format[MAX_BUF];
00365 char who_wiz_format[MAX_BUF];
00366 char motd[MAX_BUF];
00367 const char *rules;
00368 const char *news;
00369 char dm_mail[MAX_BUF];
00371
00372
00373
00374 unsigned int meta_on:1;
00375 char meta_server[MAX_BUF];
00376 char meta_host[MAX_BUF];
00377 uint16 meta_port;
00378 char meta_comment[MAX_BUF];
00380 uint32 worldmapstartx;
00381 uint32 worldmapstarty;
00382 uint32 worldmaptilesx;
00383 uint32 worldmaptilesy;
00384 uint32 worldmaptilesizex;
00385 uint32 worldmaptilesizey;
00386 uint8 fastclock;
00388 char *emergency_mapname;
00389 uint16 emergency_x, emergency_y;
00391 sint16 max_level;
00392 float item_power_factor;
00394 int armor_max_enchant;
00395 int armor_weight_reduction;
00396 uint8 armor_weight_linear;
00397 int armor_speed_improvement;
00398 uint8 armor_speed_linear;
00399 uint8 no_player_stealing;
00400 uint8 create_home_portals;
00401 uint8 personalized_blessings;
00402 sint64 pk_max_experience;
00403 int pk_max_experience_percent;
00404 int allow_denied_spells_writing;
00405 int allow_broken_converters;
00407 int log_timestamp;
00408 char *log_timestamp_format;
00409 } Settings;
00410
00411 extern Settings settings;
00412
00423 typedef struct Statistics {
00424 uint64 spell_merges;
00425 uint64 spell_hash_full;
00426 uint64 spell_suppressions;
00427 } Statistics;
00428
00429 extern Statistics statistics;
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439 #ifdef GETTIMEOFDAY_TWO_ARGS
00440 #define GETTIMEOFDAY(last_time) gettimeofday(last_time, (struct timezone *)NULL);
00441 #else
00442 #define GETTIMEOFDAY(last_time) gettimeofday(last_time);
00443 #endif
00444
00449 #define SCRIPT_FIX_ACTIVATOR 2
00450 #define SCRIPT_FIX_ALL 1
00451 #define SCRIPT_FIX_NOTHING 0
00452
00453 #include "plugin.h"
00454
00455 #endif