dbm/
misc/
old-docs/
/* db.h */

/*
 * Basic structs and stuff for TeenyMUD
 */

struct dsc;			/* Forward */

struct obj_data {

  /* The usual ints and dbref-ish ints */

  int             pennies;
  dbref           loc;
  dbref           contents;
  dbref           exits;
  dbref           rooms;
  long            timestamp;	/* This will be in minutes into the epoch */

  /* This is an array of ints */

  int            *lock;
  int            *elock;
  int            *destinations;

  /* These are the usual zero terminated strings. */

  char           *suc;
  char           *osuc;
  char           *fail;
  char           *ofail;
  char           *drop;
  char           *odrop;
  char           *desc;
  char           *enter;
  char           *oenter;
  char           *leave;
  char           *oleave;
  char           *idesc;
  char           *odesc;
  char           *site;
  char           *kill;
  char           *okill;
  char           *password;
  char           *otel;
  char           *oxtel;
  char           *oxent;
  char           *oxlea;
  char           *efail;
  char           *oefail;

  /* for use by the caching system */

  struct dsc     *descriptor;
  struct obj_data *fwd;
  struct obj_data *back;

  /* on disk size */

  long            size;
};

/*
 * A typical memory resident descriptor. If it describes an actual object, it
 * will be referenced by the main object index array, and the name field of
 * the ptr union will be meaningful. If it describes a free chunk, the next
 * field will be. We do it this way so objects can conveniently be destroyed.
 * 
 */

struct dsc {
  long            flags;
  dbref           owner;
  dbref           home_dropto;	/* Also destination for exits */
  int             size;		/* Size on disk. */
  int             list_next;	/* Used for exits/contents lists */
  dbref           obj_number;	/* real-world object number. not saved */
  union {
    char           *name;	/* If describing real data, or.. */
    struct dsc     *next;	/* .. a free chunk/descriptor    */
  }               ptr;

  struct obj_data *data;

  struct dsc     *next;		/* free descriptor list */
};

/*
 * For reaching in to a descriptor.
 */

#define GodP(a)		((a)->flags & GOD)
#define StickyP(a)	((a)->flags & STICKY)
#define WizP(a)		((a)->flags & WIZARD)
#define RobotP(a)	((a)->flags & ROBOT)
#define LinkOkP(a)	((a)->flags & LINK_OK)
#define HavenP(a)	((a)->flags & HAVEN)
#define JumpOkP(a)	((a)->flags & JUMP_OK)
#define AbodeP(a)	((a)->flags & ABODE)
#define ResidentP(a)	((a)->flags & IN_MEMORY)
#define DirtyP(a)	((a)->flags & DIRTY)
#define PlayerP(a)	(((a)->flags & TYPE_MASK) == TYP_PLAYER)
#define ThingP(a)	(((a)->flags & TYPE_MASK) == TYP_THING)
#define RoomP(a)	(((a)->flags & TYPE_MASK) == TYP_ROOM)
#define ExitP(a)	(((a)->flags & TYPE_MASK) == TYP_EXIT)

#define DSC_NAME(a)	(((a)->ptr).name)
#define DSC_DATA(a)	((a)->data)
#define DSC_SIZE(a)	((a)->size)
#define DSC_FLAGS(a)	((a)->flags)
#define DSC_OWNER(a)	((a)->owner)
#define DSC_NUMBER(a)	((a)->obj_number)
#define DSC_HOME(a)	((a)->home_dropto)
#define DSC_DROPTO(a)	((a)->home_dropto)
#define DSC_DESTINATION(a)	((a)->home_dropto)
#define DSC_NEXT(a)	((a)->list_next)

/*
 * Initial size of an object (a *total* grey box). One int each for: pennies,
 * location, exits, contents, One int for a blank lock (a -1 on disk), A \0
 * on disk for each of the empty strings suc, osuc, fail, ofail, desc, etc.
 * 
 */
#define INITIAL_SIZE (9 * sizeof(int)) + 23

/*
 * Tuning variables -- how much to grow the index by when you run out of
 * space for more entries, and how much slack space to start with when you
 * bring up an existing database. Ideally, SLACK is the number of objects
 * that will be created between start time, and when you bring it down, so
 * you never actually run out of index space.
 */

#define GROWTH_INCREMENT 1024
#define SLACK 512
#define DSC_SLACK 32