Ok, sorry.. anyway.. we have a ITEM_SAVE extra flag in our mud. It's used to
flag an item as SAVING through hotboots. Very useful for pits and corpses,
among a few other things.
functions save_pit and load pit are below. I have to be honest, I didn't
write them, they were there when I started coding our mud. So if you find a
obvious flaw, please point it out.
/* Nifty code to save objects through hotboots - I hope :) */
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 && obj->carried_by != NULL )
continue;
if ( ( obj->item_type == ITEM_CORPSE_PC
|| obj->pIndexData->vnum == OBJ_VNUM_PIT
|| IS_OBJ_STAT(obj, ITEM_SAVE) )
&& !obj->pIndexData->delete )
fwrite_obj( NULL, obj, fp, 0 );
}
fprintf( fp, "#END\n" );
fclose( fp );
return;
}
/* MUST be done after loading rooms */
void load_pit ( void )
{
FILE *fp;
OBJ_DATA *obj, *obj_next;
char buf[MSL];
int iNest;
sprintf( buf, "%sobjects.dat", DATA_DIR );
if (( fp = fopen(buf, "r")) == NULL )
{
log_string("Error: objects.dat file not found!");
return;
}
for ( iNest = 0; iNest < MAX_NEST; iNest++ )
rgObjNest[iNest] = NULL;
for ( ; ; )
{
char letter;
char *word;
letter = fread_letter( fp );
if ( letter == '*' )
{
fread_to_eol( fp );
continue;
}
if ( letter != '#' )
{
bug( "Load_pit: # not found.", 0 );
break;
}
word = fread_word( fp );
if ( !str_cmp( word, "OBJECT" ) ) fread_obj ( NULL, fp );
else if ( !str_cmp( word, "O" ) ) fread_obj ( NULL, fp );
else if ( !str_cmp( word, "END" ) ) break;
else
{
bug( "Load_pit: bad section.", 0 );
break;
}
}
fclose(fp);
for ( obj = object_list; obj != NULL; obj = obj_next )
{
obj_next = obj->next;
if ( obj->in_room == get_room_index( ROOM_VNUM_LIMBO ) )
{
if ( obj->room && obj->room != 0 )
{
obj_from_room( obj );
obj_to_room( obj, get_room_index( obj->room ) );
obj->room = 0;
}
else
extract_obj( obj );
}
}
return;
}
- Valnir
----- Original Message -----
From: "Davion Kalhen" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, November 08, 2004 7:38 PM
Subject: Re: Object Duplication.
ITEM_SAVE isn't a stock ROM item flag, infact, I've never heard of it.
If you can point us in a direction of a snippet or some such or post
your saving/loading code here, it would be appreciated so we can help
you get to the bottom of this problem :) Untill then, happy hunting :)
Davion
On Mon, 8 Nov 2004 13:46:49 -0500, Valnir <[EMAIL PROTECTED]>
wrote:
I am having an interesting problem. Maybe someone else has run into it
already. Objects that are marked obj->extra_flags = ITEM_SAVE have a
tendency to duplicate themselves on hotboot/reboot/crash reboot.
It has happened a few times with our Pits, but more often with items that
are NOT containers. Any thoughts would be great. This has on rare
occurrence
gone into a replication that just KILLS the objects.dat file and the file
has to be purged.
- Valnir
--
ROM mailing list
[email protected]
http://www.rom.org/cgi-bin/mailman/listinfo/rom
--
ROM mailing list
[email protected]
http://www.rom.org/cgi-bin/mailman/listinfo/rom