The problem is likely in fwrite_obj.  This part:

    /*
     * Slick recursion to write lists backwards,
     *   so loading them will load in forwards order.
     */
    if ( obj->next_content != NULL )
        fwrite_obj( ch, obj->next_content, fp, iNest );

So each time you move forward in the pit and save an object, it will
be saving all the objects previous to it.

Try changing this:
if ( obj->next_content != NULL )

to this:

if ( ch && obj->next_content != NULL )

So it will only recurse if the object is on a player.

On Tue, 16 Nov 2004 17:22:59 -0700, Dale Kingston <[EMAIL PROTECTED]> wrote:
> How do you know it's in the save part? Did you open the save file and read
> it for duplicate information? Or are you taking a shot in the dark?
> 
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Valnir
> Sent: Tuesday, November 16, 2004 2:00 PM
> To: [email protected]
> Subject: Saving Objects.
> 
> Ok, again.. I asked this a few days ago.
> 
> Does anyone have any idea why my saving objects would be duplicating. I
> posted the saving code and never got any responses.
> 
> What looks like is happening is that it's not properly moving to the next
> obj while running through the list. Thoughts??
> 
> It is definitely in the SAVE part, not the load part.
> 
> Here is the save part again, let me know what any of you think. Thanks!
> 
> void save_pit ( void )
> {
>    OBJ_DATA *obj, *obj_next;
>    FILE *fp;
>    char buf[MSL];
> 
>    sprintf( buf, "%sobjects.dat", DATA_DIR );
> 
>    if ( !( fp = fopen( buf, "w+" ) ) )
>    {
>        bug( "Save objects: fopen", 0 );
>        return;
>    }
> 
>    for ( obj = object_list; obj != NULL; obj = obj_next )
>    {
>        obj_next = obj->next;
> 
>        if ( obj->carried_by != NULL || obj->pIndexData->delete )
>            continue;
> 
>        if ( obj->item_type == ITEM_CORPSE_PC
>        || obj->pIndexData->vnum == OBJ_VNUM_PIT
>        || IS_OBJ_STAT(obj, ITEM_SAVE) )
>            fwrite_obj( NULL, obj, fp, 0 );
>    }
> 
>    fprintf( fp, "#END\n" );
>    fclose( fp );
>    return;
> }
> 
> - Valnir

Reply via email to