src/update.c
/*
 * Update all objs.
 * This function is performance sensitive.
 */
Update all objs.
This function is performance sensitive.
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;
	obj_next = obj->next;
        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--;  
            }
            else if ( paf->duration < 0 )
                ;
            else
            {
                if ( paf_next == NULL
                ||   paf_next->type != paf->type
                ||   paf_next->duration > 0 )
                {
                    if ( paf->type > 0 && 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 ( obj->timer <= 0 || --obj->timer > 0 )
	    continue;
	switch ( obj->item_type )
	{
	default:              message = "$p crumbles into dust.";  break;
	case ITEM_FOUNTAIN:   message = "$p dries up.";         break;
	case ITEM_CORPSE_NPC: message = "$p decays into dust."; break;
	case ITEM_CORPSE_PC:  message = "$p decays into dust."; break;
	case ITEM_FOOD:       message = "$p decomposes.";	break;
	case ITEM_POTION:     message = "$p has evaporated from disuse.";	
								break;
	case ITEM_PORTAL:     message = "$p fades out of existence."; break;
	case ITEM_CONTAINER: 
	    if (CAN_WEAR(obj,ITEM_WEAR_FLOAT))
		if (obj->contains)
		    message = 
		"$p flickers and vanishes, spilling its contents on the floor.";
		else
		    message = "$p flickers and vanishes.";
	    else
		message = "$p crumbles into dust.";
	    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)
	{   
     	    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) 
		    obj_to_obj(t_obj,obj->in_obj);
		else if (obj->carried_by)  
		    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)  
		    extract_obj(t_obj);
		else 
		    obj_to_room(t_obj,obj->in_room);
	    }
	}
	extract_obj( obj );
    }
    return;
}
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 ; obj_next = obj -> next ; 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 -- ; } else if ( paf -> duration < 0 ) ; else { if ( paf_next == NULL || paf_next -> type != paf -> type || paf_next -> duration > 0 ) { if ( paf -> type > 0 && 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 ( obj -> timer <= 0 || -- obj -> timer > 0 ) continue ; switch ( obj -> item_type ) { default : message = " " ; break ; case ITEM_FOUNTAIN : message = " " ; break ; case ITEM_CORPSE_NPC : message = " " ; break ; case ITEM_CORPSE_PC : message = " " ; break ; case ITEM_FOOD : message = " " ; break ; case ITEM_POTION : message = " " ; break ; case ITEM_PORTAL : message = " " ; break ; case ITEM_CONTAINER : if ( CAN_WEAR ( obj , ITEM_WEAR_FLOAT ) ) if ( obj -> contains ) message = " " ; else message = " " ; else message = " " ; 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 ) { 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 ) obj_to_obj ( t_obj , obj -> in_obj ) ; else if ( obj -> carried_by ) 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 ) extract_obj ( t_obj ) ; else obj_to_room ( t_obj , obj -> in_room ) ; } } extract_obj ( obj ) ; } return ; }
Update all objs.
Update all objs .
/* go through affects and decrement */ /* spell strength fades with time */ /* save the contents */ /* in another object */ /* carried */ /* destroy it */ /* to a room */