/
driver3.2@242/autoconf/
driver3.2@242/doc/LPC/
driver3.2@242/hosts/
driver3.2@242/hosts/amiga/NetIncl/
driver3.2@242/hosts/amiga/NetIncl/netinet/
driver3.2@242/hosts/amiga/NetIncl/sys/
driver3.2@242/hosts/atari/
driver3.2@242/hosts/fcrypt/
driver3.2@242/mudlib/
driver3.2@242/mudlib/sys/
driver3.2@242/util/
driver3.2@242/util/indent/hosts/next/
driver3.2@242/util/make_docs/
/*
 * Definition of an object.
 * If the object is inherited, then it must not be destructed !
 *
 * The reset is used as follows:
 * 0: There is an error in the reset() in this object. Never call it again.
 * 1: Normal state.
 * 2 or higher: This is an interactive player, that has not given any commands
 *		for a number of reset periods.
 */

#include "interpret.h" /* for struct svalue variables[1] */

#define O_HEART_BEAT		0x01  /* Does it have an heart beat ? */
#define O_IS_WIZARD		0x02  /* Is it a wizard player.c ? */
#define O_ENABLE_COMMANDS	0x04  /* Can it execute commands ? */
#define O_CLONE			0x08  /* Is it cloned from a master copy ? */
#define O_DESTRUCTED		0x10  /* Is it destructed ? */
#define O_SWAPPED		0x20  /* Is it swapped to file */
#define O_ONCE_INTERACTIVE	0x40  /* Has it ever been interactive ? */
#define O_APPROVED		0x80  /* Is std/object.c inherited ? */
#define O_RESET_STATE		0x100 /* Object in a 'reset':ed state ? */
#define O_WILL_CLEAN_UP		0x200 /* clean_up will be called next time */
#define O_LAMBDA_REFERENCED	0x400 /* be careful with replace_program() */

#define SCAN_SWAP_BUFSIZE 0x2000

struct object {
    unsigned short flags;	/* Bits or'ed together from above */
    short total_light;
    int next_reset;		/* Time of next reset of this object */
    int time_of_ref;		/* Time when last referenced. Used by swap */
    p_int ref;			/* Reference count. */
#ifdef DEBUG
    p_int extra_ref;		/* Used to check ref count. */
#endif
    p_int swap_num;		/* Swap file offset. -1 is not swapped yet. */
    struct program *prog;
    char *name;
    struct object *next_all, *next_inv, *next_heart_beat, *next_hash;
    struct object *contains;
    struct object *super;		/* Which object surround us ? */
    struct object *shadowing;		/* Is this object shadowing ? */
    struct object *shadowed;		/* Is this object shadowed ? */
    struct interactive *interactive;	/* Data about an interactive player */
    struct sentence *sent;
    struct wiz_list *user;		/* What wizard defined this object */
    struct wiz_list *eff_user;		/* Used for permissions */
    struct object *next_hashed_living;
    char *living_name;			/* Name of living object if in hash */
#ifdef DEBUG
    int extra_num_variables;
    /* amylaar : used to determine where to check ref counts at all... */
#endif
    struct svalue variables[1];		/* All variables to this program */
    /* The variables MUST come last in the struct */
};

struct replace_ob {
    struct object *ob;
    struct program *new_prog;
    int var_offset;
    int fun_offset;
    struct replace_ob *next;
    struct lambda_replace_program_protector *lambda_rpp;
};


extern struct object *load_object PROT((char *, int, int)),
        *find_object PROT((char *));
extern struct object *get_empty_object(), *find_object PROT((char *)),
	*find_object2 PROT((char *));
extern struct object *current_object, *command_giver;
extern struct replace_ob *obj_list_replace;
#define check_object(o) ((o)&&(o)->flags&O_DESTRUCTED?0:(o))

extern struct object *obj_list;
extern struct object *obj_list_destruct;

struct value;
void remove_destructed_objects(), save_object PROT((struct object *, char *)),
    move_object PROT((struct object *, struct object *)),
    tell_object PROT((struct object *, char *)),
    tell_npc PROT((struct object *, char *)),
    reference_prog PROT((struct program *, char *));
#ifdef DEBUG
void add_ref PROT((struct object *, char *));
void _free_object PROT((struct object *, char *));
#define free_object(object, from) _free_object(object, from)
#else
#define add_ref(object, from) ((object)->ref++)
int _free_object PROT((struct object *));
#define free_object(object, from) \
	((void)(--(object)->ref || _free_object(object)))
#endif

int restore_object PROT((struct object *, char *));