Oh looks like I broke nanny.

Posted by Mopop on Tue 31 Jan 2006 03:33 PM — 7 posts, 26,431 views.

#0
In my quest to remove vampires from the game, I had to remove a few lines of code from comm.c the thing is I am not sure if I deleted TOO much or not enough. Things started getting weird on compile saying I needed to deleting things that were never wrong to begin with. None the less i deleted them to compile and get the server back up. Of course now I cant even log on, so yes I will need alittle assistance.

Here is the first thing I edited

write_to_buffer( d, "\r\nYou may choose from the following races, or type help [race] to learn more:\r\n[", 0 );
         buf[0] = '\0';
         for( iRace = 0; iRace < MAX_PC_RACE; iRace++ )
         {
            if( iRace != RACE_VAMPIRE
                && race_table[iRace]->race_name && race_table[iRace]->race_name[0] != '\0'
                && !IS_SET( race_table[iRace]->class_restriction, 1 << ch->Class )
                && str_cmp( race_table[iRace]->race_name, "unused" ) )
            {
               if( iRace > 0 )
               {
                  if( strlen( buf ) + strlen( race_table[iRace]->race_name ) > 77 )
                  {
                     mudstrlcat( buf, "\r\n", MAX_STRING_LENGTH );
                     write_to_buffer( d, buf, 0 );
                     buf[0] = '\0';
                  }
                  else
                     mudstrlcat( buf, " ", MAX_STRING_LENGTH );
               }
               mudstrlcat( buf, race_table[iRace]->race_name, MAX_STRING_LENGTH );
            }
         }


now It looks like this in my comm.c

write_to_buffer( d, "\r\nYou may choose from the following races, or type help [race] to learn more:\r\n[", 0 );
         buf[0] = '\0';
         for( iRace = 0; iRace < MAX_PC_RACE; iRace++ )
	   {
                   if( iRace > 0 )
		     {
                  if( strlen( buf ) + strlen( race_table[iRace]->race_name ) > 77 )
                  {
                     mudstrlcat( buf, "\r\n", MAX_STRING_LENGTH );
                     write_to_buffer( d, buf, 0 );
                     buf[0] = '\0';
                  }
                  else
                     mudstrlcat( buf, " ", MAX_STRING_LENGTH );
               }
               mudstrlcat( buf, race_table[iRace]->race_name, MAX_STRING_LENGTH );
            }
         }


After that it said breaks and cases were in the wrong place and I deleted them which I think really messed the mud up. There is more to this but Im going to see if maybe this is the problem before posting more.
USA #1
From the code you pasted it looks like you have one to many curly braces at the end. This will cause a very long list of errors.

You will probably want to keep that if check around, just remove the vampire clause from it, as so:



            if(  race_table[iRace]->race_name && race_table[iRace]->race_name[0] != '\0'
                && !IS_SET( race_table[iRace]->class_restriction, 1 << ch->Class )
                && str_cmp( race_table[iRace]->race_name, "unused" ) )

USA #2
Yup. What WK said.

Note that you removed the if check without really reading it. :) The whole thing is relevant to people that aren't vampires -- in other words, your whole set of characters. So you should be making the subsequent checks to everybody.
#3
It wasnt so much I didnt read it, it was I didnt understand what it did :( I am still pretty new at this and can only read/write a little code. But as always I thank you guys for your help!
USA #4
What don't you understand from the statement:
        if( iRace != RACE_VAMPIRE
                && race_table[iRace]->race_name && race_table[iRace]->race_name[0] != '\0'
                && !IS_SET( race_table[iRace]->class_restriction, 1 << ch->Class )
                && str_cmp( race_table[iRace]->race_name, "unused" ) )
We can go through this statement step by step, if you would like. It would probably be good for you to understand more precisely what's going on -- you'll be able to better make this kind of change without breaking fundamental things accidentally. :)
#5
Step by step please ^_^
USA #6
OK:

        // Line 1: if the current race number isn't "vampire".
        // note that we're in a for loop over all the race numbers.
        if( iRace != RACE_VAMPIRE
        
        // Line 2: AND, if the current race -- race_table[iRace] means look up the "iRace" entry in the table --
        // has a non-null race_name pointer,
        // AND, the first character of this pointer is not the zero character
                && race_table[iRace]->race_name && race_table[iRace]->race_name[0] != '\0'
        
        // This one has some degree of voodoo, I'll grant...
        // basically, it means make sure that the "iRace" entry
        // is not forbidden to take the character's chosen class
                && !IS_SET( race_table[iRace]->class_restriction, 1 << ch->Class )

        // and, make sure that the race entry's name isn't "unused".
        // (str_cmp returns 0 i.e. false on equality, and non-zero i.e. true on difference. Go figure.)
                && str_cmp( race_table[iRace]->race_name, "unused" ) )

Hope this helps...