foundation2_fluffos_v1/
foundation2_fluffos_v1/bin/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/ChangeLog.old/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/Win32/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/compat/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/compat/simuls/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/include/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/clone/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/command/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/data/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/etc/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/include/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/inherit/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/inherit/master/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/log/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/single/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/single/tests/compiler/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/single/tests/efuns/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/single/tests/operators/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/testsuite/u/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/tmp/
foundation2_fluffos_v1/fluffos-2.9-ds2.13/windows/
foundation2_fluffos_v1/lib/cfg/
foundation2_fluffos_v1/lib/cmds/adm/
foundation2_fluffos_v1/lib/daemon/save/
foundation2_fluffos_v1/lib/daemon/services/
foundation2_fluffos_v1/lib/daemon/soul/
foundation2_fluffos_v1/lib/doc/build/
foundation2_fluffos_v1/lib/doc/classes/
foundation2_fluffos_v1/lib/doc/driver/
foundation2_fluffos_v1/lib/doc/driver/applies/
foundation2_fluffos_v1/lib/doc/driver/applies/interactive/
foundation2_fluffos_v1/lib/doc/driver/concepts/
foundation2_fluffos_v1/lib/doc/driver/driver/
foundation2_fluffos_v1/lib/doc/driver/efuns/arrays/
foundation2_fluffos_v1/lib/doc/driver/efuns/buffers/
foundation2_fluffos_v1/lib/doc/driver/efuns/calls/
foundation2_fluffos_v1/lib/doc/driver/efuns/compile/
foundation2_fluffos_v1/lib/doc/driver/efuns/filesystem/
foundation2_fluffos_v1/lib/doc/driver/efuns/floats/
foundation2_fluffos_v1/lib/doc/driver/efuns/functions/
foundation2_fluffos_v1/lib/doc/driver/efuns/general/
foundation2_fluffos_v1/lib/doc/driver/efuns/mappings/
foundation2_fluffos_v1/lib/doc/driver/efuns/numbers/
foundation2_fluffos_v1/lib/doc/driver/efuns/parsing/
foundation2_fluffos_v1/lib/doc/driver/lpc/constructs/
foundation2_fluffos_v1/lib/doc/driver/lpc/types/
foundation2_fluffos_v1/lib/doc/driver/platforms/
foundation2_fluffos_v1/lib/doc/efun/
foundation2_fluffos_v1/lib/doc/etc/
foundation2_fluffos_v1/lib/doc/faq/
foundation2_fluffos_v1/lib/doc/help/creator/
foundation2_fluffos_v1/lib/doc/help/player/
foundation2_fluffos_v1/lib/doc/lpc/basic/
foundation2_fluffos_v1/lib/doc/lpc/data_types/
foundation2_fluffos_v1/lib/doc/lpc/etc/
foundation2_fluffos_v1/lib/doc/lpc/intermediate/
foundation2_fluffos_v1/lib/doc/lpc/types/
foundation2_fluffos_v1/lib/doc/mudlib/
foundation2_fluffos_v1/lib/doc/mudlib/Features/
foundation2_fluffos_v1/lib/domains/Examples/armour/
foundation2_fluffos_v1/lib/domains/Examples/etc/
foundation2_fluffos_v1/lib/domains/Examples/npc/
foundation2_fluffos_v1/lib/domains/Examples/room/
foundation2_fluffos_v1/lib/domains/Examples/virtual/
foundation2_fluffos_v1/lib/domains/Examples/virtual/exaA/
foundation2_fluffos_v1/lib/domains/Examples/virtual/exaB/
foundation2_fluffos_v1/lib/domains/Examples/weapon/
foundation2_fluffos_v1/lib/domains/School/doc/
foundation2_fluffos_v1/lib/domains/School/room/
foundation2_fluffos_v1/lib/domains/School/room/Classes/
foundation2_fluffos_v1/lib/domains/School/room/Offices/
foundation2_fluffos_v1/lib/domains/Standard/
foundation2_fluffos_v1/lib/domains/Standard/pools/
foundation2_fluffos_v1/lib/domains/Standard/std/
foundation2_fluffos_v1/lib/domains/Standard/xtra/
foundation2_fluffos_v1/lib/include/
foundation2_fluffos_v1/lib/lib/obj/
foundation2_fluffos_v1/lib/news/
foundation2_fluffos_v1/lib/save/
foundation2_fluffos_v1/lib/secure/cfg/
foundation2_fluffos_v1/lib/secure/cmds/player/
foundation2_fluffos_v1/lib/secure/lib/
foundation2_fluffos_v1/old/
foundation2_fluffos_v1/win32/
/*    /lib/room/exits.c
 *    from the Foundation II LPC Library
 *    handles players exiting from rooms
 *    created by Descartes of Borg 940711
 *    modified for new inheritance structure by Descartes 950208
 */

#include <rooms.h>
#include "exits.h"

static private mapping Exits, Enters, Doors;

static void create() {
    Exits = ([]);
    Enters = ([]);
    Doors = ([]);
}

static void init() {
    /* go and enter are cached inside the user object */
    //add_action( (: cmdLock :), "lock");
    //add_action( (: cmdUnlock :), "unlock");
    //add_action( (: cmdOpen :), "open");
    //add_action( (: cmdClose :), ({ "close", "shut" }));
}

int cmdGo(string str) {
    if( (int)this_player()->GetParalyzed() ) 
      return notify_fail("You are unable to move.\n");
    if( !Exits[str] ) return notify_fail("You go nowhere at all.\n");
    if( Doors[str] && (int)Doors[str]->GetClosed() ) {
	message("my_action", "You bump into " + 
		(string)Doors[str]->GetShort(str) + ".", this_player());
	return 1;
    }
    if( Exits[str]["pre"] && !((int)evaluate(Exits[str]["pre"], str)) )
      return 1;
    this_player()->eventMoveLiving(Exits[str]["room"], str);
    if( Exits[str]["post"] ) evaluate(Exits[str]["post"], str);
    return 1;
}

int cmdEnter(string str) {
    if( (int)this_player()->GetParalyzed() )
      return notify_fail("You are unable to move.\n");
    if( !Enters[str] ) return notify_fail("You cannot enter that.\n");
    if( Doors[str] && (int)Doors[str]->GetClosed() ) {
	message("my_action", "You bump into " + 
		(string)Doors[str]->GetShort(str) + ".", this_player());
	return 1;
    }
    if( Enters[str]["pre"] && !((int)evaluate(Enters[str]["pre"], str)) )
      return 1;
    this_player()->eventMoveLiving(Enters[str]["room"], str);
    if( Enters[str]["post"] ) evaluate(Enters[str]["post"], str);
    return 1;
}

int cmdLock(string which) {
    string *doors;
    object ob;
    string what;
    int i;

    if( !which || which == "" ) return 0;
    if( !(i = sizeof(doors = keys(Doors))) ) return 0;
    if( sscanf(which, "%s with %s", which, what) != 2 ) 
      return notify_fail("Lock it with what?\n");
    if( !(ob = present(what, this_player())) ) {
	message("my_action", "You do not have any such thing.", this_player());
	return 1;
    }
    while(i--) {
	if( (string)Doors[doors[i]]->GetId(doors[i]) == which ) {
	    if( sizeof((string *)ob->GetId() &
		       (string *)Doors[doors[i]]->GetGeys(doors[i])) ) {
		message("my_action", "That will not work on this lock.",
			this_player());
		return 1;
	    }
	    if( (int)Doors[doors[i]]->GetLocked() ) {
		message("my_action", "It is already locked!", this_player());
		return 1;
	    }
	    if( (int)Doors[doors[i]]->eventLock(this_object(), 
						this_player()) ) return 1;
	    else {
		message("my_action", "You fail to lock it.", this_player());
		return 1;
	    }
	}
    }
    return notify_fail("You see nothing here of that nature to lock.\n");
}
	
int cmdUnlock(string which) {
    string *doors;
    object ob;
    string what;
    int i;

    if( !which || which == "" ) return 0;
    if( !(i = sizeof(doors = keys(Doors))) ) return 0;
    if( sscanf(which, "%s with %s", which, what) != 2 ) 
      return notify_fail("Unlock it with what?\n");
    if( !(ob = present(what, this_player())) ) {
	message("my_action", "You have no such thing!", this_player());
	return 1;
    }
    while(i--) {
	if( (string)Doors[doors[i]]->GetId(doors[i]) == which ) {
	    if( sizeof((string *)ob->GetId() & 
		       (string *)Doors[doors[i]]->GetGeys(doors[i])) ) {
		message("my_action", "That will not work on this lock.",
			this_player());
		return 1;
	    }
	    if( !((int)Doors[doors[i]]->GetLocked()) ) {
		message("my_action", "It is already unlocked!", this_player());
		return 1;
	    }
	    if( (int)Doors[doors[i]]->eventUnlock(this_object(),
						  this_player()) ) return 1;
	    else {
		message("my_action", "You fail to unlock it.", this_player());
		return 1;
	    }
	}
    }
    return notify_fail("You see nothing here of that nature to unlock.\n");
}

int cmdOpen(string which) {
    string *doors;
    int i;

    if( !which || which == "" ) return 0;
    if( !(i = sizeof(doors = keys(Doors))) ) return 0;
    while(i--) {
	if( !((string)Doors[doors[i]]->GetId(doors[i]) == which) )
	  continue;
	if( (int)Doors[doors[i]]->GetLocked() ) {
	    message("my_action", (string)Doors[doors[i]]->GetShort(doors[i]) +
		    " is locked.", this_player());
	    return 1;
	}
	if( !((int)Doors[doors[i]]->GetClosed()) ) {
	    message("my_action", "It is already open.", this_player());
	    return 1;
	}
	if( (int)Doors[doors[i]]->eventOpen(this_object(), this_player()) ) {
	    message("my_action", "You open " + 
		    (string)Doors[doors[i]]->GetShort(doors[i]) + ".",
		    this_player());
	    message("other_action", (string)this_player()->GetName() + 
		    " opens " + (string)Doors[doors[i]]->GetShort(doors[i]) +
		    ".", this_object(), ({ this_player() }));
	    return 1;
	}
	else {
	    message("my_action", "You fail to open it.", this_player());
	    return 1;
	}
    }
    return notify_fail("There is no such thing to be opened.\n");
}
	
int cmdClose(string which) {
    string *doors;
    int i;

    if( !which || which == "" ) return 0;
    if( !(i = sizeof(doors = keys(Doors))) ) return 0;
    while(i--) {
	if( !((string)Doors[doors[i]]->GetId(doors[i]) == which) )
	  continue;
	if( (int)Doors[doors[i]]->GetClosed() ) {
	    message("my_action", "It is already closed.", this_player());
	    return 1;
	}
	if( (int)Doors[doors[i]]->eventClose(this_object(), this_player()) ) {
	    message("my_action", "You close " +
		    (string)Doors[doors[i]]->GetShort(doors[i]) + ".",
		    this_player());
	    message("other_action", (string)this_player()->GetName() + 
		    " closes " + (string)Doors[doors[i]]->GetShort(doors[i]) +
		    ".", this_object(), ({ this_player() }));
	    return 1;
	}
	else {
	    message("my_action", "You fail to close it.", this_player());
	    return 1;
	}
    }
    return notify_fail("There is no such thing to be closed.\n");
}
	
mapping SetExits(mapping mp) {
    mixed it;
    string *cles;
    int i;

    Exits = ([]);
    i = sizeof(cles = keys(mp));
    while(i--) {
	it = mp[cles[i]];
	if( stringp(it) ) Exits[cles[i]] = ([ "room" : it ]);
	else if( pointerp(it) ) {
	    int j;

	    if( (j = sizeof(it)) && stringp(it[0]) ) {
		Exits[cles[i]] = ([ "room" : it[0] ]);
		if (j > 1 && functionp(it[1])) {
		    Exits[cles[i]]["pre"]=it[1];
		    if( j>2 && functionp(it[2]) ) Exits[cles[i]]["post"]=it[2];
		}
	    }
	}
    }
    return Exits;
}

varargs mapping AddExit(string dir, string dest, function pre, function post) {
    if(!stringp(dir)) error("Bad argument 1 to AddExit().\n");
    if(!stringp(dest)) error("Bad argument 2 to AddExit().\n");
    Exits[dir] = ([ "room" : dest ]);
    if( functionp(pre) ) Exits[dir]["pre"] = pre;
    if( functionp(post) ) Exits[dir]["post"] = post;
    return Exits[dir];
}

mapping RemoveExit(string dir) {
    if(Exits[dir]) map_delete(Exits, dir);
}

string GetExit(string str) {
    if(!Exits[str]) return 0;
    else return Exits[str]["room"];
}

string *GetExits() { return keys(Exits); }

mapping SetEnters(mapping mp) {
    string *cles;
    int i;

    Enters = ([]);
    i = sizeof(cles = keys(mp));
    while(i--) Enters[cles[i]] = ([ "room": mp[cles[i]] ]);
    return Enters;
}

varargs mapping AddEnter(string dir, string dest, function pre, function post) {
    if( !stringp(dir) ) error("Bad argument 1 to AddEnter().\n");
    if( !stringp(dest) ) error("Bad argument 2 to AddEnter().\n");
    Enters[dir] = ([ "room" : dest ]);
    if( functionp(pre) ) Enters[dir]["pre"] = pre;
    if( functionp(post) ) Enters[dir]["post"] = post;
}

mapping RemoveEnter(string dir) { 
    if( Enters[dir] ) map_delete(Enters, dir);
    return Enters;
}

string GetEnter(string dir) {
    if( !Enters[dir] ) return 0;
    else return Enters[dir]["room"];
}

string *GetEnters() { return keys(Enters); }

string SetDoor(string dir, string file) { 
    file->eventRegisterSide(dir);
    return (Doors[dir] = file); 
}

string GetDoor(string dir) { return Doors[dir]; }

string *GetDoors() { return keys(Doors); }

string GetDirection(string dest) {
    string *cles;
    int i;

    i = sizeof(cles = keys(Exits));
    while(i--) if(Exits[cles[i]]["room"] == dest) return "go "+cles[i];
    i = sizeof(cles = keys(Enters));
    while(i--) if(Enters[cles[i]]["room"] == dest) return "enter "+cles[i];
    return 0;
}