People having problems with max class and max race

Posted by Tseris on Fri 06 Nov 2009 05:11 PM — 3 posts, 17,408 views.

#0
Ive seen on the forums alot of ppl having issues when creating new races and classes when they use up all of their race/class slots as defined by MAX_RACE in mud.h. The problem being that the last race or class added doesnt seem to appear anywhere.

I believe the issue may be linked to language throughout the code such as this one in void do_showrace in act_wiz.c:


for( i = 0; i < MAX_RACE; i++ )


Its taking only those entries less than max race, when it should be <=. So if your max race is 20, and your new Tiefling race is number 20, it wont show.
#1
Also, it might be helpful for those starting out putting in new classes to add the following little snippet in act_wiz.c

This will allow you to view the list of classes so you can keep track.

Where it says:


void do_showclass( CHAR_DATA* ch, const char* argument)
{
   char arg1[MAX_INPUT_LENGTH];
   char arg2[MAX_INPUT_LENGTH];
   struct class_type *Class;
   int cl, low, hi;

   set_pager_color( AT_PLAIN, ch );

   argument = one_argument( argument, arg1 );
   argument = one_argument( argument, arg2 );
   if( arg1[0] == '\0' )
   {
      send_to_char( "Syntax: showclass <class> [level range]\r\n", ch );
      return;
   }
   if( is_number( arg1 ) && ( cl = atoi( arg1 ) ) >= 0 && cl < MAX_CLASS )
      Class = class_table[cl];


Change it to:


void do_showclass( CHAR_DATA* ch, const char* argument)
{
   char arg1[MAX_INPUT_LENGTH];
   char arg2[MAX_INPUT_LENGTH];
   struct class_type *Class;
   int cl, low, hi, ct, i;

   set_pager_color( AT_PLAIN, ch );

   argument = one_argument( argument, arg1 );
   argument = one_argument( argument, arg2 );
   
   if( arg1[0] == '\0' )
   {
      send_to_char( "Syntax: showclass <class> [level range]\r\n", ch );
      /* show classes addition by Tseris */
      ct = 0;
      for( i = 0; i < MAX_CLASS; i++ )
      {
         ++ct;
         pager_printf( ch, "%2d> %-11s", i, class_table->who_name );
         if( ct % 5 == 0 )
            send_to_pager( "\r\n", ch );
      }

      send_to_pager( "\r\n", ch );
      return;
   }
   
   if( is_number( arg1 ) && ( cl = atoi( arg1 ) ) >= 0 && cl < MAX_CLASS )
      Class = class_table[cl];
USA #2
The more correct solution would be to increase MAX_RACE, not to change the comparison operator. Better yet would be to rename MAX_RACE to NUM_RACES, which is a more accurate description of what it represents.

(You would indeed loop up to and including the highest number, but you would loop up to but excluding the number of races.)

(Also, be careful with [i] in code.)