/* dbdefs.h */ #ifndef __DBDEFS_H #define __DBDEFS_H #include <stdio.h> #ifdef I_SYS_TIME #include <sys/time.h> #endif #ifdef I_TIME #include <time.h> #endif #include "attrib.h" #include "options.h" extern int depth; typedef int object_flag_type; #ifdef CHAT_SYSTEM /* Must come after dbref is defined */ #include "extchat.h" #endif extern dbref first_free; /* pointer to free list */ /* macro to make set string easier to use */ #define SET(a,b) set_string(&(a),b) /* set macro for compressed strings */ #ifdef COMPRESS #define SETC(a,b) SET(a,compress(b)) #else #define SETC(a,b) SET(a,b) #endif /* COMPRESS */ /* Updates an objects age */ #define Access(x) (db[(x)].flags |= ACCESSED) /*------------------------------------------------------------------------- * Database access macros */ #define Typeof(x) (db[(x)].flags & TYPE_MASK) #define Name(x) (db[(x)].name) #define Flags(x) (db[(x)].flags) #define Toggles(x) (db[(x)].toggles) #define Owner(x) (db[(x)].owner) #define Location(x) (db[(x)].location) #define Zone(x) (db[(x)].zone) #define Contents(x) (db[(x)].contents) #define Next(x) (db[(x)].next) #define Home(x) (db[(x)].exits) #define Exits(x) (db[(x)].exits) /* These are only for exits */ #define Source(x) (db[(x)].exits) #define Destination(x) (db[(x)].location) #define Locks(x) (db[(x)].locks) #ifdef CREATION_TIMES #define CreTime(x) (db[(x)].creation_time) #define ModTime(x) (db[(x)].modification_time) #endif #ifdef LOCAL_DATA #define LocData(x) (db[(x)].local_data) #endif #define Pennies(thing) (db[thing].penn) #define s_Pennies(thing,p) (db[thing].penn=(p)) #define Parent(x) (db[(x)].parent) #define Powers(x) (db[(x)].powers) /* Note that this is a utility to determine the objects which may or may */ /* not be controlled, rather than a strict check for the INHERIT flag */ #define Owns(p,x) (db[(p)].owner == db[(x)].owner) #define IS(thing,type,flag) ((Typeof(thing)==type) && (Toggles(thing) & flag)) #define Hasflag(x,t,f) ((Typeof(x) == t) && (Flags(x) & f)) #define Destroyed(x) (Typeof(x) == TYPE_GARBAGE) #define GoodObject(x) ((x >= 0) && (x < db_top)) #define Wizard(x) ((Flags(x) & WIZARD) || God(x)) #ifdef FIXED_FLAG #define Fixed(x) (IS(x,TYPE_PLAYER,PLAYER_FIXED)) #endif #ifdef ROYALTY_FLAG #define Royalty(x) (Flags(x) & ROYALTY) #define Hasprivs(x) (Royalty(x) || Wizard(x)) #else /* ROYALTY_FLAG */ #define Royalty(x) 0 #define Hasprivs(x) (Wizard(x)) #endif /* ROYALTY_FLAG */ #define Mobile(x) ((Typeof(x) == TYPE_PLAYER) || (Typeof(x) == TYPE_THING)) #define DestOk(x) (IS(x, TYPE_THING, THING_DEST_OK)) #define Puppet(x) (IS(x, TYPE_THING, THING_PUPPET)) #define Alive(x) ((Typeof(x)==TYPE_PLAYER) || Puppet(x)) #define Audible(x) (Flags(x) & AUDIBLE) #define Dark(x) ((Flags(x) & DARK) && (Wizard(x) || !Alive(x))) #define Debug(x) (Flags(x) & DEBUGGING) #define Going(x) (Flags(x) & GOING) #define Going_Twice(x) (Flags(x) & GOING_TWICE) #define Halted(x) (Flags(x) & HALT) #define Haven(x) (Flags(x) & HAVEN) #define LinkOk(x) (Flags(x) & LINK_OK) #define NoCommand(x) (Flags(x) & NO_COMMAND) #define Opaque(x) (Flags(x) & OPAQUE) #define Quiet(x) (Flags(x) & QUIET) #define IsQuiet(x) (Quiet(x) || Quiet(Owner(x))) #define AreQuiet(x,y) (Quiet(x) || Quiet(y)) #define Safe(x) (Flags(x) & SAFE) #define Sticky(x) (Flags(x) & STICKY) #define Unfind(x) (Flags(x) & UNFIND) #define Visual(x) (Flags(x) & VISUAL) #define Light(x) (Flags(x) & LIGHT) #define Startup(x) (Flags(x) & STARTUP) #define Marked(x) (Flags(x) & MARKED) #define Connected(x) (IS(x, TYPE_PLAYER, PLAYER_CONNECT)) #define Nospoof(x) (Toggles(Owner(x)) & PLAYER_NOSPOOF) #define Terse(x) (Toggles(Owner(x)) & PLAYER_TERSE) #define Myopic(x) (Toggles(Owner(x)) & PLAYER_MYOPIC) #define ShowAnsi(x) (Toggles(Owner(x)) & PLAYER_ANSI) #ifdef EXTENDED_ANSI #define AnsiForceWhite(x) \ (ShowAnsi(x) && (Toggles(Owner(x)) & PLAYER_FORCEWHITE)) #define ShowAnsiColor(x) (Toggles(Owner(x)) & PLAYER_COLOR) #endif #ifdef VACATION_FLAG #define Vacation(x) (IS(x, TYPE_PLAYER, PLAYER_VACATION)) #endif #define Suspect(x) (IS(x, TYPE_PLAYER, PLAYER_SUSPECT)) #define ZMaster(x) (IS(x, TYPE_PLAYER, PLAYER_ZONE)) #define Abode(x) (IS(x, TYPE_ROOM, ROOM_ABODE)) #define Floating(x) (IS(x, TYPE_ROOM, ROOM_FLOATING)) #define Inherit(x) ((Typeof(x) == TYPE_PLAYER) || (Flags(x) & INHERIT) || \ (Flags(Owner(x)) & INHERIT) || Wizard(x)) /*-------------------------------------------------------------------------- * Other db stuff */ /* Boolean expressions, for locks */ typedef char boolexp_type; #define BOOLEXP_AND 0 #define BOOLEXP_OR 1 #define BOOLEXP_NOT 2 #define BOOLEXP_CONST 3 #define BOOLEXP_ATR 4 #define BOOLEXP_IND 5 #define BOOLEXP_CARRY 6 #define BOOLEXP_IS 7 #define BOOLEXP_OWNER 8 #define BOOLEXP_EVAL 9 #define BOOLEXP_NULL 127 /* Mark a lack of a boolexp */ struct boolexp { boolexp_type type; /* and, or, not, indirect, is, carry, etc. */ struct boolexp *sub1; /* first part of lock */ struct boolexp *sub2; /* second part of lock */ dbref thing; /* thing refers to an object */ struct boolatr *atr_lock; }; #define TRUE_BOOLEXP ((struct boolexp *) 0) /* special dbref's */ #define NOTHING (-1) /* null dbref */ #define AMBIGUOUS (-2) /* multiple possibilities, for matchers */ #define HOME (-3) /* virtual room, represents mover's home */ #define ANY_OWNER (-2) /* For lstats and @stat */ struct object { const char *name; dbref location; /* pointer to container */ /* for exits, pointer to destination */ /* for rooms, pointer to drop-to */ dbref contents; /* pointer to first item */ dbref exits; /* pointer to first exit for rooms */ /* pointer to home for things and players */ /* pointer to room it's in for exits. */ dbref next; /* pointer to next in contents/exits chain */ dbref parent; /* pointer to last person paged for player */ /* parent object for everything else */ struct lock_list *locks; dbref owner; /* who controls this object */ dbref zone; /* zone master object number */ int penn; /* number of pennies object contains */ #ifdef CHAT_SYSTEM CHANLIST *channels; #endif #ifdef USE_WARNINGS int warnings; /* bitflags of warning types */ #endif #ifdef CREATION_TIMES time_t creation_time; /* Time/date of object creation */ time_t modification_time; /* Time/data of last modification to the * object's attribs; number of failed * logins for players. */ #endif #ifdef LOCAL_DATA void *local_data; #endif object_flag_type flags; object_flag_type toggles; object_flag_type powers; ALIST *list; }; struct dblist { /* used by routines in util.c */ dbref obj; struct dblist *next; }; struct db_stat_info { /* used by get_stats in wiz.c (@stat, etc) */ int total; int players; int rooms; int exits; int things; int garbage; }; extern struct object *db; extern dbref db_top; extern const char *alloc_string _((void)); extern dbref new_object _((void)); extern void putstring _((FILE * f, const char *s)); extern long getref _((FILE * f)); extern void putref _((FILE * f, long int ref)); extern const char *getstring_noalloc _((FILE * f)); extern struct boolexp *getboolexp _((FILE * f)); extern void putboolexp _((FILE * f, struct boolexp * b)); extern int db_write_object _((FILE * f, dbref i)); extern dbref db_write _((FILE * f)); extern dbref db_read _((FILE * f)); /* Warning: destroys existing db contents! */ extern void free_bool _((struct boolexp * b)); extern struct boolexp *dup_bool _((struct boolexp * b)); extern struct boolexp *alloc_bool _((void)); extern void free_boolexp _((struct boolexp * b)); extern void db_free _((void)); extern dbref parse_dbref _((const char *s)); extern void putlocks _((FILE * f, struct lock_list *l)); extern void getlocks _((dbref i, FILE * f)); extern void get_old_locks _((dbref i, FILE * f)); #define DOLIST(var, first)\ for((var) = (first); GoodObject((var)); (var) = db[(var)].next) #define PUSH(thing, locative) \ ((db[(thing)].next = (locative)), (locative) = (thing)) #define DOLIST_VISIBLE(var, first, player)\ for((var) = first_visible((player), (first)); GoodObject((var)); (var) = first_visible((player), db[(var)].next)) #ifdef USE_MAILER struct mail { struct mail *next; struct mail *prev; dbref to; dbref from; unsigned char *message; /* compressed */ unsigned char *time; /* compressed */ #ifdef MAIL_SUBJECTS unsigned char *subject; /* compressed */ #endif int read; }; #endif /* USE_MAILER */ /* log types */ #define LT_ERR 0 #define LT_CMD 1 #define LT_WIZ 2 #define LT_CONN 3 #define LT_TRACE 4 #define LT_RPAGE 5 #define LT_CHECK 6 #define LT_HUH 7 /* tokens for locks */ #define NOT_TOKEN '!' #define AND_TOKEN '&' #define OR_TOKEN '|' #define AT_TOKEN '@' #define IN_TOKEN '+' #define IS_TOKEN '=' #define OWNER_TOKEN '$' #endif /* __DBDEFS_H */