Posted by
| Zeno
USA (2,871 posts) Bio
|
Message
| I'm having an issue with the similar helpfile snippet. Certain helpfiles if you try to read them (or a close syntax to the helpfile) will crash the MUD instantly, but the gdb will look like a loop.
#0 get_help (ch=0x942f318, argument=0xfed01a40 "imm authorize") at act_info.c:2042
2042 if ( isdigit(argument[0]) )
(gdb) bt
#0 get_help (ch=0x942f318, argument=0xfed01a40 "imm authorize") at act_info.c:2042
#1 0x08054930 in do_help (ch=0x942f318, argument=0xfed01a40 "imm authorize") at act_info.c:2222
#2 0x0805487f in similar_help_files (ch=0x942f318, argument=0xfed03ab0 "imm authorize") at act_info.c:2198
#3 0x08054952 in do_help (ch=0x942f318, argument=0xfed03ab0 "imm authorize") at act_info.c:2227
#4 0x0805487f in similar_help_files (ch=0x942f318, argument=0xfed05b20 "imm authorize") at act_info.c:2198
#5 0x08054952 in do_help (ch=0x942f318, argument=0xfed05b20 "imm authorize") at act_info.c:2227
#6 0x0805487f in similar_help_files (ch=0x942f318, argument=0xfed07b90 "imm authorize") at act_info.c:2198
#7 0x08054952 in do_help (ch=0x942f318, argument=0xfed07b90 "imm authorize") at act_info.c:2227
#8 0x0805487f in similar_help_files (ch=0x942f318, argument=0xfed09c00 "imm authorize") at act_info.c:2198
#9 0x08054952 in do_help (ch=0x942f318, argument=0xfed09c00 "imm authorize") at act_info.c:2227
#10 0x0805487f in similar_help_files (ch=0x942f318, argument=0xfed0bc70 "imm authorize") at act_info.c:2198
#11 0x08054952 in do_help (ch=0x942f318, argument=0xfed0bc70 "imm authorize") at act_info.c:2227
#12 0x0805487f in similar_help_files (ch=0x942f318, argument=0xfed0dce0 "imm authorize") at act_info.c:2198
#13 0x08054952 in do_help (ch=0x942f318, argument=0xfed0dce0 "imm authorize") at act_info.c:2227
...
#574 0x0805487f in similar_help_files (ch=0x942f318, argument=0xfef477d0 "imm authorize") at act_info.c:2198
#575 0x08054952 in do_help (ch=0x942f318, argument=0xfef477d0 "imm authorize") at act_info.c:2227
#576 0x0805487f in similar_help_files (ch=0x942f318, argument=0xfef4a4a5 "imm auth") at act_info.c:2198
#577 0x08054952 in do_help (ch=0x942f318, argument=0xfef4a4a5 "imm auth") at act_info.c:2227
#578 0x080d42f5 in interpret (ch=0x942f318, argument=0xfef4a4a5 "imm auth") at interp.c:571
#579 0x080a9c17 in game_loop () at comm.c:679
#580 0x080a94ba in main (argc=2, argv=0xfef4a8e0) at comm.c:308
Is there anyway to set a variable limit so it doesn't do this?
// Main function of Similar Helpfiles Snippet by Senir. It loops through all of the
// helpfiles, using the string matching function defined to find the closest matching
// helpfiles to the argument. It then checks for singles. Then, if matching helpfiles
// are found at all, it loops through and prints out the closest matching helpfiles.
// If its a single(there's only one), it opens the helpfile.
void similar_help_files(CHAR_DATA *ch, char *argument)
{
HELP_DATA *pHelp=NULL;
char buf[MAX_STRING_LENGTH];
char *extension;
sh_int lvl=0;
bool single=FALSE;
send_to_pager_color( "&C&BSimilar Help Files:\n\r", ch);
for ( pHelp = first_help; pHelp; pHelp=pHelp->next)
{
buf[0]='\0';
extension=pHelp->keyword;
if (pHelp->level > get_trust(ch))
continue;
while ( extension[0] != '\0' )
{
extension= one_argument(extension, buf);
if ( str_similarity(argument, buf) > lvl)
{
lvl=str_similarity(argument, buf);
single=TRUE;
}
else if ( str_similarity(argument, buf) == lvl && lvl > 0)
{
single=FALSE;
}
}
}
if (lvl==0)
{
send_to_pager_color( "&C&GNo similar help files.\n\r", ch);
return;
}
for ( pHelp = first_help; pHelp; pHelp=pHelp->next)
{
buf[0]='\0';
extension=pHelp->keyword;
while ( extension[0] != '\0' )
{
extension=one_argument(extension, buf);
if ( str_similarity(argument, buf) >= lvl
&& pHelp->level <= get_trust(ch))
{
if (single)
{
send_to_pager_color( "&C&GOpening only similar helpfile.&C\n\r", ch);
do_help( ch, buf);
return;
}
pager_printf_color(ch, "&C&G %s\n\r", pHelp->keyword);
break;
}
}
}
return;
}
|
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|