--- deliantra/server/include/global.h 2006/12/11 21:32:17 1.21 +++ deliantra/server/include/global.h 2007/02/15 18:10:33 1.44 @@ -1,25 +1,26 @@ /* - CrossFire, A Multiplayer game for X-windows - - Copyright (C) 2002 Mark Wedel & Crossfire Development Team - Copyright (C) 1992 Frank Tore Johansen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - The author can be reached via e-mail to crossfire-devel@real-time.com -*/ + * CrossFire, A Multiplayer game for X-windows + * + * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team + * Copyright (C) 2002 Mark Wedel & Crossfire Development Team + * Copyright (C) 1992 Frank Tore Johansen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * The author can be reached via e-mail to crossfire@schmorp.de + */ #ifndef GLOBAL_H #define GLOBAL_H @@ -30,21 +31,23 @@ #include "includes.h" -typedef int8_t sint8; -typedef uint8_t uint8; -typedef int16_t sint16; -typedef uint16_t uint16; -typedef int32_t sint32; -typedef uint32_t uint32; -typedef int64_t sint64; -typedef uint64_t uint64; +#include "config.h" +#include "define.h" +#include "logger.h" -typedef unsigned short Fontindex; +#ifndef TRUE +#define TRUE 1 +#endif -#include +#ifndef FALSE +#define FALSE 0 +#endif -#define ACC_CLASS(name) +// used only for tagging structure members so scripting languages +// can easily parse the include files. +#define INTERFACE_CLASS(name) #define ACC(meta,member) member +#define MTH #include "keyword.h" #include "traits.h" @@ -54,7 +57,9 @@ /* This blob, in this order, is needed to actually define maps */ #include "face.h" -/* Include the basic defines from spells.h */ + +#include "spells.h" + #include "attack.h" /* needs to be before material.h */ #include "material.h" #include "living.h" @@ -65,7 +70,8 @@ #include "skills.h" /* Pull in the socket structure - used in the player structure */ -#include "newserver.h" +#include "network.h" +#include "client.h" /* Pull in the player structure */ #include "player.h" @@ -99,23 +105,17 @@ /* Now for recipe/alchemy */ #include "recipe.h" -/* Now for spells */ -#include "spells.h" - #include "funcpoint.h" /***************************************************************************** * GLOBAL VARIABLES: * *****************************************************************************/ -extern New_Face *new_faces; +extern facetile *new_faces; /* * These are the beginnings of linked lists: */ -EXTERN player *first_player; -EXTERN maptile *first_map; -EXTERN region *first_region; EXTERN treasurelist *first_treasurelist; EXTERN artifactlist *first_artifactlist; EXTERN archetype *first_archetype; @@ -124,20 +124,13 @@ EXTERN racelink *first_race; /* - * The editor uses these (will get them out of here later): - */ - -EXTERN long editor; /* if true, edit maps instead of playing (almost obsolete) */ - -/* * Variables set by different flags (see init.c): */ -EXTERN long warn_archetypes; /* If true, write warnings when failing */ +EXTERN bool warn_archetypes; /* If true, write warnings when failing */ /* to find archetypes when loading from file */ -EXTERN long init_done; /* Ignores signals until init_done is true */ -EXTERN long trying_emergency_save; /* True when emergency_save() is reached */ -EXTERN long nroferrors; /* If it exceeds MAX_ERRORS, call fatal() */ +EXTERN bool init_done; /* Ignores signals until init_done is true */ +EXTERN bool in_cleanup; /* True when cleanup() is reached */ extern long pticks; /* used by various function to determine */ /* how often to save the character */ @@ -152,25 +145,22 @@ EXTERN archetype *empty_archetype; /* Nice to have fast access to it */ EXTERN archetype *map_archeytpe; -EXTERN char first_map_path[MAX_BUF]; /* The start-level */ -EXTERN char first_map_ext_path[MAX_BUF]; /* Path used for per-race start maps */ +EXTERN shstr first_map_path; /* The start-level */ +EXTERN shstr first_map_ext_path; /* Path used for per-race start maps */ EXTERN char errmsg[HUGE_BUF]; EXTERN long ob_count; /* * Used in treasure.c */ -EXTERN archetype *ring_arch,*amulet_arch,*staff_arch,*crown_arch; - -extern std::vector animations; -EXTERN int num_animations,animations_allocated, bmaps_checksum; +EXTERN archetype *ring_arch, *amulet_arch, *staff_arch, *crown_arch; -/* Rotate right from bsd sum. This is used in various places for checksumming */ -#define ROTATE_RIGHT(c) if ((c) & 01) (c) = ((c) >>1) + 0x80000000; else (c) >>= 1; +EXTERN std::vector animations; +EXTERN int num_animations, animations_allocated; +EXTERN uint32_t bmaps_checksum; - -#define SET_ANIMATION(ob,newanim) ob->face=&new_faces[animations[ob->animation_id].faces[newanim]] -#define GET_ANIMATION(ob,anim) (animations[ob->animation_id].faces[anim]) +#define SET_ANIMATION(ob,newanim) ob->face = new_faces + animations [ob->animation_id].faces [newanim] +#define GET_ANIMATION(ob,anim) animations [ob->animation_id].faces [anim] #define GET_ANIM_ID(ob) (ob->animation_id) /* NUM_ANIMATIONS returns the number of animations allocated. The last * usuable animation will be NUM_ANIMATIONS-1 (for example, if an object @@ -185,174 +175,90 @@ extern int rightof_x[9], rightof_y[9]; extern int leftof_x[9], leftof_y[9]; -extern New_Face *blank_face, *empty_face; -extern New_Face *dark_faces[]; -extern New_Face *smooth_face; - +extern facetile *blank_face, *empty_face; +extern facetile *dark_faces[]; +extern facetile *smooth_face; -extern long max_time; /* loop time */ -extern NewSocket *init_sockets; +extern client *init_sockets; +extern void emergency_save (); +extern void cleanup (const char *cause, bool make_core = false); -EXTERN char *font_graphic; - -#ifndef __CEXTRACT__ #include "libproto.h" #include "sockproto.h" -#endif - #define decrease_ob(xyz) decrease_ob_nr(xyz,1) -/* FREE_AND_CLEAR frees the pointer and then sets it to NULL. - * This is generally done as a safety, and having this macro - * makes the code a bit cleaner when doing so. - */ -#define FREE_AND_CLEAR(xyz) {free(xyz); xyz=NULL; } - -#ifdef CALLOC -#undef CALLOC -#endif - -#ifdef USE_CALLOC -# define CALLOC(x,y) calloc(x,y) -# define CFREE(x) free(x) -#else -# define CALLOC(x,y) malloc(x*y) -# define CFREE(x) free(x) -#endif - -#if HAVE_DIRENT_H -# include -# define NAMLEN(dirent) strlen((dirent)->d_name) -#else -# define dirent direct -# define NAMLEN(dirent) (dirnet)->d_namlen -# if HAVE_SYS_NDIR_H -# include -# endif -# if HAVE_SYS_DIR_H -# include -# endif -# if HAVE_NDIR_H -# include -# endif -#endif - -typedef struct Settings { - char *logfilename; /* logfile to use */ - uint16 csport; /* port for new client/server */ - LogLevel debug; /* Default debugging level */ - uint8 dumpvalues; /* Set to dump various values/tables */ - char *dumparg; /* additional argument for some dump functions */ - uint8 daemonmode; /* If true, detach and become daemon */ - int argc; /* parameters that were passed to the program */ - char **argv; /* Only used by xio.c, so will go away at some time */ - char *confdir; /* configuration files */ - char *datadir; /* read only data files */ - char *localdir; /* read/write data files */ - char *playerdir; /* Where the player files are */ - char *mapdir; /* Where the map files are */ - char *archetypes; /* name of the archetypes file - libdir is prepended */ - char *regions; /* name of the regions file - libdir is prepended */ - char *treasures; /* location of the treasures file. */ - char *uniquedir; /* directory for the unique items */ - char *templatedir; /* directory for the template map */ - char *tmpdir; /* Directory to use for temporary files */ - uint8 stat_loss_on_death; /* If true, chars lose a random stat when they die */ - sint16 pk_luck_penalty; /* Amount by which player luck is reduced if they PK */ - uint8 permanent_exp_ratio; /* how much exp should be 'permenant' and unable to be lost*/ - uint8 death_penalty_ratio; /* how much exp should be lost at death */ - uint8 death_penalty_level; /* how many levels worth of exp may be lost on one death */ - uint8 balanced_stat_loss; /* If true, Death stat depletion based on level etc */ - uint8 not_permadeth; /* if true, death is non-permament */ - uint8 simple_exp; /* If true, use the simple experience system */ - int reset_loc_time; /* Number of seconds to put player back at home */ - uint8 set_title; /* players can set thier title */ - uint8 resurrection; /* ressurection possible w/ permadeth on */ - uint8 search_items; /* search_items command */ - uint8 spell_encumbrance; /* encumbrance effects spells */ - uint8 spell_failure_effects; /* nasty backlash to spell failures */ - uint16 set_friendly_fire; /* Percent of damage done by peaceful player vs player damage */ - uint8 casting_time; /* it takes awhile to cast a spell */ - uint8 real_wiz; /* use mud-like wizards */ - uint8 recycle_tmp_maps; /* re-use tmp maps. */ - uint8 explore_mode; /* explore mode allowed? */ - uint8 spellpoint_level_depend; /* spell costs go up with level */ - char who_format[MAX_BUF]; /* The format that the who command should use */ - char who_wiz_format[MAX_BUF]; /* The format that the who command should use when called by a dm*/ - char motd[MAX_BUF]; /* name of the motd file */ - char *rules; /* name of rules file*/ - char *news; /* name of news file*/ - char dm_mail[MAX_BUF]; /* DM's Email address */ - - /* The meta_ is information for the metaserver. These are set in - * the lib/settings file. - */ - uint8 meta_on:1; /* True if we should send updates */ - char meta_server[MAX_BUF]; /* Hostname/ip addr of the metaserver */ - char meta_host[MAX_BUF]; /* Hostname of this host */ - uint16 meta_port; /* Port number to use for updates */ - char meta_comment[MAX_BUF]; /* Comment we send to the metaserver */ - - uint32 worldmapstartx; /* starting x tile for the worldmap */ - uint32 worldmapstarty; /* starting y tile for the worldmap */ - uint32 worldmaptilesx; /* number of tiles wide the worldmap is */ - uint32 worldmaptilesy; /* number of tiles high the worldmap is */ - uint32 worldmaptilesizex; /* number of squares wide in a wm tile */ - uint32 worldmaptilesizey; /* number of squares high in a wm tile */ - uint16 dynamiclevel; /* how dynamic is the world? */ - uint8 fastclock; /* if true, clock goes warp 9 */ - - char *emergency_mapname; /* map to return players to in emergency */ - uint16 emergency_x, emergency_y; /* coordinates to use on that map */ - - sint16 max_level; /* This is read out of exp_table */ - float item_power_factor; /* See note in setings file */ - - int armor_max_enchant; /* Maximum number of times an armor can be enchanted */ - int armor_weight_reduction; /* Weight reduction per enchantment */ - uint8 armor_weight_linear; /* If 1, weight reduction is linear, else exponantiel */ - int armor_speed_improvement; /* Speed improvement */ - uint8 armor_speed_linear; /* If 1, speed improvement is linear, else exponantiel */ - uint8 no_player_stealing; /* If 1, can not steal from other players */ - uint8 create_home_portals; /* If 1, can create portals in personal maps */ -} Settings; +INTERFACE_CLASS (Settings) +struct Settings { + char *ACC (RO, logfilename); /* logfile to use */ + int ACC (RW, csport); /* port for new client/server */ + int ACC (RW, debug); /* Default debugging level */ + uint8 dumpvalues; /* Set to dump various values/tables */ + char *dumparg; /* additional argument for some dump functions */ + uint8 daemonmode; /* If true, detach and become daemon */ + int argc; /* parameters that were passed to the program */ + char **argv; /* Only used by xio.c, so will go away at some time */ + char *ACC (RO, confdir); /* configuration files */ + char *ACC (RO, datadir); /* read only data files */ + char *ACC (RO, localdir); /* read/write data files */ + char *ACC (RO, playerdir); /* Where the player files are */ + char *ACC (RO, mapdir); /* Where the map files are */ + char *ACC (RO, archetypes); /* name of the archetypes file - libdir is prepended */ + char *ACC (RO, regions); /* name of the regions file - libdir is prepended */ + char *ACC (RO, treasures); /* location of the treasures file. */ + char *ACC (RO, uniquedir); /* directory for the unique items */ + char *ACC (RO, templatedir); /* directory for the template map */ + char *ACC (RO, tmpdir); /* Directory to use for temporary files */ + sint16 ACC (RW, pk_luck_penalty); /* Amount by which player luck is reduced if they PK */ + uint8 ACC (RW, stat_loss_on_death); /* If true, chars lose a random stat when they die */ + uint8 ACC (RW, permanent_exp_ratio); /* how much exp should be 'permenant' and unable to be lost*/ + uint8 ACC (RW, death_penalty_ratio); /* how much exp should be lost at death */ + uint8 ACC (RW, death_penalty_level); /* how many levels worth of exp may be lost on one death */ + uint8 ACC (RW, balanced_stat_loss); /* If true, Death stat depletion based on level etc */ + uint8 ACC (RW, not_permadeth); /* if true, death is non-permament */ + uint8 ACC (RW, simple_exp); /* If true, use the simple experience system */ + int ACC (RW, reset_loc_time); /* Number of seconds to put player back at home */ + uint8 ACC (RW, set_title); /* players can set thier title */ + uint8 ACC (RW, resurrection); /* ressurection possible w/ permadeth on */ + uint8 ACC (RW, search_items); /* search_items command */ + uint8 ACC (RW, spell_encumbrance); /* encumbrance effects spells */ + uint8 ACC (RW, spell_failure_effects); /* nasty backlash to spell failures */ + uint16 ACC (RW, set_friendly_fire); /* Percent of damage done by peaceful player vs player damage */ + uint8 ACC (RW, casting_time); /* it takes awhile to cast a spell */ + uint8 ACC (RW, real_wiz); /* use mud-like wizards */ + uint8 dummy_000; + uint8 ACC (RW, spellpoint_level_depend); /* spell costs go up with level */ + char ACC (RW, motd)[MAX_BUF]; /* name of the motd file */ + char *ACC (RO, rules); /* name of rules file*/ + char *ACC (RO, news); /* name of news file*/ + char ACC (RW, dm_mail)[MAX_BUF]; /* DM's Email address */ + + uint32 ACC (RW, worldmapstartx); /* starting x tile for the worldmap */ + uint32 ACC (RW, worldmapstarty); /* starting y tile for the worldmap */ + uint32 ACC (RW, worldmaptilesx); /* number of tiles wide the worldmap is */ + uint32 ACC (RW, worldmaptilesy); /* number of tiles high the worldmap is */ + uint32 ACC (RW, worldmaptilesizex); /* number of squares wide in a wm tile */ + uint32 ACC (RW, worldmaptilesizey); /* number of squares high in a wm tile */ + uint16 ACC (RW, dynamiclevel); /* how dynamic is the world? */ + uint8 ACC (RW, fastclock); /* if true, clock goes warp 9 */ + + int ACC (RW, max_level); /* This is read out of exp_table */ + float ACC (RW, item_power_factor); /* See note in setings file */ + + int ACC (RW, armor_max_enchant); /* Maximum number of times an armor can be enchanted */ + int ACC (RW, armor_weight_reduction); /* Weight reduction per enchantment */ + int ACC (RW, armor_speed_improvement); /* Speed improvement */ + uint8 ACC (RW, armor_weight_linear); /* If 1, weight reduction is linear, else exponantiel */ + uint8 ACC (RW, armor_speed_linear); /* If 1, speed improvement is linear, else exponantiel */ + uint8 ACC (RW, no_player_stealing); /* If 1, can not steal from other players */ + uint8 ACC (RW, create_home_portals); /* If 1, can create portals in personal maps */ +}; extern Settings settings; -/* 0.94.1 - change to GETTIMEOFDAY macro - SNI systems only one one option. - * rather than have complex #ifdefs throughout the file, lets just figure - * it out once, here at the top. - * Have no idea if that is the right symbol to check on for NetBSD, - * but NetBSD does use 2 params. - * Move this to global.h from time.c since its also used in arch.c - */ - -#ifdef GETTIMEOFDAY_TWO_ARGS -#define GETTIMEOFDAY(last_time) gettimeofday(last_time, (struct timezone *) NULL); -#else -#define GETTIMEOFDAY(last_time) gettimeofday(last_time); -#endif - #include "plugin.h" #include "cfperl.h" -//TODO: various TEMPORARY link guards to avoid doing the wrong thing -void free (object *); -void free (archetype *); -void free (recipe *); -void free (linked_char *); -void free (godlink *); -void free (objectlink *); -void free (oblinkpt *); -void free (maptile *); -void free (key_value *); -void free (treasure *); -void free (materialtype_t *); -void free (player *); -void free (New_Face *); -void free (racelink *); - #endif /* GLOBAL_H */