/
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/
#include "language.h"
/*
   ** Format for language parameters :
   **
   ** ([ name : ({ language_props, garble_object, language_size }) })
   **
   ** name is the name seen by players, ie
   ** "thieves cant" or "oh yes they can"
   **
   ** language props can include any or all of :
   **   L_WRITTEN  : language is writable
   **   L_SPOKEN   : language is speakable
   **   L_DISTANCE : language can be spoken at a distance
   **   L_MAGIC    : An fn is called when the language is read
   **
   ** The garble object contains the fn's :
   **  -  garble_say, garble_tell, garble_shout, & garble_written
   **     which are passed the message header, ie 'Newstyle says :', and
   **     the message body, ie "Long live the hedgehogs!", and should
   **     return a mixed object ({ header, body }) from which the
   **     message shown to people who do not know the language comes.
   **     In magic languages, these fn's are called on *all* reads,
   **     even by people with the language.
   **  -  squidge_text(mixed str, int size), called when there is
   **     not enough space to write a complete message. It should
   **     return something length size in chars.
   **
   ** The language size is inexplicable. Or should that be unspeakable?
 */

mapping languages;

void    create()
{
    languages = ([ 
  "common":	      ({ L_SPOKEN | L_WRITTEN | L_DISTANCE, "/std/languages/common", 10 }),
  "light speech":    ({ L_SPOKEN | L_WRITTEN | L_DISTANCE, "/std/languages/light_speech", 10 }),
  "dark speech":     ({ L_SPOKEN | L_WRITTEN | L_DISTANCE, "/std/languages/dark_speech", 10 }),
  "little speech":   ({ L_SPOKEN | L_WRITTEN | L_DISTANCE, "/std/languages/little_speech", 5 }),
  "thieves cant":    ({ L_SPOKEN, "/std/languages/cant", 20 }),
  "grunt":	      ({ L_SPOKEN, "/std/languages/grunt", 2 }),
  "wizard spells":   ({ L_WRITTEN | L_MAGIC | L_SIZED, "/std/languages/wizard_lang", 20 }),
  "morse code":      ({ L_SPOKEN | L_WRITTEN | L_DISTANCE, "/w/newstyle/morse_lang", 20 }),
		       ]);
}

int     query_language_spoken( string str )
{
    if( !languages[ str ] )
	return 0;
    return languages[ str ][ 0 ] & L_SPOKEN;
}

int     query_language_written( string str )
{
    if( !languages[ str ] )
	return 0;
    return languages[ str ][ 0 ] & L_WRITTEN;
}

int     query_language_distance( string str )
{
    if( !languages[ str ] )
	return 0;
    return languages[ str ][ 0 ] & L_DISTANCE;
}

int     query_language_magic( string str )
{
    if( !languages[ str ] )
	return 0;
    return languages[ str ][ 0 ] & L_MAGIC;
}

int     query_language_size( string str )
{
    if( !languages[ str ] )
	return 0;
    return languages[ str ][ 2 ];
}

mixed   squidge_text( string lang, mixed str, int size )
{
    if( !languages[ lang ] )
	return 0;
    if( !(languages[ lang ][ 0 ] & L_MAGIC) )
	return str[ 0..(size / languages[ lang ][ 2 ]) ];
    return( mixed ) languages[ lang ][ 1 ]->squidge_text( str, size );
}

int     add_language( string name, int flags, mixed ob, int size )
{
    languages[ name ] = ({ flags, ob, size });
}

int     query_flags( string name )
{
    if( !languages[ name ] )
	return 0;
    return languages[ name ][ 0 ];
}

mixed   query_garble_object( string name )
{
    if( !languages[ name ] )
	return 0;
    return languages[ name ][ 1 ];
}

string *query_languages()
{
    return m_indices( languages );
}

int     test_language( string str )
{
    return pointerp( languages[ str ] );
}