The ClanStoreRoom Snippet

Posted by AlaricX on Sat 14 Jun 2003 05:27 AM — 6 posts, 23,145 views.

#0
This snippet i installed, to make ALL clanstorerooms save, no matter if they belong to a clan or not.. the save_clan_storeroom function [or whatever it's called] above do_auction in act_obj.c, for some reason, this is probably intentional [as this is hwo the regular SMAUG code did it], but it writes

#VNUM 21496
the last object put in the room, ch->in_room->last_content, i think.. if this is not what it is, tell me
#END

but when i open the file in a text editor, it just says

#VNUM 21496
#END

no matter what objects i put in there.. [it's flagged correctly, yes]

So, i changed it so it goes through all the objects in the room and saves them with fwrite_obj, and made it display the object name with bug();, so.. it displays the name, yet the file is still blank

when i manually put objects in the file, they load just fine... it must have to do with saving.. any thoughts? if you need any code, tell me.
USA #1
Hard to offer debugging advice without actually seeing the code, so yeah, we need to see code to help you with this one.
USA #2
One thing you may want to check, is the level of the items you're dropping. I've seen some code releases in which there are checks that keep any lvl 100+ object from saving. If you're using oinvoke without the level arg, you'd be invoking them at your level which would in turn not save the item. I've also seen code that protects against this very problem, but it's worth looking at. Try invoking an item with a level arg 'oi boots 50' or buying an item and see if that makes a difference.

As Meerclar said though, posting code when you have a potential 'code' problem is always a wise idea ;-) Just seems logical..

A note on why it saves with in_room->last_content.. The reason it does that, is because it SHOULD check to see if the object should be saved as it's dropped. So when you drop an object it's going to be last_content no matter what. This is smart thinking on the smaug coders part to save the code from needing to loop un-necessarily.
Amended on Sat 14 Jun 2003 08:13 PM by Boborak
#3
it's invoked as level 65.

Default. Regular Snippet Code:

void save_clan_storeroom( CHAR_DATA *ch )
{
FILE *fp;
char filename[256];
sh_int templvl;
OBJ_DATA *contents;

if ( !ch )
{
bug ("save_clan_storeroom: Null ch pointer!", 0);
return;
}

sprintf( filename, "%s%d.vault", STORAGE_DIR, ch->in_room->vnum );
if ( ( fp = fopen( filename, "w" ) ) == NULL )
{
bug( "save_clan_storeroom: fopen", 0 );
perror( filename );
}
else
{
templvl = ch->level;
ch->level = LEVEL_HERO; /* make sure EQ doesn't get lost */
contents = ch->in_room->last_content;
fprintf( fp, "#VNUM %d\n", ch->in_room->vnum );
if (contents && !IS_OBJ_STAT( contents, ITEM_CLANOBJECT))
fwrite_obj(ch, contents, fp, 0, OS_CARRY, FALSE );
fprintf( fp, "#END\n" );
ch->level = templvl;
fclose( fp );
return;
}
return;
}



My Modified Version
void save_clan_storeroom( CHAR_DATA *ch )
{
FILE *fp;
char filename[256];
sh_int templvl;
OBJ_DATA *contents;

if ( !ch )
{
bug ("save_clan_storeroom: Null ch pointer!", 0);
return;
}

sprintf( filename, "%s%d.vault", STORAGE_DIR, ch->in_room->vnum );
if ( ( fp = fopen( filename, "w" ) ) == NULL )
{
bug( "save_clan_storeroom: fopen", 0 );
perror( filename );
}
else
{
OBJ_DATA *obj_next;

templvl = ch->level;
ch->level = LEVEL_HERO; /* make sure EQ doesn't get lost */
fprintf( fp, "#VNUM %d\n", ch->in_room->vnum );

for ( contents = ch->in_room->first_content; contents; contents = obj_next )
{
if(!contents)
{
obj_next = contents->next_content;
continue;
}
bug("%s", contents->name);
fwrite_obj(ch, contents, fp, 0, OS_CARRY, IS_NPC(ch) ? FALSE : ch->pcdata->hotboot );
obj_next = contents->next_content;
}

fprintf( fp, "#END\n" );
ch->level = templvl;
fclose( fp );
return;
}
return;
}

Alright then. I put the bug statement in my version to display the object. it displays the object and then.. i find a blank file, even though fwrite_obj is called...

EDIT: now that i've seen your post, boborak.. i am going back to the default code, but... it still only prints

#VNUM 21496
#END

no matter how many objects i drop or pick up, etc.
Amended on Sun 15 Jun 2003 01:49 AM by AlaricX
USA #4
Couple of things. You said it's invoked as lvl 65. Is that an immortal level?

Also, seeing your version of fwrite_obj will probably be handy. Giving a link to the SMAUG distro you downloaded would help too. That way we could see the exact code you're working with.
#5
65 is the highest immortal level, and i got my distro of SMAUG from ftpgame.org .. my fwrite_obj is not stock though.. i installed hotboot so i had to change it [oh, and i added value[6] to value[10], so that changes it a little bit. i don't think that caused it though]

I cannot paste my Fwrite_obj.. it's over 6000 chars [my whole post]