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
➜ Swr 1.0 - A question on a bug with the login (a.k.a. nanny) function.
|
Swr 1.0 - A question on a bug with the login (a.k.a. nanny) function.
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Odis
(5 posts) Bio
|
| Date
| Wed 11 Dec 2002 01:57 AM (UTC) |
| Message
| Well, I have a very important question. I run a MUD derived off of SWR and I've fixed almost every bug I've found, except for this one. When a person logs in and it says "Please choose a main ability from the following classes" and then if they type ee or something like that it crashes. So I guess I'll just try and post the code here (only the section I know the bug is in) and hope you can find what I'm looking for. I'm not really an experienced coder, but I know enough for what I need. Only this one bug has slipped my mind, I'm not good at working with arguments really. So please post a reply if you can help. Sorry if the format is screwed up a bit, I copy and pasted it.
------ From void nanny in comm.c ------
write_to_buffer( d, "\n\rPlease choose a main ability from the folowing classes:\n\r[", 0 );
buf[0] = '\0';
for ( iClass = 0; iClass < MAX_ABILITY; iClass++ )
{
if (ability_name[iClass] && ability_name[iClass][0] != '\0')
{
if ( iClass > 0 )
{
if ( strlen(buf)+strlen(ability_name[iClass]) > 77 )
{
strcat( buf, "\n\r" );
write_to_buffer( d, buf, 0 );
buf[0] = '\0';
}
else
strcat( buf, " " );
}
strcat( buf, ability_name[iClass] );
}
}
strcat( buf, "]\n\r: " );
write_to_buffer( d, buf, 0 );
d->connected = CON_GET_NEW_CLASS;
break;
case CON_GET_NEW_CLASS:
argument = one_argument(argument, arg);
if (!str_cmp( arg, "help") )
{
do_help(ch, argument);
write_to_buffer( d, "Please choose an ability class: ", 0);
return;
}
for ( iClass = 0; iClass < MAX_ABILITY; iClass++ )
{
if ( toupper(arg[0]) == toupper(ability_name[iClass][0])
&& !str_prefix( arg, ability_name[iClass] ) )
{
ch->main_ability = iClass;
break;
}
}
if ( iClass == MAX_ABILITY
|| !ability_name[iClass] || ability_name[iClass][0] == '\0')
{
write_to_buffer( d,
"That's not a skill class.\n\rWhat IS it going to be? ", 0 );
return;
}
| | Top |
|
| Posted by
| Nick Cash
USA (626 posts) Bio
|
| Date
| Reply #1 on Sun 12 Jan 2003 11:36 AM (UTC) |
| Message
| | Actually I did this on my SWR Mud also. What is MAX_ABILITY defined to in mud.h and how many abilitys are going to be displayed? Tell me that and I think I can tell you how to fix it. |
~Nick Cash
http://www.nick-cash.com | | Top |
|
| Posted by
| Odis
(5 posts) Bio
|
| Date
| Reply #2 on Sun 12 Jan 2003 11:39 AM (UTC) |
| Message
| | MAX_ABILITY is defined as 8 but I only want to display 7. Should I change MAX_ABILITY to 7? | | Top |
|
| Posted by
| Nick Cash
USA (626 posts) Bio
|
| Date
| Reply #3 on Sun 12 Jan 2003 11:44 AM (UTC) |
| Message
| Make sure you have 7 and only 7 defined in const.c . Then change it so the code looks like this:
write_to_buffer( d, "\n\rPlease choose a main ability from the folowing classes:\n\r[", 0 );
buf[0] = '\0';
for ( iClass = 0; iClass < 7; iClass++ )
{
if (ability_name[iClass] && ability_name[iClass][0] != '\0')
{
if ( iClass > 0 )
{
if ( strlen(buf)+strlen(ability_name[iClass]) > 77 )
{
strcat( buf, "\n\r" );
write_to_buffer( d, buf, 0 );
buf[0] = '\0';
}
else
strcat( buf, " " );
}
strcat( buf, ability_name[iClass] );
}
}
strcat( buf, "]\n\r: " );
write_to_buffer( d, buf, 0 );
d->connected = CON_GET_NEW_CLASS;
break;
case CON_GET_NEW_CLASS:
argument = one_argument(argument, arg);
if (!str_cmp( arg, "help") )
{
do_help(ch, argument);
write_to_buffer( d, "Please choose an ability class: ", 0);
return;
}
for ( iClass = 0; iClass < 7; iClass++ )
{
if ( toupper(arg[0]) == toupper(ability_name[iClass][0])
&& !str_prefix( arg, ability_name[iClass] ) )
{
ch->main_ability = iClass;
break;
}
}
if ( iClass == MAX_ABILITY
|| !ability_name[iClass] || ability_name[iClass][0] == '\0')
{
write_to_buffer( d,
"That's not a skill class.\n\rWhat IS it going to be? ", 0 );
return;
}
It should fix the bug that you were getting. If it doesn't then just let me know. |
~Nick Cash
http://www.nick-cash.com | | Top |
|
| Posted by
| Odis
(5 posts) Bio
|
| Date
| Reply #4 on Sun 12 Jan 2003 11:45 AM (UTC) |
| Message
| Thanks! That fixed it. I guess it was crashing becuase it would loop up 1 more than was defined. So yeah, thanks agian.
~Odis | | Top |
|
| Posted by
| Nick Cash
USA (626 posts) Bio
|
| Date
| Reply #5 on Sun 12 Jan 2003 11:46 AM (UTC) |
| Message
| | Glad I could help. :) |
~Nick Cash
http://www.nick-cash.com | | 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.
19,526 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top