Hi
I have been working on a clan roster code for a while now I have
used different parts of snippets from all over the place and done
alot of comparing to other functions but this seems to be one of
the hardest things of all to add and actually work right if at all.

First of all I can't decide if I should make a seperate roster_data
structure or keep it within the clan data. Second no matter what I do
I can't figure out how to remove a character from a roster list.

This is part of the get_roster function that I did not write but used
in my function its part of a snippet by Steve Boleware. The problem
with the below is that even when the member names and rank is writen
to the file it is not showing up when the command is used.
It also says that word' might be used uninitialized in this function
when I compile but so far there have been no crashes caused by this,
it just doesnt work. Below is the get_roster function

void get_roster (CHAR_DATA *ch, FILE *fp, int clan)
{
   char  b1[MSL],  b2[MSL], b3[MSL];
   char  b4[MSL],  b5[MSL], b6[MSL];
   char  b7[MSL],  b8[MSL], b9[MSL];
   char b10[MSL], buf[MSL];
   char letter;
   unsigned int c1=0,c2=0,c3=0,c4=0,c5=0,c6=0,c7=0,c8=0,c9=0,c10=0;
   bool done = FALSE;
   bool bb1=FALSE, bb2=FALSE, bb3=FALSE, bb4=FALSE, bb5=FALSE;
   bool bb6=FALSE, bb7=FALSE, bb8=FALSE, bb9=FALSE, bb10=FALSE;

   sprintf (b1, " ");
   sprintf (b2, " ");
   sprintf (b3, " ");
   sprintf (b4, " ");
   sprintf (b5, " ");
   sprintf (b6, " ");
   sprintf (b7, " ");
   sprintf (b8, " ");
   sprintf (b9, " ");
   sprintf (b10, " ");
   sprintf (buf, " ");

   letter = fread_letter( fp );

   if ( letter != '#' )
   {
       bug( "Roster_add: (#) file header not found .", 0 );
       fclose(fp);
       fpReserve = fopen( NULL_FILE, "r" );
       return;
   }

       for ( ; ; )
       {
           char *word;
           char netter; /* probably is the other way...
           char word[MSL]; */
           sprintf( word, "%s", fread_word(fp) );
               /* Lets do this a different
           word = fread_word (fp); */
           word = feof( fp ) ? "$" : fread_word( fp );

           if ( word[0] != '$' )
           {
               netter = fread_letter( fp );
               switch (netter)
               {
                   case '0':
                   {
                       if (c1 > 0)
                           sprintf (buf, ", %s",  word);
                       else
                           sprintf( buf, "%s",  word);

                       strcat (b1, buf);
                       bb1 = TRUE;
                       c1++;
                       fread_to_eol(fp);
                       break;
                   }
                   case '1':
                   {
                       if (c2 < 1)
                           sprintf (buf, "%s", word);
                       else
                           sprintf( buf, ", %s", word);

                       strcat (b2, buf);
                       c2++;
                       bb2 = TRUE;
                       fread_to_eol(fp);
                       break;
                   }
                   case '2':
                   {
                       if (c3 > 0)
                       {
                           sprintf (buf, ", %s", word);
                       }
                       else
                       {
                           sprintf( buf, "%s", word);
                       }
                       strcat (b3, buf);
                       c3++;
                       bb3 = TRUE;
                       fread_to_eol(fp);
                       break;
                   }
                   case '3':
                   {
                       if (c4 > 0)
                       {
                           sprintf (buf, ", %s", word);
                       }
                       else
                       {
                           sprintf( buf, "%s", word);
                       }
                       strcat (b4, buf);
                       c4++;
                       bb4 = TRUE;
                       fread_to_eol(fp);
                       break;
                   }
                   case '4':
                   {
                       if (c5 > 0)
                       {
                           sprintf (buf, ", %s", word);
                       }
                       else
                       {
                            sprintf( buf, "%s", word);
                       }
                       strcat (b5, buf);
                       c5++;
                       bb5 = TRUE;
                       fread_to_eol(fp);
                       break;
                   }
                   case '5':
                   {
                       if (c6 > 0)
                       {
                           sprintf (buf, ", %s", word);
                       }
                       else
                       {
                            sprintf( buf, "%s", word);
                       }
                       strcat (b6, buf);
                       c6++;
                       bb6 = TRUE;
                       fread_to_eol(fp);
                       break;
                   }
                   case '6':
                   {
                       if (c7 > 0)
                       {
                           sprintf (buf, ", %s", word);
                       }
                       else
                       {
                           sprintf( buf, "%s", word);
                       }
                       strcat (b7, buf);
                       c7++;
                       bb7 = TRUE;
                       fread_to_eol(fp);
                       break;
                   }
                   case '7':
                   {
                       if (c8 > 0)
                       {
                           sprintf (buf, ", %s", word);
                       }
                       else
                       {
                           sprintf( buf, "%s", word);
                       }
                       strcat (b8, buf);
                       c8++;
                       bb8 = TRUE;
                       fread_to_eol(fp);
                       break;
                   }
                   case '8':
                   {
                       if (c9 > 0)
                       {
                           sprintf (buf, ", %s", word);
                       }
                       else
                       {
                           sprintf( buf, "%s", word);
                       }
                       strcat (b9, buf);
                       c9++;
                       bb9 = TRUE;
                       fread_to_eol(fp);
                       break;
                   }
                   case '9':
                   {
                       if (c10 > 0)
                       {
                           sprintf (buf, ", %s", word);
                       }
                       else
                       {
                           sprintf( buf, "%s", word);
                       }
                       strcat (b10, buf);
                       c10++;
                       bb10 = TRUE;
                       fread_to_eol(fp);
                       break;
                   }
                   default:
                   {
                       done = TRUE;
                       fread_to_eol(fp);
                       break;
                   }
               }//end of switch-SB
           }//end of word[0] check (check if not $)-SB
           else
           {
               done = TRUE;
               fread_to_eol(fp);
               fclose (fp);
           }

           if (done)
           {
               break;
           }
       }/* end of for loop-SB */

       sprintf (buf, "{RClan data for{x %s:{w\n\r",
           clan_table[clan].who_name);

       if (bb1 == TRUE)
       {
           strcat (buf, "{GLeaders:{W           [{C1{W]{w\n\r");
           strcat (buf, b1);
       }
       if (bb2 == TRUE)
       {
           strcat (buf, "\n\r{GDeputies:{W          [{C2{W]{w\n\r");
           strcat (buf, b2);
       }
       if (bb3 == TRUE)
       {
           strcat (buf, "\n\r{GPrinces:          {W [{C3{W]{w\n\r");
           strcat (buf, b3);
       }
       if (bb4 == TRUE)
       {
           strcat (buf, "\n\r{GSergeants:        {W [{C4{W]{w\n\r");
           strcat (buf, b4);
       }
       if (bb5 == TRUE)
       {
           strcat (buf, "\n\r{GCouncil Members:  {W [{C5{W]{w\n\r");
           strcat (buf, b5);
       }
       if (bb6 == TRUE)
       {
           strcat (buf, "\n\r{GHonorable Members:{W [{C6{W]{w\n\r");
           strcat (buf, b6);
       }
       if (bb7 == TRUE)
       {
           strcat (buf, "\n\r{GMembers:{W           [{C7{W]{w\n\r");
           strcat (buf, b7);
       }
       if (bb8 == TRUE)
       {
           strcat (buf, "\n\r{GCommoners:{W         [{C8{W]{w\n\r");
           strcat (buf, b8);
       }
       if (bb9 == TRUE)
       {
           strcat (buf, "\n\r{GInitiates:{W         [{C9{W]{w\n\r");
           strcat (buf, b9);
       }
       if (bb10 == TRUE)
       {
           strcat (buf, "\n\r{GTrainees:{W          [{C10{W]{w\n\r");
           strcat (buf, b10);
       }
       strcat (buf, "\n\r");
       page_to_char(buf, ch);

/* return; */
}


Also call me a dummy if you must but could someone explain in some
detail what the [0] in word[0] and how it works, why it causes so
many problems like pointer from integer without a cast and so on.
I never went to college so I don't know too much about code I just
know what I learned over the past several years coding.

The problem could be that the bools for bb1 bb2 ext. are returning
FALSE all the time which would cause only clan data for (clan whoname)
to show up when the roster command is used. By the way I am using
gary's clan code. I even tried messing with the worship snippet
thats on kyndig.com and that one's roster for the order of the player
doesnt work right. Any ideas, code , suggestions and just help in general is much needed and will be much apprecaited.

Adrian




_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 3 months FREE*. http://join.msn.com/?page=features/junkmail&xAPID=42&PS=47575&PI=7324&DI=7474&SU= http://www.hotmail.msn.com/cgi-bin/getmsg&HL=1216hotmailtaglines_stopmorespam_3mf


Reply via email to