[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  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] Refresh page


Posted by Odis   (5 posts)  [Biography] 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;
}
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] 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
[Go to top] top

Posted by Odis   (5 posts)  [Biography] 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?
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] 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
[Go to top] top

Posted by Odis   (5 posts)  [Biography] 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
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] 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
[Go to top] 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,309 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]