Similar helpfiles, loop?

Posted by Zeno on Sun 19 Dec 2004 10:33 PM — 11 posts, 32,648 views.

USA #0
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;
}
USA #1
Looks like it's finding something that isn't actually a help file. I imagine that it's trying to look up the helpfile that similar_helpfile gave it, failing, and then passing it on to similar_helpfile, which will then start the mess all over again.

One option would be to prefix all automated help requests with '-auto-' or something like that; then, as you process the argument in do_help you would check for that. If the request was made automatically, do not do anything like checking for similar help files.
USA #2
Personally never ran into that problem with the code, but there were some other issues I had with it that caused me to get rid of it. Then Remcon was kind enough to write up something which more or less does the same thing but doesn't have all the baggage and errors with it. Works rather nicely. It's available on my site for the curious.
USA #3
I'd rather not, I want similar helpfiles to remain there at all times. Is there no ifcheck that can be done to prevent this? Help imm says lists "help imm auth", so I typed help imm auth, and it brought about this problem. Although it has happened before, with things such as certain numbers.
USA #4
Perhaps you misunderstood, or I wasn't clear enough, Remcon's code does more or less the same thing. Providing similar files to look at. It's just a replacement do_help, but it does the job nicely and the results are more accurate.
USA #5
Sorry, was replying to Ksilyan's post, your post wasn't there when I was reading the topic.

Didn't know you had one like that. I'll check it out.
USA #6
Hmm, Remcon's code also has the same problem.

#0  get_help (ch=0x94374d0, argument=0xfed04570 "2") at act_info.c:2042
2042        if ( isdigit(argument[0]) )
(gdb) bt
#0  get_help (ch=0x94374d0, argument=0xfed04570 "2") at act_info.c:2042
#1  0x0805489f in do_help (ch=0x94374d0, argument=0xfed04570 "2")
    at act_info.c:2277
#2  0x08054b2f in do_help (ch=0x94374d0, argument=0xfed075b0 "2")
    at act_info.c:2329
#3  0x08054b2f in do_help (ch=0x94374d0, argument=0xfed0a5f0 "2")
    at act_info.c:2329

It goes on for a few hundred frames.
USA #7
What combinations of arguments are you feeding the code to make it crash? Using your two posted core examples where you had "imm authorize" and "2" showing as the argument, I am unable to duplicate the crash or loop behaviour. I get back output from both commands. Using Remcon's code that is. I have been able to generate crashes on Senir's code using both arguments.
USA #8
Not really constructive or anything, but I would just like to note that I've used Senir's helpfile snippet for a long time now (by long time, i mean a long time, it was one of the first snippets I ever added to my mud) and I've never had this problem.
USA #9
[  44] Dias: bug with help area (low range) (high range)
Date:  Fri Dec 31 05:25:34 2004
To:    imm
===========================================================================
i was reading some help files while i was sittin around today.
when i tried the help area (low range) (high range) it crashed the mud.
just informing you. later.

[  45] Dias: error in last post
Date:  Fri Dec 31 05:30:49 2004
To:    imm
===========================================================================
it was just areas (low range) (high range), not help
and the actual command i used was areas 2 10


The old similiar helpfile system is commented out, so it is Remcon's code, I'm sure of that.

This is all I know from the notes. I can't seem to reproduce it either, and he isn't telling me exactly what crashed it. But the core does match to the date.

But I noticed this problem...
No help on '2' found.
Suggested Help Files:
 2                     2  

Not sure why. I can't hstat the "2" helpfile. (hstat is an Imm command, helpfile stat)
Amended on Sat 01 Jan 2005 12:09 AM by Zeno
USA #10
Well I've "fixed" the problem. The similar helpfile snippet was fine, but there were some bad helpfiles. Some were named "2 level fight" or something like that. They came with Smaug, and they caused these crashes. Finally got around to removing the last of them.