/
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/
#pragma save_binary

/* code to handle forcing.   The method used will be to ask the object to
 * do the command.  While this is similar to the original method of doing this
 * it will be used to be more in the style of asking things to do things,
 * rather than the making things do things without asking them first. */

/*
   ** Optimised by Newstyle, 18/11/93
   **  - I removed a number of 'features' (bugs) too.
 */

#define FORCE_COST 1
#define ILLEGAL_FORCE ({ "alias", "unalias", "history", "finger",\
                         "mv", "cp", "mkdir", "rm", "rmdir", "cd",\
                         "grade", "sponsor", "force", "exec", "call",\
                         "promote", "demote", "new_domain",\
                         "kill", "drop", "give", "quit", "su",\
                         "shout", "echoall", "emoteall" })

static string fname;
static int no_force_me;

void    force_commands()
{
    sscanf( file_name( this_object() ), "%s#", fname );
    if( "/obj/handlers/cregrade"->
	    query_cre_grade( (string)this_object()->query_name() ) > 19 )
	add_action( "do_force", "force" );
    if( fname == "/global/lord" )
	add_action( "no_force", "noforce" );
}

static int no_force( string str )
{
    if( fname != "/global/lord" )
	return 0;
    if( str == "on" )
    {
	no_force_me = 1;
	write( "Okay, you now cannot be forced.\n" );
	return 1;
    }
    if( str == "off" )
    {
	no_force_me = 0;
	write( "Okay, you can now be forced.\n" );
	return 1;
    }
    if( no_force_me )
	write( "Forcing you is currently disabled.\n" );
    else
	write( "Forcing you is currently enabled.\n" );
    return 1;
}

int     do_force( string str )
{
    string  who, what;
    object *obs, ob;
    int     i;

    if( fname == "/global/player" && !this_player()->query_property( "force" ) )
    {
	notify_fail( "You do not have the ability to force yet.\n" );
	return 0;
    }
    if( !str || sscanf( str, "%s %s", who, what ) != 2 )
    {
	notify_fail( "Usage : force <person> <command>\n" );
	return 0;
    }
    if( this_player()->adjust_social_points( -FORCE_COST ) < 0 )
    {
	notify_fail( "Insufficient social points.\n" );
	return 0;
    }
    who = (string)this_player()->expand_nickname( who );
    who = lower_case( who );
    obs = find_match( who, environment( this_object() ) );
    if( !sizeof( obs ) )
	if( !(ob = find_living( who )) )
	{
	    notify_fail( "No such living thing.\n" );
	    return 0;
	}
	else
	    obs += ({ ob });
    for( i = 0; i < sizeof( obs ); i++ )
	if( obs[ i ]->do_force_on_me( what ) )
	    write( obs[ i ]->query_cap_name() + " forced sucessfully.\n" );
	else
	    write( obs[ i ]->query_cap_name() + " didn't want to do that.\n" );
    return 1;
}

int     do_force_on_me( string str )
{
    string  temp1, temp2;
    object  forcer;
    int     i;

    if( !(forcer = this_player( 1 )) )
	forcer = previous_object();

    for( i = 0; i < sizeof( ILLEGAL_FORCE ); i++ )
	if( ((sscanf( str, "%s" + ILLEGAL_FORCE[ i ] + "%s", temp1, temp2 ) == 2) ||
	     no_force_me) &&
		!"secure/master"->high_programmer( geteuid( forcer ) ) )
	{
	    tell_object( this_object(), forcer->query_cap_name() +
			 " fails to force you to " + str + "\n" );
	    event( users(), "inform", forcer->query_cap_name() + " forces " +
		   this_object()->query_name() + " to " + str + " (failed)", "force" );
	    log_file( "FORCE", ctime( time() ) + " " + forcer->query_name() + " " +
		      this_object()->query_name() + " : " + str + " (failed)\n" );
	    return 0;
	}
    tell_object( this_object(), forcer->query_cap_name() +
		 " forces you to " + str + "\n" );
    event( users(), "inform", forcer->query_cap_name() + " forces " +
	   this_object()->query_name() + " to " + str, "force" );
    log_file( "FORCE", ctime( time() ) + " " + forcer->query_name() + " " +
	      this_object()->query_name() + " : " + str + " (succeeded)\n" );
    command( str );
    return 1;
}