Crossfire Server, Branch 1.12
R12190
|
00001 /* 00002 * static char *rcsid_global_h = 00003 * "$Id: global.h 11578 2009-02-23 22:02:27Z lalo $"; 00004 */ 00005 00006 /* 00007 CrossFire, A Multiplayer game for X-windows 00008 00009 Copyright (C) 2006 Mark Wedel & Crossfire Development Team 00010 Copyright (C) 1992 Frank Tore Johansen 00011 00012 This program is free software; you can redistribute it and/or modify 00013 it under the terms of the GNU General Public License as published by 00014 the Free Software Foundation; either version 2 of the License, or 00015 (at your option) any later version. 00016 00017 This program is distributed in the hope that it will be useful, 00018 but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 GNU General Public License for more details. 00021 00022 You should have received a copy of the GNU General Public License 00023 along with this program; if not, write to the Free Software 00024 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00025 00026 The author can be reached via e-mail to crossfire-devel@real-time.com 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 /* Type defines for specific signed/unsigned variables of a certain number 00044 * of bits. Not really used anyplace, but if a certain number of bits 00045 * is required, these type defines should then be used. This will make 00046 * porting to systems that have different sized data types easier. 00047 * 00048 * Note: The type defines should just mean that the data type has at 00049 * least that many bits. if a uint16 is actually 32 bits, no big deal, 00050 * it is just a waste of space. 00051 * 00052 * Note2: When using something that is normally stored in a character 00053 * (ie strings), don't use the uint8/sint8 typdefs, use 'char' instead. 00054 * The signedness for char is probably not universal, and using char 00055 * will probably be more portable than sint8/unit8 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 /* Python plugin stuff defines SIZEOF_LONG_LONG as 8, and besides __int64 is a 64b type on MSVC... 00090 * So let's force the typedef */ 00091 typedef unsigned __int64 uint64; 00092 typedef signed __int64 sint64; 00093 /* Needed for experience */ 00094 #define atoll _atoi64 00095 00096 #define FMT64 "I64d" 00097 #define FMT64U "I64u" 00098 00099 /* To reduce number of warnings */ 00100 #pragma warning(disable: 4244) /* conversion from 'xxx' to 'yyy', possible loss of data */ 00101 #pragma warning(disable: 4305) /* initializing float f = 0.05; instead of f = 0.05f; */ 00102 00103 #else /* WIN32 */ 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 /* This blob, in this order, is needed to actually define maps */ 00126 #include "face.h" 00127 /* Include the basic defines from spells.h */ 00128 #include "attack.h" /* needs to be before material.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 /* Pull in the socket structure - used in the player structure */ 00138 #include "newserver.h" 00139 00140 /* Pull in the player structure */ 00141 #include "player.h" 00142 00143 /* pull in treasure structure */ 00144 #include "treasure.h" 00145 00146 #include "commands.h" 00147 00148 /* pull in book structures */ 00149 #include "book.h" 00150 00151 /* ob_methods and ob_types subsystem */ 00152 #include "ob_methods.h" 00153 #include "ob_types.h" 00154 00155 /* 00156 * So far only used when dealing with artifacts. 00157 * (now used by alchemy and other code too. Nov 95 b.t). 00158 */ 00159 typedef struct linked_char { 00160 const char *name; 00161 struct linked_char *next; 00162 } linked_char; 00163 00164 00165 /* Pull in artifacts */ 00166 #include "artifact.h" 00167 00168 /* Now for gods */ 00169 #include "god.h" 00170 00171 /* Now for races */ 00172 #include "race.h" 00173 00174 /* Now for recipe/alchemy */ 00175 #include "recipe.h" 00176 00177 /* Now for spells */ 00178 #include "spells.h" 00179 00180 /***************************************************************************** 00181 * GLOBAL VARIABLES: * 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 * Variables set by different flags (see init.c): 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 * Used in treasure.c 00237 */ 00238 EXTERN archetype *ring_arch, *amulet_arch, *staff_arch, *crown_arch; 00239 EXTERN const char *undead_name; /* Used in hit_player() in main.c */ 00240 00241 EXTERN Animations *animations; 00242 EXTERN int num_animations, animations_allocated, bmaps_checksum; 00243 00244 /* Rotate right from bsd sum. This is used in various places for checksumming */ 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 /* NUM_ANIMATIONS returns the number of animations allocated. The last 00251 * usuable animation will be NUM_ANIMATIONS-1 (for example, if an object 00252 * has 8 animations, NUM_ANIMATIONS will return 8, but the values will 00253 * range from 0 through 7. 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; /* loop 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 /* FREE_AND_CLEAR frees the pointer and then sets it to NULL. 00279 * This is generally done as a safety, and having this macro 00280 * makes the code a bit cleaner when doing so. 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 /* FREE_AND_COPY is for the shared string - it is handy enough 00286 * to use all over the place. 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 /* ---win32 we define this stuff in win32.h */ 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 /* The meta_ is information for the metaserver. These are set in 00372 * the lib/settings file. 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 /* 0.94.1 - change to GETTIMEOFDAY macro - SNI systems only one one option. 00432 * rather than have complex #ifdefs throughout the file, lets just figure 00433 * it out once, here at the top. 00434 * Have no idea if that is the right symbol to check on for NetBSD, 00435 * but NetBSD does use 2 params. 00436 * Move this to global.h from time.c since its also used in arch.c 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 /* GLOBAL_H */