Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ The ClanStoreRoom Snippet

The ClanStoreRoom Snippet

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by AlaricX   (23 posts)  Bio
Date Sat 14 Jun 2003 05:27 AM (UTC)
Message
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.
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #1 on Sat 14 Jun 2003 06:21 PM (UTC)
Message
Hard to offer debugging advice without actually seeing the code, so yeah, we need to see code to help you with this one.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by Boborak   USA  (228 posts)  Bio
Date Reply #2 on Sat 14 Jun 2003 08:10 PM (UTC)

Amended on Sat 14 Jun 2003 08:13 PM (UTC) by Boborak

Message
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.
Top

Posted by AlaricX   (23 posts)  Bio
Date Reply #3 on Sat 14 Jun 2003 09:57 PM (UTC)

Amended on Sun 15 Jun 2003 01:49 AM (UTC) by AlaricX

Message
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.
Top

Posted by Boborak   USA  (228 posts)  Bio
Date Reply #4 on Mon 16 Jun 2003 05:25 PM (UTC)
Message
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.
Top

Posted by AlaricX   (23 posts)  Bio
Date Reply #5 on Mon 16 Jun 2003 11:31 PM (UTC)

Amended on Tue 20 Nov 2007 04:25 AM (UTC) by Nick Gammon

Message
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]
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


17,825 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.