1 | /* |
|
|
2 | * static char *rcsid_global_h = |
|
|
3 | * "$Id: global.h,v 1.1 2006/02/03 07:12:49 root Exp $"; |
|
|
4 | */ |
|
|
5 | |
|
|
6 | /* |
1 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
8 | |
3 | |
9 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
10 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
33 | #define EXTERN extern |
28 | #define EXTERN extern |
34 | #endif |
29 | #endif |
35 | |
30 | |
36 | #include "includes.h" |
31 | #include "includes.h" |
37 | |
32 | |
38 | |
33 | typedef int8_t sint8; |
39 | /* Type defines for specific signed/unsigned variables of a certain number |
34 | typedef uint8_t uint8; |
40 | * of bits. Not really used anyplace, but if a certain number of bits |
35 | typedef int16_t sint16; |
41 | * is required, these type defines should then be used. This will make |
36 | typedef uint16_t uint16; |
42 | * porting to systems that have different sized data types easier. |
37 | typedef int32_t sint32; |
43 | * |
|
|
44 | * Note: The type defines should just mean that the data type has at |
|
|
45 | * least that many bits. if a uint16 is actually 32 bits, no big deal, |
|
|
46 | * it is just a waste of space. |
|
|
47 | * |
|
|
48 | * Note2: When using something that is normally stored in a character |
|
|
49 | * (ie strings), don't use the uint8/sint8 typdefs, use 'char' instead. |
|
|
50 | * The signedness for char is probably not universal, and using char |
|
|
51 | * will probably be more portable than sint8/unit8 |
|
|
52 | */ |
|
|
53 | |
|
|
54 | |
|
|
55 | typedef unsigned int uint32; |
38 | typedef uint32_t uint32; |
56 | |
39 | typedef int64_t sint64; |
57 | #ifndef UINT32_MAX |
40 | typedef uint64_t uint64; |
58 | #define UINT32_MAX 4294967295U |
|
|
59 | #endif |
|
|
60 | |
|
|
61 | typedef signed int sint32; |
|
|
62 | #define SINT32_MAX 2147483647 |
|
|
63 | |
|
|
64 | typedef unsigned short uint16; |
|
|
65 | #ifndef UINT16_MAX |
|
|
66 | #define UINT16_MAX 65535 |
|
|
67 | #endif |
|
|
68 | |
|
|
69 | typedef signed short sint16; |
|
|
70 | #define SINT16_MAX 32767 |
|
|
71 | |
|
|
72 | typedef unsigned char uint8; |
|
|
73 | #ifndef UINT8_MAX |
|
|
74 | #define UINT8_MAX 255 |
|
|
75 | #endif |
|
|
76 | |
|
|
77 | typedef signed char sint8; |
|
|
78 | #define SINT8_MAX 127 |
|
|
79 | |
|
|
80 | |
41 | |
81 | typedef unsigned short Fontindex; |
42 | typedef unsigned short Fontindex; |
82 | |
43 | |
83 | #ifdef WIN32 |
44 | #include <vector> |
84 | /* Python plugin stuff defines SIZEOF_LONG_LONG as 8, and besides __int64 is a 64b type on MSVC... |
|
|
85 | * So let's force the typedef */ |
|
|
86 | typedef unsigned __int64 uint64; |
|
|
87 | typedef signed __int64 sint64; |
|
|
88 | /* Needed for experience */ |
|
|
89 | #define atoll _atoi64 |
|
|
90 | |
45 | |
91 | /* To reduce number of warnings */ |
46 | #define ACC_CLASS(name) |
92 | #pragma warning( disable: 4244 ) /* conversion from 'xxx' to 'yyy', possible loss of data */ |
47 | #define ACC(meta,member) member |
93 | #pragma warning( disable: 4305 ) /* initializing float f = 0.05; instead of f = 0.05f; */ |
|
|
94 | |
48 | |
95 | #else /* WIN32 */ |
49 | #include "keyword.h" |
96 | |
50 | #include "traits.h" |
97 | #if SIZEOF_LONG == 8 |
51 | #include "dynbuf.h" |
98 | typedef unsigned long uint64; |
52 | #include "util.h" |
99 | typedef signed long sint64; |
53 | #include "shstr.h" |
100 | #elif SIZEOF_LONG_LONG == 8 |
|
|
101 | typedef unsigned long long uint64; |
|
|
102 | typedef signed long long sint64; |
|
|
103 | #else |
|
|
104 | #error do not know how to get a 64 bit value on this system. |
|
|
105 | #error correct and send mail to crossfire-devel on how to do this |
|
|
106 | #endif |
|
|
107 | |
|
|
108 | #endif |
|
|
109 | |
54 | |
110 | /* This blob, in this order, is needed to actually define maps */ |
55 | /* This blob, in this order, is needed to actually define maps */ |
111 | #include "face.h" |
56 | #include "face.h" |
112 | /* Include the basic defines from spells.h */ |
57 | /* Include the basic defines from spells.h */ |
113 | #include "attack.h" /* needs to be before material.h */ |
58 | #include "attack.h" /* needs to be before material.h */ |
… | |
… | |
134 | #include "book.h" |
79 | #include "book.h" |
135 | /* |
80 | /* |
136 | * So far only used when dealing with artifacts. |
81 | * So far only used when dealing with artifacts. |
137 | * (now used by alchemy and other code too. Nov 95 b.t). |
82 | * (now used by alchemy and other code too. Nov 95 b.t). |
138 | */ |
83 | */ |
139 | typedef struct linked_char { |
84 | struct linked_char |
140 | const char *name; |
85 | { |
|
|
86 | shstr name; |
141 | struct linked_char *next; |
87 | struct linked_char *next; |
142 | } linked_char; |
88 | }; |
143 | |
|
|
144 | |
89 | |
145 | /* Pull in artifacts */ |
90 | /* Pull in artifacts */ |
146 | #include "artifact.h" |
91 | #include "artifact.h" |
147 | |
92 | |
148 | /* Now for gods */ |
93 | /* Now for gods */ |
… | |
… | |
167 | |
112 | |
168 | /* |
113 | /* |
169 | * These are the beginnings of linked lists: |
114 | * These are the beginnings of linked lists: |
170 | */ |
115 | */ |
171 | EXTERN player *first_player; |
116 | EXTERN player *first_player; |
172 | EXTERN mapstruct *first_map; |
117 | EXTERN maptile *first_map; |
173 | EXTERN region *first_region; |
118 | EXTERN region *first_region; |
174 | EXTERN treasurelist *first_treasurelist; |
119 | EXTERN treasurelist *first_treasurelist; |
175 | EXTERN artifactlist *first_artifactlist; |
120 | EXTERN artifactlist *first_artifactlist; |
176 | EXTERN archetype *first_archetype; |
121 | EXTERN archetype *first_archetype; |
177 | EXTERN objectlink *first_friendly_object; /* Objects monsters will go after */ |
122 | EXTERN objectlink *first_friendly_object; /* Objects monsters will go after */ |
178 | EXTERN godlink *first_god; |
123 | EXTERN godlink *first_god; |
179 | EXTERN racelink *first_race; |
124 | EXTERN racelink *first_race; |
180 | |
125 | |
181 | #define NROF_COMPRESS_METHODS 4 |
|
|
182 | EXTERN char *uncomp[NROF_COMPRESS_METHODS][3]; |
|
|
183 | /* |
126 | /* |
184 | * The editor uses these (will get them out of here later): |
127 | * The editor uses these (will get them out of here later): |
185 | */ |
128 | */ |
186 | |
129 | |
187 | EXTERN long editor; /* if true, edit maps instead of playing (almost obsolete) */ |
130 | EXTERN long editor; /* if true, edit maps instead of playing (almost obsolete) */ |
… | |
… | |
189 | /* |
132 | /* |
190 | * Variables set by different flags (see init.c): |
133 | * Variables set by different flags (see init.c): |
191 | */ |
134 | */ |
192 | |
135 | |
193 | EXTERN long warn_archetypes; /* If true, write warnings when failing */ |
136 | EXTERN long warn_archetypes; /* If true, write warnings when failing */ |
194 | /* to find archetypes when loading from file */ |
137 | /* to find archetypes when loading from file */ |
195 | EXTERN long init_done; /* Ignores signals until init_done is true */ |
138 | EXTERN long init_done; /* Ignores signals until init_done is true */ |
196 | EXTERN long trying_emergency_save; /* True when emergency_save() is reached */ |
139 | EXTERN long trying_emergency_save; /* True when emergency_save() is reached */ |
197 | EXTERN long nroferrors; /* If it exceeds MAX_ERRORS, call fatal() */ |
140 | EXTERN long nroferrors; /* If it exceeds MAX_ERRORS, call fatal() */ |
198 | |
141 | |
199 | extern long pticks; /* used by various function to determine */ |
142 | extern long pticks; /* used by various function to determine */ |
200 | /* how often to save the character */ |
143 | /* how often to save the character */ |
201 | /* |
144 | /* |
202 | * Misc global variables: |
145 | * Misc global variables: |
203 | */ |
146 | */ |
204 | EXTERN FILE *logfile; /* Used by server/daemon.c */ |
147 | EXTERN FILE *logfile; /* Used by server/daemon.c */ |
205 | EXTERN int exiting; /* True if the game is about to exit */ |
148 | EXTERN int exiting; /* True if the game is about to exit */ |
… | |
… | |
208 | EXTERN long nrofallowedstr; /* Only used in malloc_info() */ |
151 | EXTERN long nrofallowedstr; /* Only used in malloc_info() */ |
209 | |
152 | |
210 | EXTERN archetype *empty_archetype; /* Nice to have fast access to it */ |
153 | EXTERN archetype *empty_archetype; /* Nice to have fast access to it */ |
211 | EXTERN archetype *map_archeytpe; |
154 | EXTERN archetype *map_archeytpe; |
212 | EXTERN char first_map_path[MAX_BUF]; /* The start-level */ |
155 | EXTERN char first_map_path[MAX_BUF]; /* The start-level */ |
|
|
156 | EXTERN char first_map_ext_path[MAX_BUF]; /* Path used for per-race start maps */ |
213 | |
157 | |
214 | EXTERN char errmsg[HUGE_BUF]; |
158 | EXTERN char errmsg[HUGE_BUF]; |
215 | EXTERN long ob_count; |
159 | EXTERN long ob_count; |
216 | /* |
160 | /* |
217 | * Used in treasure.c |
161 | * Used in treasure.c |
218 | */ |
162 | */ |
219 | EXTERN archetype *ring_arch,*amulet_arch,*staff_arch,*crown_arch; |
163 | EXTERN archetype *ring_arch,*amulet_arch,*staff_arch,*crown_arch; |
220 | EXTERN const char *undead_name; /* Used in hit_player() in main.c */ |
|
|
221 | |
164 | |
222 | EXTERN Animations *animations; |
165 | extern std::vector<Animations> animations; |
223 | EXTERN int num_animations,animations_allocated, bmaps_checksum; |
166 | EXTERN int num_animations,animations_allocated, bmaps_checksum; |
224 | |
167 | |
225 | /* Rotate right from bsd sum. This is used in various places for checksumming */ |
168 | /* Rotate right from bsd sum. This is used in various places for checksumming */ |
226 | #define ROTATE_RIGHT(c) if ((c) & 01) (c) = ((c) >>1) + 0x80000000; else (c) >>= 1; |
169 | #define ROTATE_RIGHT(c) if ((c) & 01) (c) = ((c) >>1) + 0x80000000; else (c) >>= 1; |
227 | |
170 | |
… | |
… | |
264 | /* FREE_AND_CLEAR frees the pointer and then sets it to NULL. |
207 | /* FREE_AND_CLEAR frees the pointer and then sets it to NULL. |
265 | * This is generally done as a safety, and having this macro |
208 | * This is generally done as a safety, and having this macro |
266 | * makes the code a bit cleaner when doing so. |
209 | * makes the code a bit cleaner when doing so. |
267 | */ |
210 | */ |
268 | #define FREE_AND_CLEAR(xyz) {free(xyz); xyz=NULL; } |
211 | #define FREE_AND_CLEAR(xyz) {free(xyz); xyz=NULL; } |
269 | #define FREE_AND_CLEAR_STR(xyz) {free_string(xyz); xyz=NULL; } |
|
|
270 | |
|
|
271 | /* FREE_AND_COPY is for the shared string - it is handy enough |
|
|
272 | * to use all over the place. |
|
|
273 | */ |
|
|
274 | #define FREE_AND_COPY(sv,nv) { if (sv) free_string(sv); sv=add_string(nv); } |
|
|
275 | |
|
|
276 | #define DELETE_STRING(__str_) free_string(__str_);__str_=NULL; |
|
|
277 | |
212 | |
278 | #ifdef CALLOC |
213 | #ifdef CALLOC |
279 | #undef CALLOC |
214 | #undef CALLOC |
280 | #endif |
215 | #endif |
281 | |
216 | |
… | |
… | |
285 | #else |
220 | #else |
286 | # define CALLOC(x,y) malloc(x*y) |
221 | # define CALLOC(x,y) malloc(x*y) |
287 | # define CFREE(x) free(x) |
222 | # define CFREE(x) free(x) |
288 | #endif |
223 | #endif |
289 | |
224 | |
290 | #ifndef WIN32 /* ---win32 we define this stuff in win32.h */ |
|
|
291 | #if HAVE_DIRENT_H |
225 | #if HAVE_DIRENT_H |
292 | # include <dirent.h> |
226 | # include <dirent.h> |
293 | # define NAMLEN(dirent) strlen((dirent)->d_name) |
227 | # define NAMLEN(dirent) strlen((dirent)->d_name) |
294 | #else |
228 | #else |
295 | # define dirent direct |
229 | # define dirent direct |
… | |
… | |
301 | # include <sys/dir.h> |
235 | # include <sys/dir.h> |
302 | # endif |
236 | # endif |
303 | # if HAVE_NDIR_H |
237 | # if HAVE_NDIR_H |
304 | # include <ndir.h> |
238 | # include <ndir.h> |
305 | # endif |
239 | # endif |
306 | #endif |
|
|
307 | #endif |
240 | #endif |
308 | |
241 | |
309 | typedef struct Settings { |
242 | typedef struct Settings { |
310 | char *logfilename; /* logfile to use */ |
243 | char *logfilename; /* logfile to use */ |
311 | uint16 csport; /* port for new client/server */ |
244 | uint16 csport; /* port for new client/server */ |
… | |
… | |
326 | char *uniquedir; /* directory for the unique items */ |
259 | char *uniquedir; /* directory for the unique items */ |
327 | char *templatedir; /* directory for the template map */ |
260 | char *templatedir; /* directory for the template map */ |
328 | char *tmpdir; /* Directory to use for temporary files */ |
261 | char *tmpdir; /* Directory to use for temporary files */ |
329 | uint8 stat_loss_on_death; /* If true, chars lose a random stat when they die */ |
262 | uint8 stat_loss_on_death; /* If true, chars lose a random stat when they die */ |
330 | sint16 pk_luck_penalty; /* Amount by which player luck is reduced if they PK */ |
263 | sint16 pk_luck_penalty; /* Amount by which player luck is reduced if they PK */ |
331 | uint8 use_permanent_experience; /* If true, players can gain perm exp */ |
264 | uint8 permanent_exp_ratio; /* how much exp should be 'permenant' and unable to be lost*/ |
|
|
265 | uint8 death_penalty_ratio; /* how much exp should be lost at death */ |
|
|
266 | uint8 death_penalty_level; /* how many levels worth of exp may be lost on one death */ |
332 | uint8 balanced_stat_loss; /* If true, Death stat depletion based on level etc */ |
267 | uint8 balanced_stat_loss; /* If true, Death stat depletion based on level etc */ |
333 | uint8 not_permadeth; /* if true, death is non-permament */ |
268 | uint8 not_permadeth; /* if true, death is non-permament */ |
334 | uint8 simple_exp; /* If true, use the simple experience system */ |
269 | uint8 simple_exp; /* If true, use the simple experience system */ |
335 | int reset_loc_time; /* Number of seconds to put player back at home */ |
270 | int reset_loc_time; /* Number of seconds to put player back at home */ |
336 | uint8 set_title; /* players can set thier title */ |
271 | uint8 set_title; /* players can set thier title */ |
337 | uint8 resurrection; /* ressurection possible w/ permadeth on */ |
272 | uint8 resurrection; /* ressurection possible w/ permadeth on */ |
338 | uint8 search_items; /* search_items command */ |
273 | uint8 search_items; /* search_items command */ |
339 | uint8 spell_encumbrance; /* encumbrance effects spells */ |
274 | uint8 spell_encumbrance; /* encumbrance effects spells */ |
340 | uint8 spell_failure_effects; /* nasty backlash to spell failures */ |
275 | uint8 spell_failure_effects; /* nasty backlash to spell failures */ |
341 | uint16 set_friendly_fire; /* Percent of damage done by peaceful player vs player damage */ |
276 | uint16 set_friendly_fire; /* Percent of damage done by peaceful player vs player damage */ |
342 | uint8 casting_time; /* it takes awhile to cast a spell */ |
277 | uint8 casting_time; /* it takes awhile to cast a spell */ |
343 | uint8 real_wiz; /* use mud-like wizards */ |
278 | uint8 real_wiz; /* use mud-like wizards */ |
344 | uint8 recycle_tmp_maps; /* re-use tmp maps. */ |
279 | uint8 recycle_tmp_maps; /* re-use tmp maps. */ |
345 | uint8 explore_mode; /* explore mode allowed? */ |
280 | uint8 explore_mode; /* explore mode allowed? */ |
346 | uint8 spellpoint_level_depend; /* spell costs go up with level */ |
281 | uint8 spellpoint_level_depend; /* spell costs go up with level */ |
… | |
… | |
379 | int armor_weight_reduction; /* Weight reduction per enchantment */ |
314 | int armor_weight_reduction; /* Weight reduction per enchantment */ |
380 | uint8 armor_weight_linear; /* If 1, weight reduction is linear, else exponantiel */ |
315 | uint8 armor_weight_linear; /* If 1, weight reduction is linear, else exponantiel */ |
381 | int armor_speed_improvement; /* Speed improvement */ |
316 | int armor_speed_improvement; /* Speed improvement */ |
382 | uint8 armor_speed_linear; /* If 1, speed improvement is linear, else exponantiel */ |
317 | uint8 armor_speed_linear; /* If 1, speed improvement is linear, else exponantiel */ |
383 | uint8 no_player_stealing; /* If 1, can not steal from other players */ |
318 | uint8 no_player_stealing; /* If 1, can not steal from other players */ |
|
|
319 | uint8 create_home_portals; /* If 1, can create portals in personal maps */ |
384 | } Settings; |
320 | } Settings; |
385 | |
321 | |
386 | extern Settings settings; |
322 | extern Settings settings; |
387 | |
323 | |
388 | /* 0.94.1 - change to GETTIMEOFDAY macro - SNI systems only one one option. |
324 | /* 0.94.1 - change to GETTIMEOFDAY macro - SNI systems only one one option. |
… | |
… | |
397 | #define GETTIMEOFDAY(last_time) gettimeofday(last_time, (struct timezone *) NULL); |
333 | #define GETTIMEOFDAY(last_time) gettimeofday(last_time, (struct timezone *) NULL); |
398 | #else |
334 | #else |
399 | #define GETTIMEOFDAY(last_time) gettimeofday(last_time); |
335 | #define GETTIMEOFDAY(last_time) gettimeofday(last_time); |
400 | #endif |
336 | #endif |
401 | |
337 | |
402 | /* GROS: Those are used by plugin events (argument fixthem) */ |
|
|
403 | #define SCRIPT_FIX_ACTIVATOR 2 |
|
|
404 | #define SCRIPT_FIX_ALL 1 |
|
|
405 | #define SCRIPT_FIX_NOTHING 0 |
|
|
406 | |
|
|
407 | #include "plugin.h" |
338 | #include "plugin.h" |
|
|
339 | #include "cfperl.h" |
|
|
340 | |
|
|
341 | //TODO: various TEMPORARY link guards to avoid doing the wrong thing |
|
|
342 | void free (object *); |
|
|
343 | void free (archetype *); |
|
|
344 | void free (recipe *); |
|
|
345 | void free (linked_char *); |
|
|
346 | void free (godlink *); |
|
|
347 | void free (objectlink *); |
|
|
348 | void free (oblinkpt *); |
|
|
349 | void free (maptile *); |
|
|
350 | void free (key_value *); |
|
|
351 | void free (treasure *); |
|
|
352 | void free (materialtype_t *); |
|
|
353 | void free (player *); |
|
|
354 | void free (New_Face *); |
|
|
355 | void free (racelink *); |
408 | |
356 | |
409 | #endif /* GLOBAL_H */ |
357 | #endif /* GLOBAL_H */ |
|
|
358 | |