/
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/
/*
   ** Optimesed by Newstyle, 93/12/09
 */

mapping map_nicknames;

string *query_nicknames()
{
    return map_nicknames + ({ });
}

void    nickname_commands()
{
    add_action( "delete_nickname", "dn*ickname" );
    add_action( "nickname", "ni*ckname" );
    if( !map_nicknames )
	map_nicknames = ([ ]);
}

int     add_nickname( string s1, string s2 )
{
    if( !map_nicknames[ s1 ] )
	write( s1 + " is now nicknamed as " + s2 + ".\n" );
    else
	write( "Nickname " + s1 + " changed from " + map_nicknames[ s1 ] + " to " + s2 + ".\n" );
    map_nicknames[ s1 ] = s2;
    return 1;
}

string  expand_nickname( string str )
{
    string *array;
    int     i;

    if( !str )
	return "";
    array = explode( lower_case( str ), " " );
    for( i = 0; i < sizeof( array ); i++ )
	if( map_nicknames[ array[ i ] ] )
	    array[ i ] = map_nicknames[ array[ i ] ];
    return implode( array, " " );
}

int     delete_nickname( string str )
{
    if( !map_nicknames[ str ] )
    {
	notify_fail( "That nickname does not exist.\n" );
	return 0;
    }
    map_nicknames = m_delete( map_nicknames, str );
    write( "Deleted nickname : " + str + "\n" );
    return 1;
}

int     print_nicknames()
{
    int     i, cols;
    string  str, str1, str2, *tmp;

    str1 = str2 = "";
    if( !sizeof( map_nicknames ) )
    {
	write( "You have no nicknames defined.\n" );
	return 1;
    }
    tmp = m_indices( map_nicknames );
    cols = (int)this_player()->query_cols();
    for( i = 0; i < sizeof( tmp ); i++ )
    {
/* Not sure what the point of all this is .... NS, 8/12/93 */
	str = tmp[ i ] + ": " + map_nicknames[ tmp[ i ] ] + "  ";
	if( strlen( str ) > 39 )
	    printf( tmp[ i ] + ": %-=*s\n", cols - strlen( tmp[ i ] ), map_nicknames[ tmp[ i ] ] );
	else
	    if( strlen( str ) > 19 )
		str1 += str + "\n";
	    else
		str2 += str + "\n";
    }
    if( strlen( str1 ) )
	printf( "%-#*s\n", cols, str1 );
    if( strlen( str2 ) )
	printf( "%-#*s\n", cols, str2 );
    return 1;
}

int     nickname( string str )
{
    string  s1, s2;

    if( !str )
	return print_nicknames();

    if( sscanf( str, "%s %s", s1, s2 ) != 2 )
    {
	if( !map_nicknames[ s1 ] )
	{
	    notify_fail( "That nickname does not exist.\n" );
	    return 0;
	}
	write( str + " is nicknamed as " + map_nicknames[ str ] + ".\n" );
	return 1;
    }
    return add_nickname( s1, s2 );
}