Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl, DotBot, Yandex, Google

Members: 0
Guests: 21
Stats
Files
Topics
Posts
Members
Newest Member
481
3,739
19,386
621
KellieBusb
Today's Birthdays
Rane (42)
Related Links
» SmaugMuds.org » General » Smaug Snippets » Pfile Pruning
Forum Rules | Mark all | Recent Posts

Pfile Pruning
< Newer Topic :: Older Topic > Pfile Cleaning

Pages:<< prev 1 next >>
Post is unread #1 Apr 16, 2004, 1:53 pm
Go to the top of the page
Go to the bottom of the page

RapidRunner

GroupMembers
Posts72
JoinedDec 4, 2003

heh, I've been looking through sw:fotes code, this probably isn't the place to post, but.. if i do it on mudplanet.org, no one responds.. and if i do it on swfoteforge, people will try to blame samson for shit again, don't need that bullcrap going on again.. so i'll just ask it here, since swfoteFUSS is smaug based anyways..

I'm wondering how it would be possible to make the pfile cleaning actually adjust the clans correctly.. like remove the member from the roster, then lower the members by 1..

and if the person is a leader or number1 or number2 it sets the clans leader or number1, number2 as "" instead of leaving the character in there..

Would be cool if someone could help me figure this out...

Thanks for your time, peace.
       
Post is unread #2 Apr 17, 2004, 1:03 am   Last edited Nov 24, 2007, 2:55 pm by Samson
Go to the top of the page
Go to the bottom of the page

Greven
Magician
GroupMembers
Posts204
JoinedMar 5, 2005

Its not hard at all, I'll demonstrate. In fread_pfile, modify the clan bit to this:
                                if (clan != NULL)
                                {
                                        CLAN_DATA *guild = get_clan(clan);

                                        if (guild != NULL)
                                        {
                                                if (!str_cmp
                                                    (name, guild->leader))
                                                {
                                                        if (guild->leader)
                                                                STRFREE(guild->leader);
                                                        guild->leader =
                                                                STRALLOC("";);
                                                }
                                                if (!str_cmp
                                                    (name, guild->number1))
                                                {
                                                        if (guild->number1)
                                                                STRFREE(guild->number1);
                                                        guild->number1 =
                                                                STRALLOC("";);
                                                }
                                                if (!str_cmp
                                                    (name, guild->number2))
                                                {
                                                        if (guild->number2)
                                                                STRFREE(guild->number2);
                                                        guild->number2 =
                                                                STRALLOC("";);
                                                }
                                                save_clan(guild);
                                        }
                                }
This is from my modified version of both the pfile snippet and SWR, though its not FotE. I don't know how it works in FotE, but at the end of my function, I have
        if (clan != NULL)
        {
                CLAN_DATA *guild = get_clan(clan);

                if (guild != NULL)
                {
                        guild->members++;
                        save_clan(guild);
                }
        }
At the beginning of the function stack, it sets members to 0, and this will increase the members if it doesn't delete them. Hope that helps.
       
Post is unread #3 Apr 17, 2004, 3:34 pm
Go to the top of the page
Go to the bottom of the page

Greven
Magician
GroupMembers
Posts204
JoinedMar 5, 2005

Well, why is it crashing? Run it through gdb, should be all you need to find out why.

[EDIT] Why are you calling remove_member twice, one with a check, another without it? And why is FotE fully loading characters? A large waste of memory and system time.
       
Post is unread #4 Apr 18, 2004, 4:36 am
Go to the top of the page
Go to the bottom of the page

RapidRunner

GroupMembers
Posts72
JoinedDec 4, 2003

lol.. ohh.. didn't notice that..
       
Post is unread #5 Apr 19, 2004, 10:55 am
Go to the top of the page
Go to the bottom of the page

RapidRunner

GroupMembers
Posts72
JoinedDec 4, 2003

heh

It crashes upon the clan checking part, i don't really know how to fix that, my luck is bad so.. it'd be better to get help if possible.

Thanks, hope someone can help me out *begs*
       
Post is unread #6 Apr 19, 2004, 6:16 pm
Go to the top of the page
Go to the bottom of the page

Greven
Magician
GroupMembers
Posts204
JoinedMar 5, 2005

Ok, do you know how to use GDB? If not, I can give you step by step instructions. If you do, just just run it in there and see what comes up.
       
Post is unread #7 Apr 19, 2004, 7:00 pm
Go to the top of the page
Go to the bottom of the page

RapidRunner

GroupMembers
Posts72
JoinedDec 4, 2003

Umm.. of course i do, its what i practicly learned to do stuff with..

But, the core only shows the begining part of the clan code i posted above in a few posts...

heh
       
Post is unread #8 Apr 19, 2004, 7:32 pm
Go to the top of the page
Go to the bottom of the page

Greven
Magician
GroupMembers
Posts204
JoinedMar 5, 2005

I meant boot the mud in gdb, instead of the core, more useful that way.
       
Post is unread #9 Apr 23, 2004, 9:57 pm   Last edited Nov 24, 2007, 2:56 pm by Samson
Go to the top of the page
Go to the bottom of the page

RapidRunner

GroupMembers
Posts72
JoinedDec 4, 2003

This is the current code i am using..

    if ( victim->plr_home )
    {
      ROOM_INDEX_DATA *room = victim->plr_home;
      
//      STRFREE( room->name );
      room->name = STRALLOC( "An Empty Apartment" );
//      STRFREE( room->description );

 /* Strfree's were causing crashes so removed */

      room->description = STRALLOC( "" );

      REMOVE_BIT( room->room_flags , ROOM_PLR_HOME );
      SET_BIT( room->room_flags , ROOM_EMPTY_HOME );
     
      fold_area( room->area, room->area->filename, FALSE );      
    }

    if ( victim->pcdata && victim->pcdata->clan )
    {
       if(victim->pcdata->clan->shortname && victim->pcdata->clan->shortname[0] != '�')
   remove_member(victim->name, victim->pcdata->clan->shortname);

       if ( !str_cmp( victim->name, victim->pcdata->clan->leader ) )
       {
          if ( victim->pcdata->clan->number1 )
          {
             STRFREE(victim->pcdata->clan->leader);
             victim->pcdata->clan->leader = STRALLOC( victim->pcdata->clan->number1 );

             STRFREE( victim->pcdata->clan->number1 );
             victim->pcdata->clan->number1 = STRALLOC( "" );
          }
          else if ( victim->pcdata->clan->number2 )
          {
             STRFREE(victim->pcdata->clan->leader);
             victim->pcdata->clan->leader = STRALLOC( victim->pcdata->clan->number2 );

             STRFREE( victim->pcdata->clan->number2 );
             victim->pcdata->clan->number2 = STRALLOC( "" );
          }
          else
             STRFREE( victim->pcdata->clan->leader );
             victim->pcdata->clan->leader = STRALLOC( "" );
       }
       
       if ( !str_cmp( victim->name, victim->pcdata->clan->number1 ) )
       {
          if ( victim->pcdata->clan->number2 )
          {
             STRFREE(victim->pcdata->clan->number1);
             victim->pcdata->clan->number1 = STRALLOC( victim->pcdata->clan->number2 );

             STRFREE( victim->pcdata->clan->number2 );
             victim->pcdata->clan->number2 = STRALLOC( "" );
          }
          else
             STRFREE( victim->pcdata->clan->number1 );
             victim->pcdata->clan->number1 = STRALLOC( "" );
       }
       
       if ( !str_cmp( victim->name, victim->pcdata->clan->number2 ) )
       {
          STRFREE( victim->pcdata->clan->number2 );
          victim->pcdata->clan->number1 = STRALLOC( "" );
       }
       
        victim->pcdata->clan->members--;
    }


Here is a GDB log of it, ran directly from GDB

#0  0x4e068e2b in strlen () from /lib/libc.so.6
#1  0x4e039435 in vfprintf () from /lib/libc.so.6
#2  0x4e0546bc in vsprintf () from /lib/libc.so.6
#3  0x4e04176d in sprintf () from /lib/libc.so.6
#4  0x08092347 in fold_area (tarea=0x4e05e500,
    filename=0x17a85 , install=0 '�') at build.c:5729
#5  0x08181d94 in fread_pfile (fp=0x868e688, tdiff=0, fname=0xb95b6670 "../player/a/Ahriman",
    count=0 '�') at pfiles.c:318
#6  0x081824a2 in read_pfile (dirname=0xb95b76b0 "../player/a", filename=0x868f20b "Ahriman",
    count=0 '�') at pfiles.c:410
#7  0x081825e5 in pfile_scan (count=0 '�') at pfiles.c:457
#8  0x081827f2 in do_pfiles (ch=0x868df60, argument=0xb95b9425 "";) at pfiles.c:512
#9  0x080d3ff5 in interpret (ch=0x868df60, argument=0xb95b9425 "";) at interp.c:408
#10 0x080a41bf in game_loop () at comm.c:588
#11 0x080a35f8 in main (argc=2, argv=0xb95b98b4) at comm.c:257
#12 0x4e002d06 in __libc_start_main () from /lib/libc.so.6


I'm having trouble figuring this part out, its frustrating, i can't solve it

If anyone knows, or maybe could give me a suggest to how to do this, please assist, thanks.
       
Post is unread #10 Apr 25, 2004, 9:31 am   Last edited Nov 24, 2007, 2:56 pm by Samson
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,874
JoinedJul 26, 2005

I see alot of possible problems with it just simply because of where the pfile scan is done on boot up. Its done normaly before there are any rooms loaded into memory. Try this code out instead of what you have. Note that this will only work on the rooms once they have been loaded up. I suggest moving the pfile scan called in boot_db or what ever you have it in for your base to after areas (rooms) are loaded also. But just incase you should be adding checks in the code as so.
Also never use STRALLOC("";) its not considered as valid stuff in memory. So later using valgrind on it even if you are clearing the stuff like it should it would likly report it as a leak at some point.

   if ( victim->plr_home )
   {
     ROOM_INDEX_DATA *room = victim->plr_home;
     
     if(room != NULL)
     {
       if(room->name && room->name[0] != '\0')
         STRFREE( room->name );
       room->name = STRALLOC( "An Empty Apartment" );
       if(room->description && room->description[0] != '\0')
         STRFREE( room->description );
       room->description = STRALLOC( "An Empty Apartment's description" );
       REMOVE_BIT( room->room_flags , ROOM_PLR_HOME );
       SET_BIT( room->room_flags , ROOM_EMPTY_HOME );
       fold_area( room->area, room->area->filename, FALSE );      
     }
   }


As for the clan stuff i would suggest making sure that the normal pfile scan is done after clans are loaded also
       
Post is unread #11 Apr 25, 2004, 5:18 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,643
JoinedJan 1, 2002

I'm more worried about the implication of what happens between frame 5 and frame 4. Notice how it lists fold_area as one of the places it went. Why does it need to do that in fread_pfile? That doesn't make any sense.
       
Post is unread #12 Apr 25, 2004, 7:11 pm
Go to the top of the page
Go to the bottom of the page

Greven
Magician
GroupMembers
Posts204
JoinedMar 5, 2005

I beleive Rapidrunner is using swr:fote (yes?). If thats the case, then the problem is likely that someone being deleted had an apartment, and that room is being cleaned in his code due to ch->plr_home. FotE mangled your snippet, and has caused these problems.
       
Post is unread #13 Apr 25, 2004, 7:52 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,643
JoinedJan 1, 2002

Well frankly I suppose I shouldn't be surprised they mangled that. They mangeled alot of things in the code. But the deleting of the room makes sense now that you've mentioned it.
       
Pages:<< prev 1 next >>