/
mudtem/
mudtem/area/scripts/
mudtem/bin/
mudtem/log/
mudtem/player/
mudtem/slang/autoconf/
mudtem/slang/doc/
mudtem/slang/doc/OLD/help/
mudtem/slang/doc/internal/
mudtem/slang/doc/text/
mudtem/slang/doc/tm/tools/
mudtem/slang/examples/
mudtem/slang/modules/
mudtem/slang/slsh/
mudtem/slang/slsh/lib/
mudtem/slang/slsh/scripts/
mudtem/slang/src/mkfiles/
mudtem/slang/src/util/
mudtem/src/CVS/
mudtem/src/include/
mudtem/src/include/CVS/
mudtem/src/var/CVS/
/*
 * Update all objs.
 * This function is performance sensitive.
 */
void obj_update( void )
{   
    OBJ_DATA *obj;
    OBJ_DATA *obj_next;
    AFFECT_DATA *paf, *paf_next;

    for ( obj = object_list; obj != NULL; obj = obj_next )
    {
	CHAR_DATA *rch;
	char *message;
	char *mensaje = NULL;

	obj_next = obj->next;

	/* go through affects and decrement */
	for ( paf = obj->affected; paf != NULL; paf = paf_next )
	{
	    paf_next    = paf->next;
	    if ( paf->duration > 0 )
	    {
		paf->duration--;
		if (number_range(0,4) == 0 && paf->level > 0)
		  paf->level--;  /* spell strength fades with time */
	    }
	    else if ( paf->duration < 0 )
		;
	    else
	    {
		if ( paf_next == NULL
		||   paf_next->type != paf->type
		||   paf_next->duration > 0 )
		{
		    if ( paf->type > 0 && !IS_NULLSTR(skill_table[paf->type].msg_obj) )
		    {
			if (obj->carried_by != NULL)
			{
			    rch = obj->carried_by;
			    act(skill_table[paf->type].msg_obj,
				rch,obj,NULL,TO_CHAR);
			}
			if (obj->in_room != NULL 
			&& obj->in_room->people != NULL)
			{
			    rch = obj->in_room->people;
			    act(skill_table[paf->type].msg_obj,
				rch,obj,NULL,TO_ALL);
			}
		    }
		}

		affect_remove_obj( obj, paf );
	    }
	}

	if ( CAN_WEAR(obj, ITEM_TAKE)
	  && number_range(0,15) == 0
	  && obj->condition > 0
	  && (!obj->carried_by || !IS_NPC(obj->carried_by))
	  && !IS_OBJ_STAT(obj, ITEM_INVENTORY))
	{
		--obj->condition;

		switch( obj->condition )
		{
			default: mensaje = NULL;				break;
			case 75: mensaje = "$p esta en buena condicion.";	break;
			case 50: mensaje = "$p esta en regular condicion.";	break;
			case 25: mensaje = "$p esta en mala condicion.";	break;
		}

		if ( mensaje != NULL
		&&   obj->carried_by != NULL
		&&  !IS_SET(obj->carried_by->comm, COMM_CONDICION ) )
			act( mensaje, obj->carried_by, obj, NULL, TO_CHAR );
	}

	if ( (obj->timer <= 0 || --obj->timer > 0) && obj->condition > 0 )
	{
		EXIT_DATA *pExit;

		if (obj->in_room
		 && obj->in_room->sector_type == SECT_AIR
		 && IS_SET(obj->wear_flags, ITEM_TAKE)
		 && (pExit = exit_lookup(obj->in_room, DIR_DOWN))
		 && pExit->u1.to_room)
		{
			ROOM_INDEX_DATA *new_room = pExit->u1.to_room;

			if (( rch = obj->in_room->people ) != NULL )
			{
				act( "$p cae hacia abajo.", rch, obj, NULL, TO_ROOM );
				act( "$p cae hacia abajo.", rch, obj, NULL, TO_CHAR );
			}

			obj_from_room(obj);
			obj_to_room(obj, new_room);

			if (( rch = obj->in_room->people ) != NULL )
			{
				act( "$p cae desde el cielo.", rch, obj, NULL, TO_ROOM );
				act( "$p cae desde el cielo.", rch, obj, NULL, TO_CHAR );
			}
		}

		continue;
	}

	switch ( obj->item_type )
	{
	default:              message = "$p se deshace en polvo.";  break;
	case ITEM_FOUNTAIN:   message = "$p se seca.";         break;
	case ITEM_CORPSE_NPC: message = "$p se deshace en polvo."; break;
	case ITEM_CORPSE_PC:  message = "$p se deshace en polvo."; break;
	case ITEM_FOOD:       message = "$p se pudre.";        break;
	case ITEM_POTION:     message = "$p se ha evaporado.";  
								break;
	case ITEM_PORTAL:     message = "$p se desvanece."; break;
	case ITEM_CONTAINER: 
	    if (CAN_WEAR(obj,ITEM_WEAR_FLOAT))
	    {
		if (obj->contains)
		    message = "$p parpadea y desaparece, derramando sus contenidos por el suelo.";
		else
		    message = "$p parpadea y desaparece.";
	    }
	    else
		message = "$p se deshace en polvo.";
	    break;
	}

	if ( obj->carried_by != NULL )
	{
	    if (IS_NPC(obj->carried_by) 
	    &&  obj->carried_by->pIndexData->pShop != NULL)
		obj->carried_by->silver += obj->cost/5;
	    else
	    {
		act( message, obj->carried_by, obj, NULL, TO_CHAR );
		if ( obj->wear_loc == WEAR_FLOAT)
		    act(message,obj->carried_by,obj,NULL,TO_ROOM);
	    }
	}
	else if ( obj->in_room != NULL
	&&      ( rch = obj->in_room->people ) != NULL )
	{
	    if (! (obj->in_obj && obj->in_obj->pIndexData->vnum == OBJ_VNUM_PIT
		   && !CAN_WEAR(obj->in_obj,ITEM_TAKE)))
	    {
		act( message, rch, obj, NULL, TO_ROOM );
		act( message, rch, obj, NULL, TO_CHAR );
	    }
	}

	if ((obj->item_type == ITEM_CORPSE_PC || obj->wear_loc == WEAR_FLOAT)
	&&  obj->contains)
	{   /* save the contents */
	    OBJ_DATA *t_obj, *next_obj;

	    for (t_obj = obj->contains; t_obj != NULL; t_obj = next_obj)
	    {
		next_obj = t_obj->next_content;
		obj_from_obj(t_obj);

		if (obj->in_obj) /* in another object */
		    obj_to_obj(t_obj,obj->in_obj);

		else if (obj->carried_by)  /* carried */
		{
		    if (obj->wear_loc == WEAR_FLOAT)
		    {
			if (obj->carried_by->in_room == NULL)
			    extract_obj(t_obj);
			else
			    obj_to_room(t_obj,obj->carried_by->in_room);
		    }
		    else
			obj_to_char(t_obj,obj->carried_by);
		}

		else if (obj->in_room == NULL)  /* destroy it */
		    extract_obj(t_obj);

		else /* to a room */
		    obj_to_room(t_obj,obj->in_room);
	    }
	}

	extract_obj( obj );
    }

    return;
}