/*
 * AREA_HANDLER AUTOGENERATED ROOM
 *
 * DO NOT CHANGE ANYTHING IN THIS ROOM SINCE THE ROOM
 * AUTOREMOVES ITSELF REGULARLY.
 */

inherit "/std/room";

#include <stdproperties.h>
#include <macros.h>
#define TO this_object()

string		Master_ob;	/* The master object */
int		Timeout;	/* Timeout time */
static int	Alarm;		/* Alarm ID */

public nomask void set_cleanup_time(int time);

create_room()
{
    setuid();
    seteuid(getuid());

    Master_ob = "/d/Genesis/doc/examples/area_handler/ah_obj";
    Timeout = 300;

    set_short("a tree");
    set_long("In the middle of the meadows stands a tree. It's a gnarled tree that seems to have been hit by the lightning many times but somehow survived every time. You feel an evil presence looming over you.\n");

    add_exit("", "west", "@@move_in_map:/d/Genesis/doc/examples/area_handler/ah_obj|meadow.3.11.c@@", 1);
    add_exit("", "south", "@@move_in_map:/d/Genesis/doc/examples/area_handler/ah_obj|meadow.4.10.c@@", 1);
    add_exit("", "east", "@@move_in_map:/d/Genesis/doc/examples/area_handler/ah_obj|meadow.5.11.c@@", 1);

    add_item("presence", "It can't be seen, only felt...\n");

    clone_object("/d/Immortal/mrpr/obj/examples/tree")->move(TO, 1);

    set_cleanup_time((120 * 30));

    add_prop(ROOM_I_TYPE, 0);
    add_prop(ROOM_I_INSIDE, 0);
    add_prop(ROOM_I_LIGHT, 1);
    add_prop(ROOM_I_NO_CLEANUP, 1);
}

public void
clean_up()
{
    object *ob;
    int i;

    ob = all_inventory(this_object());
    for (i = 0 ; i < sizeof(ob) ; i++)
    {
	if (living(ob[i]))
	{
	    remove_alarm(Alarm);
	    Alarm = set_alarm(itof(Timeout), 0.0, clean_up);
	    return;
	}
    } 

    for (i = 0 ; i < sizeof(ob) ; i++)
	Master_ob->dispose_of(ob[i]);

    rm(MASTER_OB(TO) + ".c");
    remove_object();
}

public nomask void
enter_inv(object ob, object from)
{
    remove_alarm(Alarm);
    Alarm = set_alarm(itof(Timeout), 0.0, clean_up);
    ::enter_inv(ob, from);
}

public nomask void
set_cleanup_time(int time)
{
    Timeout = time;
    remove_alarm(Alarm);
    Alarm = set_alarm(itof(Timeout), 0.0, clean_up);
}
