Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ People having problems with max class and max race

People having problems with max class and max race

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Tseris   (98 posts)  Bio
Date Fri 06 Nov 2009 05:11 PM (UTC)
Message
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.
Top

Posted by Tseris   (98 posts)  Bio
Date Reply #1 on Fri 06 Nov 2009 05:31 PM (UTC)
Message
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];
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #2 on Sat 07 Nov 2009 03:23 AM (UTC)
Message
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.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


13,639 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.