/
LIB3/
LIB3/D/ADMIN/
LIB3/D/ADMIN/OBJ/
LIB3/D/ADMIN/ROOM/W/
LIB3/D/HOME/
LIB3/D/HOME/CITY/ARENA/
LIB3/D/HOME/CITY/ITEMS/
LIB3/D/HOME/CITY/POSTOFFI/
LIB3/DOC/
LIB3/GLOBAL/SPECIAL/
LIB3/GLOBAL/VIRTUAL/
LIB3/NET/
LIB3/NET/CONFIG/
LIB3/NET/DAEMON/CHARS/
LIB3/NET/GOPHER/
LIB3/NET/INHERIT/
LIB3/NET/OBJ/
LIB3/NET/SAVE/
LIB3/NET/VIRTUAL/
LIB3/OBJ/B_DAY/
LIB3/OBJ/HANDLERS/TERM_TYP/
LIB3/PLAYERS/B/
LIB3/PLAYERS/N/
LIB3/ROOM/
LIB3/SAVE/
LIB3/SAVE/BOARDS/
LIB3/SAVE/ENVIRON/
LIB3/SAVE/POST/
LIB3/STD/COMMANDS/SHADOWS/
LIB3/STD/CREATOR/
LIB3/STD/DOM/
LIB3/STD/EFFECTS/
LIB3/STD/EFFECTS/HEALING/
LIB3/STD/EFFECTS/OTHER/
LIB3/STD/EFFECTS/POISONS/
LIB3/STD/ENVIRON/
LIB3/STD/GUILDS/
LIB3/STD/LIQUIDS/
LIB3/STD/ROOM/
LIB3/STD/TRIGGER/SHADOW/
LIB3/W/
LIB3/W/BANNOR/
LIB3/W/NEWSTYLE/
/*
* 31-OCT-93 Bannor - added #pragma save_binary
*
* 04-DEC-93 Bannor - Fixed formatting, corrected invis bug that would only
*                    allow normal invis.
* 22-MAR-94 Bannor - Added query_prevent_shadow() to return 1.  This is
*                    a quick fix while all the lord+ functions get nomasked.
*/
#pragma save_binary
#include "mail.h"

inherit "/global/wiz_file_comm";

#define COL "%^CYAN%^"
#define CREGRADEOBJ "/obj/handlers/cregrade"

string *allowed;

nomask query_prevent_shadow() { return 1; }

void    create()
{
   ::create();
   allowed = ({ });
}/* create() */

void    move_player_to_start( string bong, int bing, string c_name )
{
   ::move_player_to_start( bong, bing, c_name );
   if( file_size( "/log/COMPLAINTS" ) != -1 )
      tell_object( this_object(), "Complaints have been made. Please check /log/COMPLAINTS.\n" );
   if( query_invis() )
      tell_object( this_object(), "===> You are currently INVISIBLE! <===\n" );
   add_action( "visible", "vis*ible" );
   add_action( "invisible", "invis*ible" );
   add_action( "promote", "promote" );
   add_action( "do_demote", "demote" );
   add_action( "new_domain", "new_domain" );
   add_action( "do_heart_beat", "heart_beat" );
   add_action( "do_allow", "allow" );
   add_action( "do_disallow", "disallow" );
   add_action( "do_info", "dinfo" );
   add_action( "do_mail", "mail" );
   add_action( "remote_inventory", "ri*nventory" );
   add_action( "remote_clone", "rcl*one" );
   add_action( "remote_dest", "rde*st" );
   add_action( "do_sponsor", "sponsor" );
   add_action( "do_grade", "grade" );
   add_action("do_collect_parcel", "collect");
   add_action("do_send_parcel", "send");
   add_action("add_title", "title");
   add_action("remove_title", "untitle");
   add_action("query_titles", "titles");
}

int add_title(string str)
{
   string name, title;
   
   if(this_player(1) != this_player()) return 0;
   if(!str || sscanf(str, "%s %s", name, title) != 2)
      {
      notify_fail("Useage : "+query_verb()+" <person> <title>\n");
      return 0;
   }
   return (int)CREGRADEOBJ->add_title(name, title);
}

int remove_title(string str)
{
   string name, title;
   int num;
   
   if(this_player(1) != this_player()) return 0;
   notify_fail("Useage : "+query_verb()+" <person> <number/title>\n");
   if(!str) return 0;
   
   if(sscanf(str, "%s %d", name, num) == 2)
      return (int)CREGRADEOBJ->remove_title(name, num);
   if(sscanf(str, "%s %s", name, title) == 2)
      return (int)CREGRADEOBJ->remove_title(name, title);
   return 0;
}

int query_titles(string str)
{
   string *titles;
   
   if(!str)
      {
      notify_fail("Useage : "+query_verb()+" <person>\n");
      return 0;
   }
   titles = CREGRADEOBJ->query_titles(str);
   if(!titles || !sizeof(titles))
      {
      if("/secure/login"->test_user(str))
         notify_fail(capitalize(str)+" has no titles.\n");
      else
         notify_fail("No such person as "+capitalize(str)+".\n");
      return 0;
   }
   printf( "%#-*s\n", ( int ) this_player()->query_cols() - 2,
           implode( titles, "\n")  );
   return 1;
}

int do_collect_parcel()
{
   return (int)PARCEL_OFFICE->collect_parcel();
}

int do_send_parcel(string s)
{
   return (int)PARCEL_OFFICE->send_parcel(s);
}

int     do_grade( string str )
{
   string  name;
   int     score;
   
   notify_fail( "Useage : grade <creator> [+/-][score]\n" );
   if( !str )
      return 0;
   str = lower_case( str );
   if( sscanf( str, "%s +%d", name, score ) == 2 )
      return( int ) CREGRADEOBJ->adjust_cre_grade( name, score );
   
   if( sscanf( str, "%s -%d", name, score ) == 2 )
      return( int ) CREGRADEOBJ->adjust_cre_grade( name, -score );
   
   if( sscanf( str, "%s %d", name, score ) == 2 )
      return( int ) CREGRADEOBJ->set_cre_grade( name, score );
   
   if( "/secure/login"->test_creator( str ) )
      {
      write( capitalize( str ) + " has " + CREGRADEOBJ->query_cre_grade( str ) +
         " creator-points.\n" );
      return 1;
   }
   return 0;
}

int     do_sponsor( string str )
{
   string  spon;
   
   notify_fail( "Useage: sponsor <creator> [sponsor]\n" );
   if( !str )
      return 0;
   if( sscanf( str, "%s %s", str, spon ) != 2 )
      {
      write( capitalize( str ) + "'s sponsor is : " +
         capitalize( (string)CREGRADEOBJ->query_sponsor( str ) ) + ".\n" );
      return 1;
   }
   return( int ) CREGRADEOBJ->set_sponsor( str, spon );
}

string short( int dark )
{
   if( query_invis() == 2 )
      return 0;
   if( query_verb() == "dest" )
      return "" + this_object();
   if( query_invis() )
      if( !this_player() || this_player()->query_creator() )
      return ::short( dark ) + " (invis)";
   
   else
      return 0;
   else
      return ::short( dark );
   
   return 0;
}

string long( string name, int dark )
{
   if( query_invis() )
      return 0;
   else
      return ::long( name, dark );
}

static int visible()
{
   if( !query_invis() )
      {
      notify_fail( "You are already visible.\n" );
      return 0;
   }
   write( "You appear.\n" );
   invis = 0;
   return 1;
}

static int invisible( string str )
{
   notify_fail( "Useage: invis <normal/super>.\n" );
   if( !str )
      return 0;
   if( str == "super" )
      {
      write( COL + "You go super-invisible.%^RESET%^\n" );
      invis = 2;
      return 1;
   }
   else
      {
      write( COL + "You go normal-invisible.%^RESET%^\n" );
      invis = 1;
      return 1;
   }
}/* invisible() */

nomask int query_creator()
{
   return 1;
}

nomask int query_wizard()
{
   return 1;
}

nomask int query_lord()
{
   return( int ) "/secure/master"->
   query_lord( this_object()->query_name() );
}

static int promote( string str )
{
   if( this_player( 1 ) != this_object() )
      return 1;
   if( !str )
      {
      notify_fail( "Usage: promote <person>\n" );
      return 0;
   }
   return( int ) "/secure/master"->create_creator( str );
}

static int do_demote( string str )
{
   if( this_player( 1 ) != this_player() )
      return 0;
   if( !str )
      {
      notify_fail( "Syntax: demote <person> <reason>\n" );
      return 0;
   }
   CREGRADEOBJ->kill_creator( str );
   return( int ) "/secure/master"->demote_creator( str );
}

static int new_domain( string str )
{
   string  s1, s2;
   
   if( this_player( 1 ) != this_object() )
      return 1;
   notify_fail( "Usage: new_domain <domain> <lord>\n" );
   if( !str )
      return 0;
   if( sscanf( str, "%s %s", s1, s2 ) != 2 )
      return 0;
   return( int ) "/secure/master"->create_domain( s1, s2 );
}

nomask int query_creator_playing()
{
   return 0;
}

string *parse_command_id_list()
{
   if( query_invis() == 2 )
      return({ });
   return ::parse_command_id_list();
}

string *parse_command_adjectiv_id_list()
{
   if( query_invis() == 2 )
      return({ });
   return ::parse_command_adjectiv_id_list();
}

string *parse_command_plural_id_list()
{
   if( query_invis() == 2 )
      return({ });
   return ::parse_command_plural_id_list();
}

nomask string query_object_type()
{
   if( "/secure/master"->high_programmer( geteuid( this_object() ) ) )
      return "H";
   else
      return "L";
}/* query_object_type() */

void    event_enter( object me, string s1, object from )
{
   if( (!s1 || s1 == "") && me && interactive( me ) )
      {
      if( environment() == environment( me ) )
         event_inform( me, me->query_cap_name() +
         " invisibly enters the room", "enter" );
      else
         event_inform( me, me->query_cap_name() +
         " invisibly enters your inventory", "enter" );
   }
   ::event_enter( me, s1, from );
}/* event_enter() */

void    event_exit( object me, string s1, object from )
{
   if( (!s1 || s1 == "") && interactive( me ) )
      {
      if( environment() == environment( me ) )
         event_inform( me, me->query_cap_name() +
         " invisibly exits the room", "enter" );
      else
         event_inform( me, me->query_cap_name() +
         " invisibly exits your inventory", "enter" );
   }
   ::event_exit( me, s1, from );
}/* event_exit() */

static int do_allow( string name )
{
   string *names;
   int     i;
   
   if( !name )
      {
      write( "Currently allowed people are: " + implode( allowed, ", " ) +
         "\n" );
      write( "Syntax: allow <name> [name] ...\n" );
      return 1;
   }
   names = explode( name, " " );
   for( i = 0; i < sizeof( names ); i++ )
   {
      if( member_array( names[ i ], allowed ) != -1 )
         {
         write( "User " + names[ i ] +
            " is already on the allowed array.\n" );
         names = delete( names, i, 1 );
         i--;
         continue;
       }
      if( !"/secure/login"->test_user( names[ i ] ) )
         {
         write( "User " + names[ i ] + " does not exist.\n" );
         names = delete( names, i, 1 );
         i--;
       }
   }
   if( !sizeof( names ) )
      write( "No one is added.\n" );
   else
      write( implode( names, ", " ) +
      " have been added to the allowed array.\n" );
   allowed += names;
   return 1;
}/* do_allow() */

static int do_disallow( string name )
{
   string *names;
   int     i;
   
   if( !name )
      {
      notify_fail( "Syntax: disallow <name> [name] ...\n" );
      return 0;
   }
   names = explode( name, " " );
   for( i = 0; i < sizeof( names ); i++ )
   if( member_array( names[ i ], allowed ) == -1 )
      {
      write( "User " + names[ i ] + " was in the allowed array.\n" );
      names = delete( names, i, 1 );
      i--;
   }
   if( !sizeof( names ) )
      write( "No one removed from the array.\n" );
   else
      write( implode( names, ", " ) +
      " has been removed from the allowed array.\n" );
   allowed = allowed - names;
   return 1;
}/* do_disallow() */

string *query_allowed()
{
   return allowed;
}

void    dest_me()
{
   if( this_player() && this_player() != this_object() )
      {
      event( users(), "inform", this_player()->query_cap_name() +
         " dests " + this_object()->query_cap_name(), "dest" );
      tell_object( this_object(), "You were dested by " +
         this_player()->query_cap_name() + ".\n" );
   }
   ::dest_me();
}/* dest_me() */

int     do_mail( string str )
{
   return( int ) "/obj/handlers/mail_track"->mail( str );
}/* do_mail() */

int     do_info( string str )
{
   string *creators, *domains, *mem, *cre_not, bit;
   mapping no_dir, not_creator;
   int     i, j, cols;
   
   cols = (int)this_player()->query_cols();
   creators = get_dir( "/w/" );
   domains = get_dir( "/d/" );
   no_dir = ([ ]);
   not_creator = ([ ]);
   cre_not = ({ });
   for( i = 0; i < sizeof( creators ); i++ )
   if( file_size( "/w/" + creators[ i ] ) != -2 )
      {
      creators = delete( creators, i, 1 );
      i--;
   }
   else
      if( !"/secure/login"->test_creator( creators[ i ] ) )
      {
      cre_not += ({ creators[ i ] });
      creators = delete( creators, i, 1 );
      i--;
   }
   for( i = 0; i < sizeof( domains ); i++ )
   {
      mem = (string *)("/d/" + domains[ i ] + "/master")->query_members() +
      ({ (string *)("/d/" + domains[ i ] +
               "/master")->query_lord() });
      creators -= mem;
      for( j = 0; j < sizeof( mem ); j++ )
      {
         if( file_size( "/w/" + mem[ j ] ) != -2 )
            no_dir[ mem[ j ] ] = domains[ i ];
         if( !"/secure/login"->test_creator( mem[ j ] ) )
            not_creator[ mem[ j ] ] = domains[ i ];
       }
      bit = "Members of " + domains[ i ] + " are: ";
      printf( "%s%-=*s\n", bit, cols - strlen( bit ), implode( mem, ", " ) +
         "." );
   }
   if( sizeof( no_dir ) )
      {
      write( "These creators are in domains but do not have a directory:\n" );
      printf( "    %-=*s", cols - 5, implode( keys( no_dir ), ", " ) + ".\n" );
   }
   if( sizeof( not_creator ) )
      {
      write( "These creators are in domains but are not actually creators:\n" );
      printf( "    %-=*s", cols - 5, implode( keys( not_creator ), ", " ) +
         ".\n" );
   }
   if( sizeof( creators ) )
      {
      write( "These creators are not in any domain:\n" );
      printf( "    %-=*s", cols - 5, implode( creators, ", " ) + ".\n" );
   }
   if( sizeof( cre_not ) )
      {
      write( "These creators have a directory, but are not creators...:\n" );
      printf( "    %-=*s", cols - 5, implode( cre_not, ", " ) + ".\n" );
   }
   return 1;
}/* do_info() */


int     remote_inventory( string str )
{
   object  who_from, *r_inv;
   int     i;
   
   if( !(who_from = find_living( lower_case( str ) )) )
      {
      notify_fail( capitalize( str ) + " not found.\n" );
      return 0;
   }
   r_inv = all_inventory( who_from );
   write( capitalize( str ) + " is carrying :-\n\n" );
   for( i = 0; i < sizeof( r_inv ); i++ )
   write( i + " -- " + r_inv[ i ]->short()
      + " -- " + file_name( r_inv[ i ] ) + "\n" );
   
   return 1;
}/* remote_inventory() */

int     remote_clone( string str )
{
   string *argv;
   object  who_from, what, *r_inv;
   int     i;
   
   if( !str )
      {
      notify_fail( " rclone <living thing> <objectname>.\n" );
      return 0;
   }
   argv = explode( str, " " );
   if( sizeof( argv ) == 1 )
      {
      argv[ 1 ] = argv[ 0 ];
      argv[ 0 ] = lower_case( (string)this_object()->query_name() );
   }
   if( !(who_from = find_living( lower_case( argv[ 0 ] ) )) )
      {
      notify_fail( capitalize( argv[ 0 ] ) + " not found.\n" );
      return 0;
   }
   if( !(who_from = find_living( lower_case( argv[ 0 ] ) )) )
      {
      notify_fail( capitalize( argv[ 0 ] ) + " not found.\n" );
      return 0;
   }
   r_inv = all_inventory( who_from );
   for( i = 0; i < sizeof( r_inv ); i++ )
   if( r_inv[ i ]->id( argv[ 1 ] ) )
      what = r_inv[ i ];
   if( !what )
      {
      notify_fail( "Object " + argv[ 1 ] + " not found in "
            + who_from->query_cap_name() + ".\n" );
      return 0;
   }
   write( capitalize( (string)what->short() ) + " cloned from  "
      + who_from->query_cap_name() + ".\n" );
   
   clone_object( explode( file_name( what ), "#" )[ 0 ] )->move( this_player() );
   return 1;
}/* remote_clone() */

int     remote_dest( string str )
{
   string *argv;
   object  who_from, what, *r_inv;
   int     i;
   
   if( !str )
      {
      notify_fail( " rdest <living thing> <objectname>.\n" );
      return 0;
   }
   argv = explode( str, " " );
   if( sizeof( argv ) == 1 )
      {
      argv[ 1 ] = argv[ 0 ];
      argv[ 0 ] = lower_case( (string)this_object()->query_name() );
   }
   if( !(who_from = find_living( lower_case( argv[ 0 ] ) )) )
      {
      notify_fail( capitalize( argv[ 0 ] ) + " not found.\n" );
      return 0;
   }
   r_inv = all_inventory( who_from );
   for( i = 0; i < sizeof( r_inv ); i++ )
   if( r_inv[ i ]->id( argv[ 1 ] ) )
      what = r_inv[ i ];
   if( !what )
      {
      notify_fail( "Object " + argv[ 1 ] + " not found in "
            + who_from->query_cap_name() + ".\n" );
      return 0;
   }
   write( capitalize( (string)what->short() ) + " dested from  "
      + who_from->query_cap_name() + ".\n" );
   
   what->dest_me();
   return 1;
}/* remote_dest() */