#include "boot.clh"

object EXIT
    parents	DESCRIBED_OBJ;

    name = "Generic Exit";

    obj		source;		/* source room */
    obj		dest;		/* destination room */
    str		leave;		/* message displayed to user on leaving */
    str		oleave;		/* message displayed to others on leaving */
    str		arrive;		/* message displayed to user on arriving */
    str		oarrive;	/* message displayed to others on arriving */

    method init
	if (this == EXIT)
	    this.add_owner(WIZARD);
	elseif (PERMS_OK)
	    source = NOTHING;
	    dest = NOTHING;
	    pass();
	else
	    raise E_PERM;
	endif
    endmethod /* init */

    method destroy
	if (PERMS_OK || caller == source)
	    source.rm_exit(this);
	    pass();
	else
	    raise E_PERM;
	endif
    endmethod

    method match
	return match_full(name, args[1], ";");
    endmethod /* match */

    method dest
	return dest;
    endmethod /* dest */

    method set_dest
	if (PERMS_OK)
	    dest = args[1];
	else
	    raise(E_PERM);
	endif
    endmethod

    method set_source
	if (PERMS_OK)
	    source = args[1];
	else
	    raise(E_PERM);
	endif
    endmethod

    method activate
/*
 * activate the exit
 */
	var	pname;
	ignore	E_SERVERDN;

	pname = player.name;

/* 
 * display leave messages in old room
 */
	if (dest.name == E_SERVERDN)
	    player.tell("You can't go that way right now.");
	    return;
	elseif (!player.moveto(dest, leave, oleave, arrive, oarrive))
	    player.tell("You can't go that way.");
	    return;
	endif
    endmethod /* activate */

endobject	/* EXIT */