/
roa/
roa/lib/boards/
roa/lib/config/
roa/lib/edits/
roa/lib/help/
roa/lib/misc/
roa/lib/plrobjs/
roa/lib/quests/
roa/lib/socials/
roa/lib/www/
roa/lib/www/LEDSign/
roa/lib/www/LEDSign/fonts/
roa/lib/www/LEDSign/scripts/
roa/src/s_inc/
roa/src/sclient/
roa/src/sclient/binary/
roa/src/sclient/text/
roa/src/util/
/************************************************************************
	Realms of Aurealis 		James Rhone aka Vall of RoA

db.h					Header file for database handling
					and other things... to be sorted!

		******** Heavily modified and expanded ********
		*** BE AWARE OF ALL RIGHTS AND RESERVATIONS ***
		******** Heavily modified and expanded ********
		        All rights reserved henceforth. 

    Please note that no guarantees are associated with any code from
Realms of Aurealis.  All code which has been released to the general
public has been done so with an 'as is' pretense.  RoA is based on both
Diku and CircleMUD and ALL licenses from both *MUST* be adhered to as well
as the RoA license.   *** Read, Learn, Understand, Improve ***
*************************************************************************/
#ifndef ROA_DB_H
#define ROA_DB_H

#include "weather.h"

#ifdef __ROA_DB_C__
  #define EXTERN
#else
  #define EXTERN extern
#endif /* __ROA_DB_C */

/* arbitrary constants used by index_boot() (must be unique) */
#define DB_BOOT_WLD	0
#define DB_BOOT_MOB	1
#define DB_BOOT_OBJ	2
#define DB_BOOT_ZON	3

#define REAL 0
#define VIRTUAL 1

/* names of various files and directories */
#define INDEX_FILE	"index"		/* index of world files		*/
#define MINDEX_FILE	"index.mini"	/* ... and for mini-mud-mode	*/
#define WLD_PREFIX	"world/wld"	/* room definitions		*/
#define MOB_PREFIX	"world/mob"	/* monster prototypes		*/
#define OBJ_PREFIX	"world/obj"	/* object prototypes		*/
#define ZON_PREFIX	"world/zon"	/* zon defs & command tables	*/

#define ROA_HELP_DIR    "help"
#define ROA_WIZHELP_DIR "wizhelp"
#define ROA_SOCIAL_DIR  "socials"
#define ROA_FINGER_DIR  "finger"

#define CREDITS_FILE	"text/credits"	/* for the 'credits' command	*/
#define CREDIT_SEQ_FILE	"text/credit_sequence"	/* seq at login 	*/
#define NEWS_FILE	"text/news"	/* for the 'news' command	*/
#define MOTD_FILE	"text/motd"	/* messages of the day / mortal	*/
#define IMOTD_FILE	"text/imotd"	/* messages of the day / immort	*/
#define IDEA_FILE	"text/ideas"	/* for the 'idea'-command	*/
#define TYPO_FILE	"text/typos"	/*         'typo'		*/
#define BUG_FILE	"text/bugs"	/*         'bug'		*/
#define INFO_FILE	"text/info"	/* for INFO			*/
#define WIZLIST_FILE	"text/wizlist"	/* for WIZLIST			*/
#define IMMLIST_FILE	"text/immlist"	/* for IMMLIST			*/
#define BACKGROUND_FILE	"text/background" /* for the background story	*/
#define POLICIES_FILE	"text/policies"	/* player policies/rules	*/
#define HANDBOOK_FILE	"text/handbook"	/* handbook for new immorts	*/
#define SKILLS_FILE     "text/skills"   /* list of skills for classesJTR*/
#define RACES_FILE      "text/races"    /* list of races JTRhone        */
#define TITLE_FILE0     "text/title0"  /* title message JTRhone        */
#define TITLE_FILE1     "text/title1"  /* title message JTRhone        */
#define TITLE_FILE2     "text/title2"  /* title message JTRhone        */
#define TITLE_FILE3     "text/title3"  /* title message JTRhone        */
#define TITLE_FILE4     "text/title4"  /* title message JTRhone        */
#define TITLE_FILE5     "text/title5"  /* title message JTRhone        */
#define WELCOME_FILE	"text/welcome"	/* welcome message per login	*/
#define START_FILE	"text/start"	/* first time start message	*/
#define PLAYER_FILE	"misc/players"	/* the player database		*/
#define MESS_FILE	"misc/messages"	/* damage message		*/
#define SOCMESS_FILE	"misc/socials"	/* messgs for social acts	*/
#define MAIL_FILE	"misc/plrmail"	/* for the mudmail system	*/
#define BAN_FILE	"misc/badsites"	/* for the siteban system	*/
#define XNAME_FILE	"misc/xnames"	/* invalid name substrings	*/
#define IMP "vall"
#define HCONTROL_FILE   "house/hcontrol" /* for houses */

/* public procedures in db.c */
void	boot_db(void);
void	char_to_store(struct char_data *ch, struct char_file_u *st);
void	store_to_char(struct char_file_u *st, struct char_data *ch);
int	load_char(char *name, struct char_file_u *char_element);
void	save_char(struct char_data *ch, sh_int load_room);
int	create_entry(char *name);
void	zone_update(void);
void	init_char(struct char_data *ch);
void	clear_char(struct char_data *ch);
void	clear_object(struct obj_data *obj);
void	reset_char(struct char_data *ch);
void	free_char(struct char_data *ch);
void	free_obj(struct obj_data *obj);
int	real_room(int vnum);
char   *fread_string(FILE *fl, char *error);
char	fread_letter(FILE *fl);
int	real_object(int vnum);
int	real_mobile(int vnum);
int	vnum_mobile(char *searchname, struct char_data *ch);
int	vnum_object(char *searchname, struct char_data *ch);
char   *killr(char *dstr);
struct obj_data *read_object(int nr, int type);
struct char_data *read_mobile(int nr, int type);
int	file_to_string(char *name, char *buf);
int	huge_file_to_string(char *name, char *buf);
int	file_to_string_alloc(char *name, char **buf);

/* zone definition structure. for the 'zone-table'   */
struct zone_data {
   char	*name;		    /* name of this zone                  */
   int	lifespan;           /* how long between resets (minutes)  */
   int	age;                /* current age of this zone (minutes) */
   int	top;                /* upper limit for rooms in this zone */

   sh_int reset_mode;       /* conditions for reset (see below)   */
   int	number;		    /* virtual number of this zone	  */
   int locked_id;  /* idnum of player who locked it RoA, instead of names */
   int bitvector;    /* lets have some bits for zones RoA*/
   sh_int idle_time;  /* if zone is idle for 15 to 20 minutes, purge it
			 and wait for players to enter it before resetting*/

   char *comlist;  /* for new reset style, ROA, give em strings to reset
		      with instead of that old cmd crap */

   /************ RoA Weather Structures and data ************/
   struct season_data seasons[4];  /* have 4 seasons */

   sh_int current_status;	/* is it rainin? snowin? windy? dry? */
				/* SNOWING, SLEETING, HAILING, RAINING ?*/
   sh_int previous_status;	/* was it rainin? snowin? windy? dry? */

   sh_int current_gtemp;	/* whats the ground temp outside */
   sh_int previous_gtemp;	/* what was that temp an hour ago */

   sh_int current_atemp;	/* whats the air/sky temp outside */
   sh_int previous_atemp;	/* what was that temp an hour ago */

   sh_int accum_type;		/* ACCUM_SNOW, ACCUM_RAIN, ACCUM_MUD, etc */
   sh_int accum;		/* how many inches of accum_type on ground */

   BOOL has_rained;		// has it rained today?
   sh_int 	hour_to_rain;	// what hour during the day will it begin
				// chosen each day at 0 hours 0-23

   int max_pcs;			// stats for players in zone
   int pc_deaths;		// how many pcs died in this zone

   int music_timer;		// how long til resend...
   int wav_timer;		// same for wavs...? not used yet...
   char *sound_file;		// which sound file associated with this zone...?
};
typedef struct zone_data zndata;

/* element in monster and object index-tables   */
struct index_data {
   int	vnum;       		/* vnum of this mob/obj           */
   int	number;     		/* number of existing units of this mob/obj	*/
   int	(*func)(chdata *ch, int cmd, char *arg);  /* special procedure for this mob/obj       */
};
typedef struct index_data indexdata;

/* for queueing zones for update   */
struct reset_q_element {
   int	zone;  /* number of the zone to reset */
   struct reset_q_element *next;
};

/* structure for the update queue     */
struct reset_q_type {
   struct reset_q_element *head;
   struct reset_q_element *tail;
};  /* must declare struct reset_q_type reset_q in db.c internal section */
    /* jtrhone -roa */

struct player_index_element {
   char	*name;
   long id;
   char last_ip[50];
};

/* don't change these */
#define BAN_NOT 	0
#define BAN_NEW 	1
#define BAN_SELECT	2
#define BAN_ALL		3

#define BANNED_SITE_LENGTH    50
struct ban_list_element {
   char	site[BANNED_SITE_LENGTH+1];
   int	type;
   long	date;
   char	name[NAME_LENGTH+1];
   struct ban_list_element *next;
};

/* global buffering system */

EXTERN char	buf[MAX_STRING_LENGTH];
EXTERN char	buf1[MAX_STRING_LENGTH];
EXTERN char	buf2[MAX_STRING_LENGTH];
EXTERN char	arg[MAX_STRING_LENGTH];

#undef EXTERN

#endif /* ROA_DB_H */