Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
auth_update crash
Dec 23, 2017, 10:15 pm
By Remcon
check_tumble
Dec 18, 2017, 7:21 pm
By Remcon
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, Google

Members: 0
Guests: 6
Stats
Files
Topics
Posts
Members
Newest Member
478
3,708
19,242
612
Jacki72H
Today's Birthdays
Evoru (32)
Related Links
» SmaugMuds.org » General » Smaug Snippets » Clan Roster Snippet Question
Forum Rules | Mark all | Recent Posts

Clan Roster Snippet Question
< Newer Topic :: Older Topic > Names move around...

Pages:<< prev 1, 2 next >>
Post is unread #21 Apr 3, 2005, 11:45 am
Go to the top of the page
Go to the bottom of the page

Xorith
The Null Value
GroupAFKMud Team
Posts254
JoinedFeb 23, 2003

Ah, I read it wrong. I was thinking it was writing out a buffer created by the previous code lines. My bad.
       
Post is unread #22 Sep 5, 2005, 6:03 pm
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

Gonna bring this up again. I'm still having issues with rosters clearing on hotboot. And I think I found the problem. The snippet says:
   Change that to read as follows:

         word = fread_word( fp );
         if( !str_cmp( word, "CLAN" ) )
            fread_clan( clan, fp );
         else if( !str_cmp( word, "ROSTER" ) )
            fread_memberlist( clan, fp );
         else if( !str_cmp( word, "END" ) )
            break;
         else
         {
            bug( "%s: bad section: %s.", __FUNCTION__, word );
            break;
         }


So if the word is END, it stops loading. But...
   Below the "End" line, add the following:

      fwrite_memberlist( fp, clan );

The code will stop loading at the END line.
       
Post is unread #23 Sep 5, 2005, 7:55 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

This is the entire save_clan function I now have, and it works fine, never had issue with it. If yours isn't setup in a similar manner, you placed the call wrong:

/*
 * Save a clan's data to its data file
 */
void save_clan( clan_data * clan )
{
   FILE *fp;
   char filename[256];

   if( !clan )
   {
      bug( "%s: null clan pointer!", __FUNCTION__ );
      return;
   }

   if( !clan->filename || clan->filename[0] == '\0' )
   {
      bug( "save_clan: %s has no filename", clan->name );
      return;
   }

   snprintf( filename, 256, "%s%s", CLAN_DIR, clan->filename );

   if( !( fp = fopen( filename, "w" ) ) )
   {
      bug( "%s", "save_clan: fopen" );
      perror( filename );
   }
   else
   {
      fprintf( fp, "%s", "#CLAN\n" );
      fprintf( fp, "Name         %s~\n", clan->name );
      fprintf( fp, "Filename     %s~\n", clan->filename );
      fprintf( fp, "Motto        %s~\n", clan->motto );
      fprintf( fp, "Description  %s~\n", clan->clandesc );
      fprintf( fp, "Deity        %s~\n", clan->deity );
      fprintf( fp, "Leader       %s~\n", clan->leader );
      fprintf( fp, "NumberOne    %s~\n", clan->number1 );
      fprintf( fp, "NumberTwo    %s~\n", clan->number2 );
      fprintf( fp, "Badge        %s~\n", clan->badge );
      fprintf( fp, "Leadrank     %s~\n", clan->leadrank );
      fprintf( fp, "Onerank      %s~\n", clan->onerank );
      fprintf( fp, "Tworank      %s~\n", clan->tworank );
      fprintf( fp, "PKills       %d %d %d %d %d %d %d %d %d %d\n",
               clan->pkills[0], clan->pkills[1], clan->pkills[2],
               clan->pkills[3], clan->pkills[4], clan->pkills[5],
               clan->pkills[6], clan->pkills[7], clan->pkills[8], clan->pkills[9] );
      fprintf( fp, "PDeaths      %d %d %d %d %d %d %d %d %d %d\n",
               clan->pdeaths[0], clan->pdeaths[1], clan->pdeaths[2],
               clan->pdeaths[3], clan->pdeaths[4], clan->pdeaths[5],
               clan->pdeaths[6], clan->pdeaths[7], clan->pdeaths[8], clan->pdeaths[9] );
      fprintf( fp, "MKills       %d\n", clan->mkills );
      fprintf( fp, "MDeaths      %d\n", clan->mdeaths );
      fprintf( fp, "IllegalPK    %d\n", clan->illegal_pk );
      fprintf( fp, "Score        %d\n", clan->score );
      fprintf( fp, "Type         %d\n", clan->clan_type );
      fprintf( fp, "Class        %d\n", clan->Class );
      fprintf( fp, "Favour       %d\n", clan->favour );
      fprintf( fp, "Strikes      %d\n", clan->strikes );
      fprintf( fp, "Members      %d\n", clan->members );
      fprintf( fp, "MemLimit     %d\n", clan->mem_limit );
      fprintf( fp, "Alignment    %d\n", clan->alignment );
      fprintf( fp, "Board        %d\n", clan->board );
      fprintf( fp, "ClanObjOne   %d\n", clan->clanobj1 );
      fprintf( fp, "ClanObjTwo   %d\n", clan->clanobj2 );
      fprintf( fp, "ClanObjThree %d\n", clan->clanobj3 );
      fprintf( fp, "ClanObjFour  %d\n", clan->clanobj4 );
      fprintf( fp, "ClanObjFive  %d\n", clan->clanobj5 );
      fprintf( fp, "Recall       %d\n", clan->recall );
      fprintf( fp, "Storeroom    %d\n", clan->storeroom );
      fprintf( fp, "GuardOne     %d\n", clan->guard1 );
      fprintf( fp, "GuardTwo     %d\n", clan->guard2 );
      fprintf( fp, "Tithe	   %d\n", clan->tithe );
      fprintf( fp, "Balance	   %d\n", clan->balance );
      fprintf( fp, "Idmob	   %d\n", clan->idmob );
      fprintf( fp, "Inn		   %d\n", clan->inn );
      fprintf( fp, "Shopkeeper   %d\n", clan->shopkeeper );
      fprintf( fp, "Auction	   %d\n", clan->auction );
      fprintf( fp, "Bank	   %d\n", clan->bank );
      fprintf( fp, "Repair	   %d\n", clan->repair );
      fprintf( fp, "Forge	   %d\n", clan->forge );
      fprintf( fp, "%s", "End\n\n" );
      fwrite_memberlist( fp, clan );
      fprintf( fp, "%s", "#END\n" );
   }
   FCLOSE( fp );
   return;
}
       
Post is unread #24 Sep 5, 2005, 8:05 pm   Last edited Sep 5, 2005, 8:07 pm by Zeno
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

This is my save_clan, which still doesn't work.
/*
 * Save a clan's data to its data file
 */
void save_clan( CLAN_DATA *clan )
{
   FILE *fp;
   char filename[256];

   if( !clan )
   {
      bug( "%s: null clan pointer!", __FUNCTION__ );
      return;
   }

   if( !clan->filename || clan->filename[0] == '\0' )
   {
      bug( "save_clan: %s has no filename", clan->name );
      return;
   }

   snprintf( filename, 256, "%s%s", CLAN_DIR, clan->filename );

   if( !( fp = fopen( filename, "w" ) ) )
   {
      bug( "%s", "save_clan: fopen" );
      perror( filename );
   }
   else
   {
        fprintf( fp, "#CLAN\n" );
        fprintf( fp, "Name         %s~\n",      clan->name              );
        fprintf( fp, "Filename     %s~\n",      clan->filename          );
        fprintf( fp, "Motto        %s~\n",      clan->motto             );
        fprintf( fp, "Description  %s~\n",      clan->description       );
        fprintf( fp, "Creator      %s~\n",      clan->deity             );
        fprintf( fp, "Leader       %s~\n",      clan->leader            );
        fprintf( fp, "NumberOne    %s~\n",      clan->number1           );
        fprintf( fp, "NumberTwo    %s~\n",      clan->number2           );
        fprintf( fp, "Badge        %s~\n",      clan->badge             );
        fprintf( fp, "Leadrank     %s~\n",      clan->leadrank          );
        fprintf( fp, "Onerank      %s~\n",      clan->onerank           );
        fprintf( fp, "Tworank      %s~\n",      clan->tworank           );
        fprintf( fp, "PKillRangeNew   %d %d %d %d %d %d %d\n",
                clan->pkills[0], clan->pkills[1], clan->pkills[2],
                clan->pkills[3], clan->pkills[4], clan->pkills[5],
                clan->pkills[6]);
        fprintf( fp, "PDeathRangeNew  %d %d %d %d %d %d %d\n",
                clan->pdeaths[0], clan->pdeaths[1], clan->pdeaths[2],
                clan->pdeaths[3], clan->pdeaths[4], clan->pdeaths[5],
                clan->pdeaths[6]);
        fprintf( fp, "MKills       %d\n",       clan->mkills            );
        fprintf( fp, "MDeaths      %d\n",       clan->mdeaths           );
        fprintf( fp, "IllegalPK    %d\n",       clan->illegal_pk        );
        fprintf( fp, "Score        %d\n",       clan->score             );
        fprintf( fp, "Type         %d\n",       clan->clan_type         );
        fprintf( fp, "Class        %d\n",       clan->class             );
        fprintf( fp, "Favour       %d\n",       clan->favour            );
        fprintf( fp, "Strikes      %d\n",       clan->strikes           );
        fprintf( fp, "Members      %d\n",       clan->members           );
        fprintf( fp, "MemLimit     %d\n",       clan->mem_limit         );
        fprintf( fp, "Alignment    %d\n",       clan->alignment         );
        fprintf( fp, "Board        %d\n",       clan->board             );
        fprintf( fp, "ClanObjOne   %d\n",       clan->clanobj1          );
        fprintf( fp, "ClanObjTwo   %d\n",       clan->clanobj2          );
        fprintf( fp, "ClanObjThree %d\n",       clan->clanobj3          );
        fprintf( fp, "ClanObjFour  %d\n",       clan->clanobj4          );
        fprintf( fp, "ClanObjFive  %d\n",       clan->clanobj5          );
        fprintf( fp, "Recall       %d\n",       clan->recall            );
        fprintf( fp, "Storeroom    %d\n",       clan->storeroom         );
        fprintf( fp, "GuardOne     %d\n",       clan->guard1            );
        fprintf( fp, "GuardTwo     %d\n",       clan->guard2            );
        fprintf( fp, "ClanID       %d\n",       clan->clanid            );
        fprintf( fp, "Allies   %d %d %d %d %d\n",
                clan->allies[0], clan->allies[1], clan->allies[2],
                clan->allies[3], clan->allies[4]);
        fprintf( fp, "AtWar    %d %d %d %d %d\n",
                clan->atwar[0], clan->atwar[1], clan->atwar[2],
                clan->atwar[3], clan->atwar[4]);
        fprintf( fp, "Funds        %d\n",       clan->funds             );
        fprintf( fp, "Inducting    %d\n",       clan->inducting         );
        fprintf( fp, "%s", "End\n\n" );
        fwrite_memberlist( fp, clan );
        fprintf( fp, "%s", "#END\n" );
    }
    fclose( fp );
    return;
}


This is the end of my load_clan_file function:
    if ( ( fp = fopen( filename, "r" ) ) != NULL )
    {

        found = TRUE;
        for ( ; ; )
        {
            char letter;
            char *word;

            letter = fread_letter( fp );
            if ( letter == '*' )
            {
                fread_to_eol( fp );
                continue;
            }

            if ( letter != '#' )
            {
                bug( "Load_clan_file: # not found.", 0 );
                break;
            }

            word = fread_word( fp );
            if ( !str_cmp( word, "CLAN" ) )
            {
                fread_clan( clan, fp );
                break;
            }
            else
            if ( !str_cmp( word, "END"  ) )
                break;
            else
            {
                char buf[MAX_STRING_LENGTH];

                sprintf( buf, "Load_clan_file: bad section: %s.", word );
                bug( buf, 0 );
                break;
            }


         word = fread_word( fp );
         if( !str_cmp( word, "CLAN" ) )
            fread_clan( clan, fp );
         else if( !str_cmp( word, "ROSTER" ) )
            fread_memberlist( clan, fp );
         else if( !str_cmp( word, "END" ) )
            break;
         else
         {
            bug( "%s: bad section: %s.", __FUNCTION__, word );
            break;
         }

        }
        fclose( fp );
    }
       
Post is unread #25 Sep 5, 2005, 8:17 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Then the only thing left I can suggest is you start filling the relevent code up with log_string statements and find out where it's failing to pick up at, because I see nothing out of line here.
       
Post is unread #26 Sep 5, 2005, 8:24 pm   Last edited Sep 5, 2005, 8:32 pm by Zeno
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

This is what happened:
Mon Sep  5 20:23:09 2005 :: shadow.cln
Mon Sep  5 20:23:09 2005 :: [*****] BUG: load_clan_file: start
Mon Sep  5 20:23:09 2005 :: [*****] BUG: load_clan_file: pre-fopen
Mon Sep  5 20:23:09 2005 :: [*****] BUG: load_clan_file: pre-for
Mon Sep  5 20:23:09 2005 :: [*****] BUG: load_clan_file: found CLAN


Here's where the bugs are:
    if ( ( fp = fopen( filename, "r" ) ) != NULL )
    {

        found = TRUE;
    bug( "load_clan_file: pre-for" );
        for ( ; ; )
        {
            char letter;
            char *word;

            letter = fread_letter( fp );
            if ( letter == '*' )
            {
                fread_to_eol( fp );
                continue;
            }

            if ( letter != '#' )
            {
                bug( "Load_clan_file: # not found.", 0 );
                break;
            }

            word = fread_word( fp );
            if ( !str_cmp( word, "CLAN" ) )
            {
                fread_clan( clan, fp );
    bug( "load_clan_file: found CLAN" );
                break;
            }
            else
            if ( !str_cmp( word, "END"  ) )
            {
            bug( "load_clan_file: found END" );
                break;
            }
            else
            {
                char buf[MAX_STRING_LENGTH];

                sprintf( buf, "Load_clan_file: bad section: %s.", word );
                bug( buf, 0 );
                break;
            }


         word = fread_word( fp );
         if( !str_cmp( word, "CLAN" ) )
        {
    bug( "load_clan_file: found CLAN2" );
            fread_clan( clan, fp );
        }
         else if( !str_cmp( word, "ROSTER" ) )
        {
    bug( "load_clan_file: found ROSTER" );
            fread_memberlist( clan, fp );
        }
         else if( !str_cmp( word, "END" ) )
        {
    bug( "load_clan_file: END2" );
            break;
        }
         else
         {
            bug( "%s: bad section: %s.", __FUNCTION__, word );
            break;
         }

        }


[EDIT] Yeah, wow I don't know how those two reads got in the loop there. Fixed.
       
Pages:<< prev 1, 2 next >>