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/interactive.c
 *    from the Foundation II LPC Library
 *    an interactive object
 *    created by Descartes of Borg 941001 for the Idea Exchange
 *    modified for Foundation II 950210
 */

#include <lib.h>
#include <daemons.h>
#include <objects.h>
#include <rooms.h>
#include <origin.h>
#include "interactive.h"

inherit LIB_CONTAINER;
inherit LIB_OBJECT;
inherit LIB_MOVE;
inherit LIB_AUTOSAVE;
inherit LIB_FILES;
inherit LIB_PAGER;
inherit LIB_MESSAGES;
inherit LIB_INTERFACE;

private int Age, WhereBlock, Brief, LoginTime, BirthTime;
private string Password, Email, RealName, Position;
private mapping News;
private static int LastAge, Setup;
private static object NetDiedHere;
private static mapping LastError;
private static string *UserId;

static void create() {
    container::create();
    object::create();
    autosave::create();
    messages::create();
    interface::create();
    Brief = 0;
    Password = 0;
    Email = 0;
    RealName = 0;
    Position = "citizen";
    BirthTime = time();
    LastAge = time();
    News = ([]);
    SetShort("$N the unaccomplished");
}

/* ***************  /lib/interactive.c modal functions  *************** */

int CanGet(object ob) {
    message("my_action", GetName() + " is a living being!", ob);
    return 0;
}

/* ***************  /lib/interactive.c lfuns  *************** */
int Setup() {
    mapping mp;
    string tmp;

    if(Setup) return 0;
    else Setup = 1;
    set_living_name(GetKeyName());
    interface::Setup();
    add_action((: cmdQuit :), "quit");
    LoginTime = time();
    SetId(({}));
    autosave::Setup();
    call_out("save_player", 2, GetKeyName());
    log_file("enter", GetCapName()+" (enter): "+ctime(time())+
      " : "+query_ip_name(this_object())+"\n");
    eventMove(ROOM_START);
    if( !(tmp = GetMessage("login")) ) 
      tmp = GetName() + " enters " + mud_name() + ".";
    message("environment", tmp, environment(this_object()), ({this_object()}));
    message("announce", "["+GetCapName()+" logs in]",
      filter_array(users(), (: archp :)));
    if(!catch(mp = (mapping)FOLDERS_D->mail_status(GetKeyName()))) {
        if(mp["unread"]) {
            message("login", "\n>>> "+mp["unread"] + " of your " + 
              (mp["total"] == 1 ? mp["total"]+" letter is" :
              mp["total"]+" letters remain") + " unread. <<<\n", 
              this_object());
        }
    }
    catch(NEWS_D->read_news());
    return 1;
}

static void net_dead() {
    interface::net_dead();
    Age += time() - LastAge;
    LastAge = time();
    save_player(GetKeyName());
    NetDiedHere = environment(this_object());
    message("other_action", GetName()+" suddenly disappears into " +
      "a sea of irreality.", environment(this_object()), ({ this_object() }));
    message("announce", "["+GetCapName()+" goes net-dead]", 
      filter_array(users(), (: archp :)));
    eventMove(ROOM_FREEZER);
    if(query_snoop(this_object()))
      message("snoop", GetCapName()+" has gone net-dead.",
        query_snoop(this_object()));
}

void restart_heart() {
    string dead_ed;

    interface::restart_heart();
    LastAge = time();
    message("system", "Reconnected.", this_object());
    message("announce", "["+GetCapName()+" has rejoined "+mud_name()+"]",
      filter(users(), (: archp :)));
    if(NetDiedHere) eventMove(NetDiedHere);
    else eventMove(ROOM_START);
    message("environment", GetCapName()+" has rejoined this reality.",
      environment(this_object()), ({ this_object() }));
    NetDiedHere = 0;
}

void eventDescribeEnvironment(int brief) {
    mapping mp;
    object *obs;
    object env;
    mixed tmp;
    string *shorts;
    string desc, smell, sound;
    int i, maxi;

    if(!(env = environment(this_object()))) {
        message("room_description", "You are nowhere.", this_object());
        return;
    }
    if(!brief) {
        desc = (string)env->GetLong();
        if(functionp(tmp = (mixed)env->GetSmell("default")))
          tmp = (string)(*tmp)("default");
        smell = tmp;
        if(functionp(tmp = (mixed)env->GetListen("default")))
          tmp = (string)(*tmp)("default");
        sound = tmp;
    }
    else desc = (string)env->GetShort();
    if(desc) message("room_description", desc, this_object());
    if(smell) message("smell", smell, this_object());
    if(sound) message("sound", sound, this_object());
    mp = ([]);
    shorts = map(filter(all_inventory(env), 
      (: !living($1) && !((int)$1->GetInvis(this_object())) :)), 
      (: (string)$1->GetShort() :));
    for(i=0, maxi = sizeof(shorts); i<maxi; i++) 
      if( shorts[i] ) mp[shorts[i]]++;
    maxi = sizeof(shorts = keys(mp));
    for(i=0, desc = "%^MAGENTA%^"; i<maxi; i++) {
	if( mp[shorts[i]] < 2 ) {
	    if( !i ) desc += capitalize(shorts[i]) + "%^RESET%^MAGENTA%^";
	    else desc += shorts[i] + "%^RESET%^MAGENTA%^";
	}
	else {
	    if( !i ) desc += capitalize(consolidate(mp[shorts[i]],shorts[i])) +
	      "%^RESET%^MAGENTA%^";
	    else desc += consolidate(mp[shorts[i]], shorts[i]) +
              "%^RESET%^MAGENTA%^";
	}
	if( i == maxi - 1 ) {
	    if( maxi > 1 || mp[shorts[i]] >1 ) desc += " are here.%^RESET%^\n";
	    else desc += " is here.%^RESET%^\n";
	}
	else if( i == maxi - 2 ) desc += ", and ";
	else desc += ", ";
    }
    mp = ([]);
    obs = filter(all_inventory(env), 
      (: living($1) && !((int)$1->GetInvis(this_object())) :)) - 
      ({ this_object() });
    maxi = sizeof(shorts = map(obs, (: (string)$1->GetShort() :)));
    for(i=0; i<maxi; i++) if(shorts[i]) mp[shorts[i]]++;
    maxi = sizeof(shorts = keys(mp));
    for(i=0; i<maxi; i++) {
	if( i ) desc += "\n";
	if( mp[shorts[i]] < 2 ) 
          desc += "%^BOLD%^RED%^" +capitalize(shorts[i]) + "%^RESET%^";
	else desc += "%^BOLD%^RED%^" + 
          capitalize(consolidate(mp[shorts[i]],shorts[i]))+"%^RESET%^";
    }
    message("room_inventory", desc + "\n", this_object());
}

varargs int eventMoveLiving(mixed dest, string omsg, string imsg) {
    object prev;
    object *inv;
    string *arr;
    string chambre,going,temp1,temp2,temp3, msgclass;
    int i, illum, bzbd, adj, tmp, ret;

    prev = environment( this_object() );
    chambre = file_name(prev);
    if (stringp(dest)) {
        if(dest[0] != '/') {
            arr = explode(chambre, "/");
            dest = "/"+implode(arr[0..sizeof(arr)-2], "/")+"/"+dest;
        }
    }
    if( !eventMove(dest) ) {
        message("system","You remain where you are.", this_object());
        return 0;
    }
    inv = filter(all_inventory(prev), 
      (: (!GetInvis($1) && living($1) && ($1 != this_object())) :));
    msgclass = ((omsg && omsg != "") ? "leave" : "telout");
    if( !omsg || omsg == "" ) omsg = GetMessage(msgclass = "telout");
    else omsg = GetMessage(msgclass = "leave", omsg);
    message(msgclass, omsg, inv);
    inv = filter(all_inventory(environment()),
      (: (!GetInvis($1) && living($1) && ($1 != this_object())) :));
    if( (!imsg || imsg == "") && (!omsg || omsg == "") ) 
      imsg = GetMessage(msgclass = "telin");
    else imsg = GetMessage(msgclass = "come", imsg);
    message(msgclass, imsg, inv);
    eventDescribeEnvironment(GetBriefMode());
    return 1;
}

int eventDestruct() {
    object *inv;
    int i;

    autosave::eventDestruct();
    interface::eventDestruct();
    inv = filter(all_inventory(), (:($1 && (int)$1->CanDrop(this_object())):));
    inv->eventMove(environment());
    return object::eventDestruct();
}

int cmdQuit(string str) {
    string tmp;

    if( origin() != ORIGIN_LOCAL && ((int)master()->valid_apply( ({ GetKeyName() }) )) ) return 0;
    message("system", "Please come back another time!", this_object());
    save_player(GetKeyName());
    tmp = GetMessage("logout") || (GetName() + " is gone from this reality!");
    message("environment", tmp, environment(this_object()), ({this_object()}));
    log_file("enter", GetCapName()+" (quit): "+ctime(time())+"\n");
    message("announce", "["+GetCapName()+" quits]", filter(users(), (: archp :)));
    eventDestruct();
    return 1;
}

int GetAge() {
    int x;

    if(!interactive(this_object())) return Age;
    x = time() - LastAge;
    Age += x;
    LastAge = time();
    return Age;
}

int GetBirth() { return BirthTime; }

string query_cwd() { return interface::query_cwd(); }

void SetEmail(string str) {
    if(!((int)master()->valid_apply(({ GetKeyName() })))) return;
    Email = str;
}

string GetEmail() {
    if(!((int)master()->valid_apply(({ GetKeyName() })))) return 0;
    else return Email;
}

void SetId(string *bogus) {
    int i;

    if(UserId) return;
    if(!GetCapName()) {
        UserId = ({ GetKeyName() });
        return;
    }
    UserId = ({ GetKeyName(), lower_case(GetCapName()) });
    if((i=sizeof(bogus = explode(lower_case(GetCapName()), " "))) == 1)
        return;
    while(i--)
        if(!user_exists(bogus[i])) UserId += ({ bogus[i] });
}

string *GetId() { return UserId; }

int id(string str) {
    if(!str) return 0;
    else return member_array(lower_case(str), UserId) != -1;
}

int GetLoginTime() { return LoginTime; }

varargs string GetLong(string str) { 
    mapping counts;
    string *inv;
    int i;

    str = GetShort() + "\n";
    i = sizeof(inv = map(all_inventory(), (: (string)$1->GetShort() :)));
    counts = ([]);
    while(i--) counts[inv[i]]++;
    i = sizeof(inv = keys(counts));
    while(i--) str += consolidate(counts[inv[i]], inv[i]) + "\n";
    return str;
}

void SetKeyName(string str) {
    if( previous_object() != master() ) return;
    object::SetKeyName(str);
}

string GetKeyName() { return object::GetKeyName(); }

void SetNews(string type, int sz) { News[type] = sz; }

int GetNews(string type) { return News[type]; }

string SetPassword(string str) {
    if(!((int)master()->valid_apply(({ GetKeyName() })))) return;
    Password = str;
    save_player(GetKeyName());
    return Password;
}

string GetPassword() {
    if(!((int)master()->valid_apply(({ GetKeyName() })))) return 0;
    else return Password;
}

void SetPosition(string str) { Position = str; }

string GetPosition() { return Position; }

void SetRealName(string str) {
    if(!((int)master()->valid_apply(({ GetKeyName() })))) return;
    RealName = str;
}

string GetRealName() { return RealName; }

string GetShort() {
    string str;

    str = object::GetShort(str);
    if( !str) str = "$N the unaccomplished";
    if(strsrch(str, "$N") == -1) str = "$N";
    str = replace_string(str, "$N", GetName());
    if( interactive(this_object()) ) return str;
    else return str + " (net-dead)";
}

int SetBriefMode(int x) { return (Brief = x); }

int GetBriefMode() { return Brief; }

int SetWhereBlock() { return (WhereBlock = !WhereBlock); }

int GetWhereBlock() { return WhereBlock; }

string get_path() { 
    log_file("get_path", identify(previous_object())+"\n");
    return query_cwd();
}

void SetLastError(mapping m) {
    if (previous_object() != master()) return;
    LastError = m;
}

mapping GetLastError() {
    string caller = file_name(previous_object());
    if (caller[0..23] == "/secure/cmds/creator/dbx") return LastError;
    error("Privilege Violation: " + caller);
}

string SetCapName(string str) { 
    if( base_name(previous_object(0)) != OB_LOGIN ) return GetCapName();
    return object::SetCapName(str);
}

string GetCapName() { return object::GetCapName(); }

void move_or_destruct() {
    (eventMove(ROOM_START) || eventMove(ROOM_VOID));
}

string SetShort(string str) {
    if(strsrch(str, "$N") == -1) return GetShort();
    else return object::SetShort(str);
}

string GetName() { return object::GetName(); }

mixed *GetCommands() {
    if( !((int)master()->valid_apply( ({ GetKeyName() }))) ) return ({});
    return commands();
}