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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Similar helpfiles, loop?

Similar helpfiles, loop?

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


Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Sun 19 Dec 2004 10:33 PM (UTC)
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
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #1 on Sun 19 Dec 2004 11:24 PM (UTC)
Message
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.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Samson   USA  (683 posts)  [Biography] bio
Date Reply #2 on Mon 20 Dec 2004 03:17 AM (UTC)
Message
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.
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #3 on Mon 20 Dec 2004 03:18 AM (UTC)
Message
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.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Samson   USA  (683 posts)  [Biography] bio
Date Reply #4 on Mon 20 Dec 2004 03:30 AM (UTC)
Message
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.
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #5 on Mon 20 Dec 2004 03:33 AM (UTC)
Message
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.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #6 on Fri 31 Dec 2004 02:47 PM (UTC)
Message
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.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Samson   USA  (683 posts)  [Biography] bio
Date Reply #7 on Fri 31 Dec 2004 03:40 PM (UTC)
Message
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.
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] bio
Date Reply #8 on Fri 31 Dec 2004 10:08 PM (UTC)
Message
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.

~Nick Cash
http://www.nick-cash.com
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #9 on Fri 31 Dec 2004 11:09 PM (UTC)

Amended on Sat 01 Jan 2005 12:09 AM (UTC) by Zeno

Message
[  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)

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #10 on Tue 15 Feb 2005 03:32 PM (UTC)
Message
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.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[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.


20,297 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]