cdirt/ascii/
cdirt/data/BULL/
cdirt/data/ZONES/PENDING/
cdirt/pending/
cdirt/src/utils/
cdirt/utils/
#include "mudtypes-extras.h"
#include "xrweather.h"
#include "store.h"

#ifndef _MUDTYPES_H
#define _MUDTYPES_H

typedef	LongInt	 LFLAGS;
typedef	LongInt  OFLAGS;
typedef	DLongInt PFLAGS;
typedef	LongInt  SFLAGS;
typedef	LongInt  EFLAGS;
typedef long int NFLAGS;
typedef	LongInt  MFLAGS;
typedef	long int QFLAGS;
typedef long int AFLAGS;

#define TITLE_LEN	300	/* Max. length of a players title */
#define PROMPT_LEN	60	/* Max. length of the prompt */
#define PNAME_LEN	13	/* Max. length of a player-name */
#define MNAME_LEN	16	/* Max length, mobile-name */
#define ONAME_LEN	32	/* Max length, object-name */
#define SETIN_MAX	80	/* Max length, travel-message */
#define TTY_LEN		64	/* Max length, name of players host */
#define MSG_LEN		240	/* Max length of a message */
#define PASSWD_LEN	16	/* Max chars of passwd + 1 */
#define MAX_COM_LEN	300	/* Max chars in a command line */

#define NUM_CONDS	6
#define NUM_ACTS	4

typedef struct _a_inp_h {
  struct _a_inp_h *next;
  void            (*inp_handler)(char *input_string);
} INP_HANDLER;

/* A condition as defined in database.c 
 */
typedef struct _CONDITION {
  short	cnd_code;
  short	cnd_data;
} CONDITION;

typedef short ACTION;

/* A line as defined in database.c 
 */
typedef struct _LINE {
  short		verb;
  short		item1;
  short		item2;
  CONDITION	conditions[NUM_CONDS];
  ACTION	actions[NUM_ACTS];
} LINE;

/* Pager Structure */
typedef struct _PAGER {
  FILE          *file;
  INP_HANDLER   *old_handler;
  char          prompt[PROMPT_LEN+40];
  int           len;
} PAGER;

/* Spell Duration Structure */
typedef struct _SPELL_DURATION {
  int		spell;
  int		duration;
  int		tmp;
  struct	_SPELL_DURATION	*next;
} SPELL_DURATION;

/* Zone table entry 
 */
typedef struct _ZONE {
  char	*z_name;		/* Zone name */

  int		maxlocs;
  int		maxmobs;
  int		maxobjs;

  int		latitude;
  int		rainfall;

  int_set	locations;
  int_set	mobiles;
  int_set	objects;
} ZONE;

/* Location data in the rooms arrray as read from locations file 
 */
typedef struct {
  int		r_exit[NEXITS];
  LFLAGS	r_flags;
  char 		*r_name;
  char		*r_short;
  char		*r_long;
  long int	id;
  int		r_altitude;	/* Altitude of room.  :) */
  int_set	objects;	/* Set of objects in this loc. */
  int_set	mobiles;	/* Set of players/mobiles in this loc. */
  int_set	exits_to_me;	/* Set of locations that have exits to this */
  Boolean	touched;	/* Has any exit been changed since last rst? */
  int		zone;		/* To which zone do we belong ? */

/* Reset data */
  long int	r_exit_reset[NEXITS];
  LFLAGS	r_flags_reset;
  int		r_altitude_reset;
} Location;

/* An object
 */
typedef struct {

/* Unalterable, no need to reset on a reset: */
  char		*oname;		/* objects name */
  char		*oaltname;	/* objects alternate name */
  char		*odesc[4];	/* descriptions for each state  */
  int		omaxstate;	/* max state a wiz can SET an obj to */
  long		oexamine;	/* ptr in file where examine text is found */
  char		*oexam_text;	/* ptr to exam-txt for in-game created objs */
  long int	id;		/* unique ID, needed for new saved objects */
  Boolean	temporary;	/* Part of a wizards permenent zone? */
  int		linked;		/* Which object, if any, is this linked to? */
  int		zone;		/* To which zone do we belong? */
  int		onum;		/* number for the code to test so that cloned
				   objects can behave like the originals. */
/* Alterable, needs saved reset values too: */
  int		ovalue;		/* base value */
  int		osize;
  int           oweight;
  int		oloc;
  int		ovis;		/* the objects visibility level */
  int		odamage;
  int		oarmor;
  int		ocarrf;
  int		ostate;
  OFLAGS	oflags;
  AFLAGS        aflags;

  long int	oloc_reset;
  int		osize_reset;
  int		ovalue_reset;
  int		ovis_reset;
  int		odamage_reset;
  int		oarmor_reset;
  int		ocarrf_reset;
  int		ostate_reset;
  int           oweight_reset;
  OFLAGS	oflags_reset;

  int_set	objects;	/* set of objects inside this object */
} Object;

/* A record describing a player or mobile in the world. */

typedef struct {
  SPELLS        pspells;
  time_t        death_time;     /* time the player/mobile died */
  int           angry;          /* who are we angry at? */
  Body          body;           /* the player/mobile's body */
  char		pname[MNAME_LEN+1];
  int		ploc;
  long int	phome;		/* players start-loc. and home */
  int		pdam;		/* Damage */
  int           pac;            /* total AC of items worn */
  int		parmor;
  int		pagg;		/* Agression */
  int		pspeed;		/* Speed */
  int		pstr;
  int		pvis;
  SFLAGS	psflags;
  PFLAGS	pflags;
  PFLAGS	pmask;
  MFLAGS	pmflags;
  int		plev;
  int		pweapon;
  int		psitting;
  int		phelping;
  int		pfighting;
  unsigned int	pscore;
  char		*pftxt;		/* Mobile's one-line description */
  char		*p_exam;	/* exam-text for mobs (may also be in DESC)*/
  int		pnum;		/* player/mobile number */
  int           planguage;      /* Language Selected */
  EFLAGS	peflags;	/* Spell Flags */
  NFLAGS        pnflags;        /* Mobile's language */
  int_set	objects;	/* set of objects carried by this character */
  long int	id;		/* Unique ID */
  Boolean       ftimer;         /* fighting timer */
  int		zone;		/* To which zone do we belong ? */
  int           class;          /* Class of player or mobile */

  int		pwimpy;

/* Reset data for mobiles: */

  char		*pname_reset;
  long int	ploc_reset;
  EFLAGS	peflags_reset;
  NFLAGS        pnflags_reset;
  int		pstr_reset;
  int		pvis_reset;
  SFLAGS	psflags_reset;
  PFLAGS	pflags_reset;
  MFLAGS	pmflags_reset;
  int		plev_reset;
  int		pagg_reset;	/* Agression */
  int		pspeed_reset;	/* Speed */
  int		pdam_reset;
  int		parmor_reset;
  int		pwimpy_reset;
} UBLOCK_REC;

typedef UBLOCK_REC Mobile;
typedef UBLOCK_REC Player;

/* stuff to preserve over a reboot */

typedef struct _reboot {
  int           aliasto;                       /* number of mobile aliased */
  int           replyplr;                      /* reply messages to        */
  Boolean       isawiz;                        /* wizard?                  */
  Boolean       ismonitored;                   /* monitored?               */
  Boolean       aliased;                       /* Are we aliased?          */
  Boolean       linkdead;		       /* Player has lost connect  */
  int           polymorphed;                   /* Polymorphed turns        */
  int           pretend;                       /* Who aliased or poly to   */
  int           i_follow;                      /* following plr or -1      */
  int           me_ivct;                       /* Invisible for #cmds       */
  int           phelping;                      /* Who are we helping?       */
  int           snooped;                       /* How many are snooping us? */
  int           snooptarget;                   /* Who are we snooping?    */
  int           rounds_in_room;                /* How long in room?       */
  int           pconverse;                     /* Player conversing with  */
  int           forget[10];                    /* Forget list             */
  int           storage[NUM_STORE_SLOTS];      /* storage system          */
  Boolean       newplr;                        /* Are we new?             */
  Boolean       logged;                        /* Are we logged?          */
  Boolean       needsquests;                   /* Needs quests to wiz     */
  int           oldscore;                      /* Log-in score            */
  time_t        last_cmd;                      /* "last" command          */
  time_t        rlast_cmd;                     /* Real last command       */
  time_t        logged_on;                     /* Time we logged on       */
  int           fil_des;                       /* File descriptor         */
  int           port;                          /* Port we are using       */
  char          os[20];                        /* OS of connecting mach   */
  char          keyb[20];                      /* Keyboard type of mach   */
  char          ip_addr[16];                   /* Numeric IP addy         */
  char          hostname[100];                 /* Alphanumeric hostname   */
  char          usrname[200];                  /* Username@Host  (ident)  */
  char          prev_com[MAX_COM_LEN];         /* last command            */
  char          wd_her[MNAME_LEN+1];           /* Her-->plr               */ 
  char          wd_him[MNAME_LEN+1];           /* Him-->plr               */
  char          wd_it[ONAME_LEN+1];            /* It -->item              */

/* things which are copied from other structures before reboot */

  int           plx;                           /* player's number         */
  int           ploc;                          /* players location        */
  int           pvis;                          /* players visibility      */
  int           grouped;
  int           pweapon;                       /* player's weapon         */
  char          pname[MNAME_LEN+1];            /* player's name           */
  char          *atarget;                      /* aberchat reply target   */
  char          *amud;                         /* aberchat reply mud      */
} RPLR_REC;

typedef struct _iorec {
  INP_HANDLER   *inp_handler;                  /* Func to pass input to   */
  char          inp_buffer[MAX_COM_LEN];       /* Read buffer             */
  Boolean       output;                        /* have output?            */
  size_t        out_size;                      /* size of the output buffer */
  char          *inp_ptr;                      /* player's position in inbuf */
  Boolean       ignore_input;                  /* status of input buffer    */
  unsigned char *out_buffer;                   /* this player's output buff */
  unsigned char *out_write;                    /* current writepos /outbuf  */
  unsigned char *out_read;                     /* current readpos /outbuf   */
} IO_REC;

/* Player data that are not shared by mobiles. */

typedef struct _a_player {
  Boolean       is_conn;                       /* Player is connected      */
  Boolean       iamon;                         /* Am I on? Init to false.  */
  Boolean       ident;                         /* received ident username  */
  Boolean       resolved;                      /* received DNS hostname    */
  Boolean       hasquit;                       /* End this connection?     */
  void          (*old_inp_handler)(char *str); /* old input handler for mail */
  void          (*edit_inp_handler)(char *str);/* old input handler for edit */
  char          edit_outfile[256];             /* where the edit output goes */
  int           edit_mode;                     /* the mode for output file */
  int           edit_lines;                    /* number of lines in buffer */
  int           edit_status;                   /* status of editor        */
  int           edit_curr_line;                /* current line in editor  */
  char          edit_prompt[64];               /* editor prompt           */
  int           resfd;                         /* FD for resolver         */
  int           respos;                        /* Position for resolv snd */
  int           dnsfd;                         /* FD for DNS lookup       */
  int           dnspos;                        /* Position for dns snd    */
  Boolean       limbo;                         /* Plr is resolving/dnsing */
  int           pcarry;                        /* Carrying capacity       */
  char          *awaymsg;		       /* Your away message       */
  time_t        mortal_time;                   /* Time alive as mortal    */
  time_t        wiz_time;                      /* Time alive as wizard    */
  time_t        first_on;                      /* first connect           */
  time_t        time_on;                       /* On for how long?        */
  Boolean       in_cmd;                        /* are we execing a mud-cmd? */
  Boolean       cast_spell;                    /* cast a spell this round? */
  int           challenger;                    /* who will be fighting us */
  Boolean       inmailer;                      /* In mailer?              */
  int           coins;                         /* coin system             */
  int           crawl;                         /* Crawl timer             */
  void		*writer;	               /* Current writer          */
  int		no_logins;	               /* No. of failed passwd    */
  int		work;		               /* General work integer    */
  Text_Ptr      txt_curr;                      /* current position in editor */
  Text_Ptr      txt_start;                     /* Start of the editor text  */
  Text_Ptr      tmp_ptr;                       /* Tmp ptr for the editor   */
  int	        work2[64];                     /* More general storage     */
  int		isforce;	               /* Pl index of forcer       */
  Messageptr    cur_msg;                       /* Message ptr for curr mail*/
  Messageptr    first_msg;                     /* First mail message      */
  Messageptr    work_msg;                      /* Outgoing mail and such  */
  char		passwd[PASSWD_LEN];            /* Passwd                  */
  char		cprompt[PROMPT_LEN+30];        /* Color prompt            */
  char		old_cprompt[PROMPT_LEN+30];    /* Place to store old one */
  char          *wd_them;                      /* Them --> plr           */
  char		*prompt;                       /* prompt to build        */
  char		*setin;
  char 		*setout;
  char 		*setmin;
  char 		*setmout;
  char 		*setvin;
  char 		*setvout;
  char 		*setqin;
  char		*setqout;
  char		*setsit;
  char 		*setstand;
  char		*setsum;
  char		*setsumin;
  char		*setsumout;
  char		ptitle[TITLE_LEN+1];
  int		pmagic;			/* Magic points			*/
  int		pchannel;		/* Chat channel			*/
  int		pkilled;		/* Number of mobiles killed	*/
  int		pdied;			/* Number of times died		*/
  SPELL_DURATION *duration;             /* Spell Duration               */
  QFLAGS	pquests;                /* Quests completed 'n such     */
  PAGER         pager;                  /* Pager structure              */
  Boolean       inpager;                /* Is player in the pager?      */
  FILE          *log;                   /* Logfile for player           */
  Boolean	user_ban;		/* User/Who at login ban	*/
  time_t       	last_on;
} PLAYER_REC;

typedef struct _persona {
  UBLOCK_REC ublock;
  PLAYER_REC player;
  RPLR_REC rplr;
} PERSONA;

#ifndef XR_WEATHER
/* Weather and climate structure
 */
typedef struct _climate {
  int		weather;
  Boolean	daytime;
  int		time;
  int		day;
  int		month;
  int		season;
} CLIMATE_REC;
#else

typedef struct _xrweather {

               /* Global weather stuff */
  Boolean sunny;      /* Is it sunny or cloudy?  :-) */
  int windspeed;      /* How fast is the wind blowing? */
  int rain;           /* How hard it is raining.  Lower is harder */
  int timer;          /* total timer (ticks) since bootup */
  int counter;        /* Counter for how often to update weather */
  int last_hurricane; /* Number of ticks since last hurricane */

                      /* Weather pattern stuff */
  int weatherlen; /* Tick number that the current weather ends (sunny/cloudy) */
  int bottom;     /* Lowest point that the var "rain" will reach this spell */
  int duration;   /* Time that the current period of RAIN ends (ticks) */
  int standby;    /* Tick number it will start to decline */
  int decline;    /* Rain is hardest from end of decline to end of steady. */
  int steady;     /* Tick number it will start to go from bottom -> 10000 */

} XRWEATHER_REC;

#endif

typedef struct _blist {
    char          *name;
    struct _blist *next;
  } Blist;

  
/* The world. Contains some global variables 
 */
typedef struct _a_world {
  Blist         *bchars;
  Blist         *bhosts;
  QFLAGS        q_done;

  int		w_msg_low;
  int		w_msg_high;
  int		w_lock;
  int		w_mob_stop;
  int		w_peace;
  int		w_max_users;
  int		w_tournament;
  PFLAGS	w_pflags[8];
  PFLAGS	w_mask[8];
} WORLD_REC;

struct action {
  char *name;
  char *toall;
  char *tome;
  char *totarget;
  char *tosender;
  char *toothers;
  int flags;
  struct action *nxt;
};

typedef struct action Action;
typedef Action *Actionptr;

#endif