/
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/
/* 22-APR-94  Bannor - Added clean_up() in an effort to reduce the number
 *                       of excess objects floating around.
 */
#pragma save_binary
#include "move_failures.h"
#include "money.h"
inherit "/std/basic/light";
inherit "/std/basic/move";
/* this will also handle monetary value... */
 
static int weight;
int     value;
 
create()
{
}
 
void    adjust_weight( int w )
{
    if( environment() )
        environment()->add_weight( w );
    weight += w;
}
void    set_weight( int w )
{
    if( environment() )
        environment()->add_weight( w - weight );
    weight = w;
}
int     query_weight()
{
    return weight;
}
 
varargs int adjust_money( mixed amt, string type )
{
    if( pointerp( amt ) )
    {
        value += (int)MONEY_HAND->query_total_value( amt );
        if( value < 0 )
            value = 0;
        return value;
    }
    amt = (int)MONEY_HAND->query_total_value( ({ type, amt }) );
    value += amt;
    if( value < 0 )
        value = 0;
    return value;
}
int     adjust_value( int i )
{
    value += i;
    if( value < 0 )
        value = 0;
    return value;
}
 
mixed * query_money_array()
{
    return( mixed * )MONEY_HAND->create_money_array( value );
}
 
int     query_money( string type )
{
    int     i;
    mixed * m_a;
 
    m_a = (mixed *)MONEY_HAND->create_money_array( value );
    if( (i = member_array( type, m_a )) == -1 )
        return 0;
    return m_a[ i + 1 ];
}
 
void    set_value( int i )
{
    value = i;
}
int     query_value()
{
    return value;
}
 
move( mixed dest, mixed messout, mixed messin )
{
    int     i;
    object  from;
 
    from = environment();
    if( !dest->add_weight( weight ) )
        return MOVE_TOO_HEAVY;
    i = ::move( dest, messout, messin );
    if( i == MOVE_OK )
    {
        if( from )
        {
            from->add_weight( -weight );
            from->adjust_light( -query_light() );
        }
        if( from = environment() )
            from->adjust_light( query_light() );
    }
    else
        dest->add_weight( -weight );
    return i;
}
 
void    dest_me()
{
    if( environment() )
        environment()->add_weight( -weight );
    ::dest_me();
}
 
 
/* well, clean_up didn't work to well here, so i'll try 
   it in other places.  Bannor. */
void    xclean_up()
{
    mixed * arr;
    int     i;
    string  junk1, junk2;
 
    if( living( this_object() ) )
        return;
    if( sscanf( file_name( this_object() ), "%s#%s", junk1, junk2 ) != 2 )
        return;
    arr = deep_inventory( this_object() );
    for( i = 0; i < sizeof( arr ); i++ )
        if( interactive( arr[ i ] ) )
            return;
    arr->dest_me();
    dest_me();
}                               /* clean_up() */
 
 
mixed * query_init_data()
{
    return light ::query_init_data() +
        move ::query_init_data() +
        ({ "weight", weight, "set_weight/p/",
           "value", value, "set_value/p/" });
}