Atrinik Server  4.0
global.h
Go to the documentation of this file.
1 /*************************************************************************
2  * Atrinik, a Multiplayer Online Role Playing Game *
3  * *
4  * Copyright (C) 2009-2014 Alex Tokar and Atrinik Development Team *
5  * *
6  * Fork from Crossfire (Multiplayer game for X-windows). *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the Free Software *
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
21  * *
22  * The author can be reached at admin@atrinik.org *
23  ************************************************************************/
24 
30 #ifndef GLOBAL_H
31 #define GLOBAL_H
32 
33 #include "includes.h"
34 #include <toolkit/shstr.h>
35 #include <toolkit/memory.h>
36 #include <toolkit/stringbuffer.h>
37 #include <toolkit/socket.h>
38 #include <toolkit/mempool.h>
39 
50 #define BANK_SYNTAX_ERROR -1
51 
52 #define BANK_SUCCESS 0
53 
55 #define BANK_WITHDRAW_HIGH 1
56 
57 #define BANK_WITHDRAW_MISSING 2
58 
59 #define BANK_WITHDRAW_OVERWEIGHT 3
60 
62 #define BANK_DEPOSIT_COPPER 1
63 
64 #define BANK_DEPOSIT_SILVER 2
65 
66 #define BANK_DEPOSIT_GOLD 3
67 
68 #define BANK_DEPOSIT_JADE 4
69 
70 #define BANK_DEPOSIT_MITHRIL 4
71 
72 #define BANK_DEPOSIT_AMBER 4
73 
75 #define POW2(x) ((x) * (x))
76 
83 #define MAP_INFO_NORMAL 12
84 
85 #define MAP_INFO_ALL 9999
86 
100 #define FREE_AND_COPY_HASH(_sv_, _nv_) \
101  { \
102  if (_sv_) \
103  { \
104  free_string_shared(_sv_); \
105  } \
106  \
107  _sv_ = add_string(_nv_); \
108  }
109 
116 #define FREE_AND_ADD_REF_HASH(_sv_, _nv_) \
117  { \
118  if (_sv_) \
119  { \
120  free_string_shared(_sv_); \
121  } \
122  \
123  _sv_ = add_refcount(_nv_); \
124  }
125 
130 #define FREE_AND_CLEAR_HASH(_nv_) \
131  { \
132  if (_nv_) \
133  { \
134  free_string_shared(_nv_); \
135  _nv_ = NULL; \
136  } \
137  }
138 
143 #define FREE_ONLY_HASH(_nv_) \
144  if (_nv_) \
145  { \
146  free_string_shared(_nv_); \
147  }
148 
153 #define ADD_REF_NOT_NULL_HASH(_nv_) \
154  if (_nv_) \
155  { \
156  add_refcount(_nv_); \
157  }
158 
162 #define FREE_AND_CLEAR_HASH2(_nv_) \
163  if (_nv_) \
164  { \
165  free_string_shared(_nv_); \
166  _nv_ = NULL; \
167  }
168 
170 #define SPAWN_RANDOM_RANGE 10000
171 
172 typedef shstr treasure_affinity_t;
173 #define TREASURE_ARTIFACT_CHANCE -1
174 
175 
176 #define MIN_MON_RADIUS 2
177 
178 #define MAX_AGGRO_RANGE 9
179 
180 #define MAX_AGGRO_TIME 12
181 
187 #define TILED_NORTH 0
188 
189 #define TILED_EAST 1
190 
191 #define TILED_SOUTH 2
192 
193 #define TILED_WEST 3
194 
195 #define TILED_NORTHEAST 4
196 
197 #define TILED_SOUTHEAST 5
198 
199 #define TILED_SOUTHWEST 6
200 
201 #define TILED_NORTHWEST 7
202 
203 #define TILED_UP 8
204 
205 #define TILED_DOWN 9
206 
208 #define TILED_NUM 10
209 
210 #define TILED_NUM_DIR 8
211 
213 #define EXP_AGILITY 1
214 #define EXP_MENTAL 2
215 #define EXP_MAGICAL 3
216 #define EXP_PERSONAL 4
217 #define EXP_PHYSICAL 5
218 #define EXP_WISDOM 6
219 
221 #define MAXLEVEL 115
222 
224 #define MAX_EXPERIENCE new_levels[MAXLEVEL]
225 
229 typedef struct linked_char {
231  shstr *name;
232 
234  struct linked_char *next;
235 } linked_char;
236 
237 #include <face.h>
238 #include <material.h>
239 #include <living.h>
240 #include <map.h>
241 #include <tod.h>
242 #include <pathfinder.h>
243 #include <newserver.h>
244 #include <skills.h>
245 #include <party.h>
246 #include <treasure.h>
247 #include <commands.h>
248 #include <race.h>
249 #include <recipe.h>
250 #include <spells.h>
251 
253 #define move_object(__op, __dir) move_ob(__op, __dir, __op)
254 
255 #define is_magical(__op_) QUERY_FLAG(__op_, FLAG_IS_MAGICAL)
256 
257 #define NROF_COMPRESS_METHODS 4
258 
260 #define STRING_SAFE(__string__) (__string__ ? __string__ : ">NULL<")
261 
262 #define STRING_ARCH_NAME(__arch__) ((__arch__)->name ? (__arch__)->name : ">NULL<")
263 
264 #define STRING_OBJ_NAME(__ob__) ((__ob__) && (__ob__)->name ? (__ob__)->name : ">NULL<")
265 
268 #define STRING_OBJ_ARCH_NAME(__ob__) ((__ob__)->arch ? ((__ob__)->arch->name ? (__ob__)->arch->name : ">NULL<") : ">NULL<")
269 
273 #define STRING_OBJ_SLAYING(__ob__) ((__ob__)->slaying ? (__ob__)->slaying : ">NULL<")
274 
282 #define SET_ANIMATION(ob, newanim) (ob)->face = &new_faces[animations[(ob)->animation_id].faces[(newanim)]]
283 
287 #define SET_ANIMATION_STATE(ob) \
288  if ((ob)->animation_id && NUM_FACINGS((ob)) && (QUERY_FLAG((ob), FLAG_IS_TURNABLE) || QUERY_FLAG((ob), FLAG_ANIMATE))) \
289  { \
290  SET_ANIMATION((ob), (NUM_ANIMATIONS((ob)) / NUM_FACINGS((ob))) * (QUERY_FLAG((ob), FLAG_IS_TURNABLE) ? (ob)->direction : 0) + (ob)->state); \
291  object_update((ob), UP_OBJ_FACE); \
292  }
293 
294 #define GET_ANIM_ID(ob) (ob->animation_id)
295 
296 #define GET_INV_ANIM_ID(ob) (ob->inv_animation_id)
297 
298 #define NUM_ANIMATIONS(ob) (animations[ob->animation_id].num_animations)
299 
300 #define NUM_FACINGS(ob) (animations[ob->animation_id].facings)
301 
303 #define FREE_AND_NULL_PTR(_xyz_) \
304  { \
305  if (_xyz_) \
306  { \
307  efree(_xyz_); \
308  } \
309  \
310  _xyz_ = NULL; \
311  }
312 
313 enum {
314  ALLOWED_CHARS_ACCOUNT,
315  ALLOWED_CHARS_CHARNAME,
316  ALLOWED_CHARS_PASSWORD,
317 
318  ALLOWED_CHARS_NUM
319 };
320 
324 typedef struct settings_struct {
328  uint16_t port;
329 
333  uint16_t port_crypto;
334 
338  char libpath[MAX_BUF];
339 
343  char datapath[MAX_BUF];
344 
348  char mapspath[MAX_BUF];
349 
353  char httppath[MAX_BUF];
354 
358  char resourcespath[MAX_BUF];
359 
363  char metaserver_url[MAX_BUF];
364 
368  char server_host[MAX_BUF];
369 
373  char server_name[MAX_BUF];
374 
378  char server_desc[MAX_BUF];
379 
383  uint8_t world_maker;
384 
389 
394 
399 
403  char plugin_unit_test[MAX_BUF];
404 
409 
414 
419 
425 
429  char allowed_chars[ALLOWED_CHARS_NUM][MAX_BUF];
430 
434  size_t limits[ALLOWED_CHARS_NUM][2];
435 
439  char control_allowed_ips[HUGE_BUF];
440 
444  char control_player[MAX_BUF];
445 
450 
454  bool http_server:1;
455 
459  char http_url[MAX_BUF];
460 
464  char network_stack[MAX_BUF];
465 
469  char *server_cert;
470 
476 
478 typedef struct shstr_constants {
479  const char *none;
480  const char *NONE;
481  const char *home;
482  const char *force;
483  const char *portal_destination_name;
484  const char *portal_active_name;
485 
486  const char *player_info;
487  const char *BANK_GENERAL;
488 
489  const char *of_poison;
490  const char *of_hideous_poison;
491  const char *of_vile_poison;
493 
499 #define CACHE_FLAG_PYOBJ 1
500 
501 #define CACHE_FLAG_AUTOFREE 2
502 
503 #define CACHE_FLAG_GEVENT 4
504 
507 typedef struct cache_struct {
509  shstr *key;
510 
512  void *ptr;
513 
515  uint32_t flags;
516 
518  size_t id;
519 } cache_struct;
520 
521 #ifndef tolower
522 #define tolower(C) (((C) >= 'A' && (C) <= 'Z') ? (C) - 'A' + 'a' : (C))
523 #endif
524 
525 #define MAX_TICKS (1000000.0 / max_time)
526 #define MAX_TICKS_MULTIPLIER (MAX_TICKS * max_time_multiplier)
527 
528 #ifdef HAVE_WORLD_MAKER
529 void world_maker(void);
530 #endif
531 
532 #include "random_map.h"
533 
534 /* TODO: Remove from here eventually */
535 struct packet_struct;
536 
537 #ifndef GLOBAL_NO_PROTOTYPES
538 #include "proto.h"
539 #endif
540 
541 #endif
struct shstr_constants shstr_constants
char datapath[MAX_BUF]
Definition: global.h:343
char network_stack[MAX_BUF]
Definition: global.h:464
char metaserver_url[MAX_BUF]
Definition: global.h:363
bool unit_tests
Definition: global.h:388
uint8_t python_reload_modules
Definition: global.h:418
char httppath[MAX_BUF]
Definition: global.h:353
char http_url[MAX_BUF]
Definition: global.h:459
shstr * key
Definition: global.h:509
bool http_server
Definition: global.h:454
char * server_cert_sig
Definition: global.h:474
char default_permission_groups[MAX_BUF]
Definition: global.h:424
struct settings_struct settings_struct
bool plugin_unit_tests
Definition: global.h:393
shstr * name
Definition: global.h:231
int8_t magic_devices_level
Definition: global.h:408
void world_maker(void)
Definition: world_maker.c:490
char libpath[MAX_BUF]
Definition: global.h:338
size_t id
Definition: global.h:518
size_t limits[ALLOWED_CHARS_NUM][2]
Definition: global.h:434
char resourcespath[MAX_BUF]
Definition: global.h:358
uint32_t flags
Definition: global.h:515
uint16_t port_crypto
Definition: global.h:333
bool recycle_tmp_maps
Definition: global.h:449
uint16_t port
Definition: global.h:328
char server_host[MAX_BUF]
Definition: global.h:368
uint8_t world_maker
Definition: global.h:383
struct linked_char * next
Definition: global.h:234
char control_player[MAX_BUF]
Definition: global.h:444
char allowed_chars[ALLOWED_CHARS_NUM][MAX_BUF]
Definition: global.h:429
char * server_cert
Definition: global.h:469
char server_desc[MAX_BUF]
Definition: global.h:378
char mapspath[MAX_BUF]
Definition: global.h:348
void * ptr
Definition: global.h:512
char server_name[MAX_BUF]
Definition: global.h:373
char control_allowed_ips[HUGE_BUF]
Definition: global.h:439
struct linked_char linked_char
struct cache_struct cache_struct
double item_power_factor
Definition: global.h:413
char plugin_unit_test[MAX_BUF]
Definition: global.h:403
bool no_console
Definition: global.h:398