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
00030 #ifndef GLOBAL_H
00031 #define GLOBAL_H
00032
00033 #ifndef EXTERN
00034 #define EXTERN extern
00035 #endif
00036
00037
00038 #ifndef __GNUC__
00039 # define __attribute__(x)
00040 #endif
00041
00042 #include "includes.h"
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00059 typedef unsigned int uint32;
00060 #ifndef UINT32_MAX
00061 # define UINT32_MAX (4294967295U)
00062 #endif
00063
00065 typedef signed int sint32;
00066 #define SINT32_MIN (-2147483647 - 1)
00067 #define SINT32_MAX 2147483647
00068
00070 typedef unsigned short uint16;
00071 #ifndef UINT16_MAX
00072 # define UINT16_MAX (65535U)
00073 #endif
00074
00076 typedef signed short sint16;
00077 #define SINT16_MIN (-32767 - 1)
00078 #define SINT16_MAX (32767)
00079
00081 typedef unsigned char uint8;
00082 #ifndef UINT8_MAX
00083 # define UINT8_MAX (255U)
00084 #endif
00085
00087 typedef signed char sint8;
00088 #define SINT8_MIN (-128)
00089 #define SINT8_MAX (127)
00090
00092 typedef unsigned short Fontindex;
00093
00095 typedef unsigned int tag_t;
00096
00098 typedef const char shstr;
00099
00100 #ifdef WIN32
00101
00102
00103 typedef unsigned __int64 uint64;
00104 typedef signed __int64 sint64;
00105 # define atoll _atoi64
00106
00107 # define FMT64 "I64d"
00108 # define FMT64U "I64u"
00109 # define FMT64HEX "I64x"
00110 #else
00111 # if SIZEOF_LONG == 8
00112 typedef unsigned long uint64;
00113 typedef signed long sint64;
00114 # define FMT64 "ld"
00115 # define FMT64U "lu"
00116 # define FMT64HEX "lx"
00117
00118 # elif SIZEOF_LONG_LONG == 8
00119 typedef unsigned long long uint64;
00120 typedef signed long long sint64;
00121 # define FMT64 "lld"
00122 # define FMT64U "llu"
00123 # define FMT64HEX "llx"
00124
00125 # else
00126 # error Do not know how to get a 64 bit value on this system.
00127 # error Correct and send email to the Atrinik Team on how to do this.
00128 # endif
00129 #endif
00130
00131 #ifndef UINT64_MAX
00132 # define UINT64_MAX (18446744073709551615LLU)
00133 #endif
00134
00135 #define SINT64_MIN (-9223372036854775807LL - 1)
00136 #define SINT64_MAX (9223372036854775807LL)
00137
00144 #define MONEYSTRING_NOTHING 0
00145
00146 #define MONEYSTRING_AMOUNT 1
00147
00148 #define MONEYSTRING_ALL -1
00149
00154 typedef struct _money_block
00155 {
00157 int mode;
00158
00160 sint64 mithril;
00161
00163 sint64 gold;
00164
00166 sint64 silver;
00167
00169 sint64 copper;
00170 } _money_block;
00171
00182 #define BANK_SYNTAX_ERROR -1
00183
00184 #define BANK_SUCCESS 0
00185
00187 #define BANK_WITHDRAW_HIGH 1
00188
00189 #define BANK_WITHDRAW_MISSING 2
00190
00191 #define BANK_WITHDRAW_OVERWEIGHT 3
00192
00194 #define BANK_DEPOSIT_COPPER 1
00195
00196 #define BANK_DEPOSIT_SILVER 2
00197
00198 #define BANK_DEPOSIT_GOLD 3
00199
00200 #define BANK_DEPOSIT_MITHRIL 4
00201
00203 #define POW2(x) ((x) * (x))
00204
00211 #define MAP_INFO_NORMAL 12
00212
00213 #define MAP_INFO_ALL 9999
00214
00225 #define FREE_AND_COPY_HASH(_sv_, _nv_) \
00226 { \
00227 if (_sv_) \
00228 { \
00229 free_string_shared(_sv_); \
00230 } \
00231 \
00232 _sv_ = add_string(_nv_); \
00233 }
00234
00238 #define FREE_AND_ADD_REF_HASH(_sv_, _nv_) \
00239 { \
00240 if (_sv_) \
00241 { \
00242 free_string_shared(_sv_); \
00243 } \
00244 \
00245 _sv_ = add_refcount(_nv_); \
00246 }
00247
00250 #define FREE_AND_CLEAR_HASH(_nv_) \
00251 { \
00252 if (_nv_) \
00253 { \
00254 free_string_shared(_nv_); \
00255 _nv_ = NULL; \
00256 } \
00257 }
00258
00261 #define FREE_ONLY_HASH(_nv_) \
00262 if (_nv_) \
00263 { \
00264 free_string_shared(_nv_); \
00265 }
00266
00269 #define ADD_REF_NOT_NULL_HASH(_nv_) \
00270 if (_nv_) \
00271 { \
00272 add_refcount(_nv_); \
00273 }
00274
00277 #define FREE_AND_CLEAR_HASH2(_nv_) \
00278 if (_nv_) \
00279 { \
00280 free_string_shared(_nv_); \
00281 _nv_ = NULL; \
00282 }
00283
00285 #define SPAWN_RANDOM_RANGE 10000
00286
00287 #define T_STYLE_UNSET (-2)
00288 #define ART_CHANCE_UNSET (-1)
00289
00291 #define MIN_MON_RADIUS 2
00292
00293 #define MAX_AGGRO_RANGE 9
00294
00295 #define MAX_AGGRO_TIME 12
00296
00303 #define SEND_FACE_OK 0
00304
00305 #define SEND_FACE_OUT_OF_BOUNDS 1
00306
00307 #define SEND_FACE_NO_DATA 2
00308
00311 #define TILED_MAPS 8
00312
00313 #define EXP_AGILITY 1
00314 #define EXP_MENTAL 2
00315 #define EXP_MAGICAL 3
00316 #define EXP_PERSONAL 4
00317 #define EXP_PHYSICAL 5
00318 #define EXP_WISDOM 6
00319
00320 #define MAX_EXP_CAT 7
00321
00323 #define EXP_NONE 0
00324
00326 #define MAXLEVEL 115
00327 extern uint64 new_levels[MAXLEVEL + 2];
00328
00331 typedef struct linked_char
00332 {
00334 shstr *name;
00335
00337 struct linked_char *next;
00338 } linked_char;
00339
00340 #include "face.h"
00341 #include "attack.h"
00342 #include "material.h"
00343 #include "living.h"
00344 #include "object.h"
00345 #include "arch.h"
00346 #include "map.h"
00347 #include "mempool.h"
00348 #include "tod.h"
00349 #include "pathfinder.h"
00350 #include "newserver.h"
00351 #include "skills.h"
00352 #include "player_shop.h"
00353 #include "party.h"
00354 #include "player.h"
00355 #include "treasure.h"
00356 #include "commands.h"
00357 #include "artifact.h"
00358 #include "god.h"
00359 #include "race.h"
00360 #include "sounds.h"
00361 #include "recipe.h"
00362 #include "spells.h"
00363 #include "stringbuffer.h"
00364
00369 #define special_potion(__op_sp) (__op_sp)->last_eat
00370
00371 extern int arch_cmp;
00372 extern int arch_search;
00373
00375 #define move_object(__op, __dir) move_ob(__op, __dir, __op)
00376
00377 #define is_magical(__op_) QUERY_FLAG(__op_, FLAG_IS_MAGICAL)
00378
00379 extern New_Face *new_faces;
00380
00385 player *first_player;
00387 mapstruct *first_map;
00389 treasurelist *first_treasurelist;
00391 artifactlist *first_artifactlist;
00393 godlink *first_god;
00397 player *last_player;
00398
00399 #define NROF_COMPRESS_METHODS 4
00400 EXTERN char *uncomp[NROF_COMPRESS_METHODS][3];
00401
00403 EXTERN long init_done;
00405 EXTERN long nroferrors;
00406
00408 extern long pticks;
00409
00411 EXTERN FILE *logfile;
00413 EXTERN long nroftreasures;
00415 EXTERN long nrofartifacts;
00417 EXTERN long nrofallowedstr;
00418
00419 extern object void_container;
00420
00422 EXTERN char first_map_path[MAX_BUF];
00426 EXTERN long ob_count;
00427
00429 EXTERN uint32 global_round_tag;
00430 #define ROUND_TAG global_round_tag
00431
00433 EXTERN int global_race_counter;
00434
00436 EXTERN struct timeval last_time;
00437 EXTERN Animations *animations;
00438 EXTERN int num_animations, animations_allocated;
00439
00441 #define STRING_SAFE(__string__) (__string__ ? __string__ : ">NULL<")
00442
00443 #define STRING_ARCH_NAME(__arch__) ((__arch__)->name ? (__arch__)->name : ">NULL<")
00444
00445 #define STRING_OBJ_NAME(__ob__) ((__ob__) && (__ob__)->name ? (__ob__)->name : ">NULL<")
00446
00447 #define STRING_OBJ_ARCH_NAME(__ob__) ((__ob__)->arch ? ((__ob__)->arch->name ? (__ob__)->arch->name : ">NULL<") : ">NULL<")
00448
00449 #define STRING_OBJ_SLAYING(__ob__) ((__ob__)->slaying ? (__ob__)->slaying : ">NULL<")
00450
00455 #define SET_ANIMATION(ob, newanim) ob->face = &new_faces[animations[ob->animation_id].faces[newanim]]
00456
00457 #define GET_ANIM_ID(ob) (ob->animation_id)
00458
00459 #define GET_INV_ANIM_ID(ob) (ob->inv_animation_id)
00460
00461 #define NUM_ANIMATIONS(ob) (animations[ob->animation_id].num_animations)
00462
00463 #define NUM_FACINGS(ob) (animations[ob->animation_id].facings)
00464
00465 extern int freearr_x[SIZEOFFREE], freearr_y[SIZEOFFREE];
00466 extern int maxfree[SIZEOFFREE], freedir[SIZEOFFREE];
00467
00468 extern New_Face *blank_face, *next_item_face, *prev_item_face;
00469
00470 extern long max_time;
00471 extern socket_struct *init_sockets;
00472 extern unsigned long todtick;
00473 extern int world_darkness;
00474
00476 EXTERN archetype *wp_archetype;
00478 EXTERN archetype *empty_archetype;
00480 EXTERN archetype *base_info_archetype;
00481 EXTERN archetype *level_up_arch;
00482
00484 #define FREE_AND_NULL_PTR(_xyz_) \
00485 { \
00486 if (_xyz_) \
00487 { \
00488 free(_xyz_); \
00489 } \
00490 \
00491 _xyz_ = NULL; \
00492 }
00493
00494 #ifdef CALLOC
00495 #undef CALLOC
00496 #endif
00497
00498 #ifdef USE_CALLOC
00499 # define CALLOC(x, y) calloc(x, y)
00500 # define CFREE(x) free(x)
00501 #else
00502 # define CALLOC(x, y) malloc(x * y)
00503 # define CFREE(x) free(x)
00504 #endif
00505
00507 typedef struct Settings
00508 {
00510 char *logfilename;
00511
00513 uint16 csport;
00514
00516 LogLevel debug;
00517
00519 uint8 dumpvalues;
00520
00522 char *dumparg;
00523
00525 uint8 daemonmode;
00526
00528 char *datadir;
00529
00531 char *localdir;
00532
00534 char *mapdir;
00535
00537 char *playerdir;
00538
00540 char *archetypes;
00541
00543 char *treasures;
00544
00546 char *uniquedir;
00547
00549 char *tmpdir;
00550
00552 uint8 stat_loss_on_death;
00553
00555 uint8 balanced_stat_loss;
00556
00558 unsigned int meta_on:1;
00559
00561 char meta_server[MAX_BUF];
00562
00564 char meta_host[MAX_BUF];
00565
00567 char meta_name[MAX_BUF];
00568
00570 char meta_comment[MAX_BUF];
00571
00573 uint8 watchdog;
00574
00576 uint8 interactive;
00577
00579 uint8 unit_tests;
00580
00582 float item_power_factor;
00583 } Settings;
00584
00585 extern Settings settings;
00586
00588 EXTERN struct shstr_constants
00589 {
00590 const char *none;
00591 const char *NONE;
00592 const char *home;
00593 const char *force;
00594 const char *portal_destination_name;
00595 const char *portal_active_name;
00596 const char *spell_quickslot;
00597
00598 const char *GUILD_FORCE;
00599 const char *guild_force;
00600 const char *RANK_FORCE;
00601 const char *rank_force;
00602 const char *ALIGNMENT_FORCE;
00603 const char *alignment_force;
00604
00605 const char *grace_limit;
00606 const char *restore_grace;
00607 const char *restore_hitpoints;
00608 const char *restore_spellpoints;
00609 const char *heal_spell;
00610 const char *remove_curse;
00611 const char *remove_damnation;
00612 const char *heal_depletion;
00613 const char *message;
00614 const char *enchant_weapon;
00615
00616 const char *player_info;
00617 const char *BANK_GENERAL;
00618
00619 const char *of_poison;
00620 const char *of_hideous_poison;
00621 } shstr_cons;
00622
00623 EXTERN void (*object_initializers[256])(object *);
00624
00626 typedef struct ban_struct
00627 {
00629 const char *name;
00630
00632 char *ip;
00633 } _ban_struct;
00634
00640 #define CACHE_FLAG_PYOBJ 1
00641
00642 #define CACHE_FLAG_AUTOFREE 2
00643
00644 #define CACHE_FLAG_GEVENT 4
00645
00648 typedef struct cache_struct
00649 {
00651 shstr *key;
00652
00654 void *ptr;
00655
00657 uint32 flags;
00658
00660 size_t id;
00661 } cache_struct;
00662
00663 #ifndef tolower
00664 # define tolower(C) (((C) >= 'A' && (C) <= 'Z') ? (C) - 'A' + 'a': (C))
00665 #endif
00666
00667 #ifdef GETTIMEOFDAY_TWO_ARGS
00668 # define GETTIMEOFDAY(last_time) gettimeofday(last_time, (struct timezone *) NULL);
00669 #else
00670 # define GETTIMEOFDAY(last_time) gettimeofday(last_time);
00671 #endif
00672
00678 #define SCRIPT_FIX_ACTIVATOR 2
00679
00680 #define SCRIPT_FIX_ALL 1
00681
00682 #define SCRIPT_FIX_NOTHING 0
00683
00685 #include "random_map.h"
00686 #include "proto.h"
00687 #include "plugin.h"
00688
00689 #endif