This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

stats.mod v1.40dev20 - bot stucking in loop

Old posts that have not been replied to for several years.
Locked
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

stats.mod v1.40dev20 - bot stucking in loop

Post by De Kus »

cause im not really used to C++ i thought one of you guy could help me (and probably a lot of other peoples). the latest version of stats.mod is a bit time ago, it doenst seem there is something in progress, so i decided to get a fix by myself.
it seems to stuck in this section:

Code: Select all

  while (params[0]) {
    par = newsplit(&params);
    // check if param is a timerange
    if ((tmp = get_timerange(par)) != T_ERROR)
      timerange = tmp;
    // still no match? Then lets check if the param
    // is a range (top10, top20, etc...)
    else if ((tmp = atoi(par)))
      range = tmp;
    // still no match? Uhm... ok, maybe this is a
    else if ((tmp = slangtypetoi(par)) != T_ERROR) {
      itype = tmp;
      if (itype == T_WORD) {
        word = newsplit(&params);
      }
      type = par;
    } else
      debug1("Unknown parameter: %s", par);
  }
it begins on line 125 in file pubcmd.c
the cause why i think it is here, is when i use !top without any options, it will normal output. if i use !top today it still gives output, but when i use !top top10 oder !top modes oder something like this, the bot will stuck in loop and timeout so i have to kill the prozess.

PS: uncomment the 2 lines

Code: Select all

    else if ((tmp = atoi(par)))
      range = tmp;
doesnt help.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

okok

Post by De Kus »

i continiued my research and find out the looping stucking lines are

Code: Select all

    else if ((tmp = slangtypetoi(par)) != T_ERROR) {
      itype = tmp;
      if (itype == T_WORD) {
        word = newsplit(&params);
      }
      type = par;
if you remove them or replace them with somthing like

Code: Select all

    else if (par == "words" || par == "lines" || par == "wpl" || par == "actions" || par == "smileys" || par == "kicks" || par == "modes" || par == "topics" || par == "minutes") {
      itype = par = tmp;
      if (itype == T_WORD) {
        word = newsplit(&params);
      }
      type = par;
the bot wont react correctly to !top modes or anything like this, but it at least doenst hang up. :D

so it seems it stucks in the procedur slangtypetoi which is found in slang.c

Code: Select all

#ifndef SLANG_NOTYPES
static char *getslangtype(char *type)
{
  char *stype;

  if (!glob_slang) {
    putlog(LOG_MISC, "*", "WARNING! No language selected! (getslangtype())");
    return "NOLANG";
  }
  stype = slang_type_get(glob_slang->types, type);
  if (stype)
    return stype;
  else
    return type;
}
and the slang_type_get is found in slang_type.c

Code: Select all

static char *slang_type_get(struct slang_type *where, char *type)
{
  while (where) {
    if (!strcasecmp(where->type, type))
      return slang_multitext_getrandomtext(where->mtext);
    where = where->next;
  }
  return NULL;
}
here is a loop the bot could get stucking in. to be honset, i have no clue what "where = where->next" does and it seems return is never called...

eh yes, i have loaded the de langpack and alternavly the en. but i cant find thinds like words etc. in there...
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Hi, just a note, eggdrop is written in C and not C++. Also the part you changed is.. well, let's just say you can't test if par == "words" like that. That's basically never true. You're comparing the addresses of par and the string "words". You probably meant to do strcmp or strcasecmp.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

IEKS

Post by De Kus »

so par is probably a pointer @_o, hihi, sounds logicaly. but does still not answer. but ill try strcmp.
this should be descript somewhere here *looks in an old c book*.

ps: i think its around 8 years ago i learned the diffrenz between C and C++ :D and i told you i am not used to C ^^.

pps: shouldnt give me the compiler a warning, when i am trieing to compare pointer with strings? im sure i had seen such things using borland c 4.5 or something like that :D.

ppps:
hihi, im just stupid, i am still not getting a true value with strcasecmp :D.

found a new subfunction in slang_multitext.c depending to prevoius:

Code: Select all

static char *slang_multitext_getrandomtext(struct slang_multitext *where)
{
  struct slang_mt_content *content;
  unsigned long x;

  if (!where)
    return NULL;
  x = random() % where->nr;
  for (content = where->contents; content; content = content->next)
    if (!x)
      return slang_text_get(content->text);
    else
      x--;
  // we should never reach this part
  debug0("warning: getrandomtext didn't find anything!");
  return NULL;
}
PS: ich hab mir mal die entsprechenden ausschnitte in den alten files von v1.3.3dev1 angeschaut, aber da sich die eine function von dort total aufgespittet hat find ich mich da nicht zurecht, ehrlich gesagt :(. aber wäre net, wenn sich das mal einer anschauen könnte...

PPS: last PS was in german, dont ask me why:
i tried to compare the parts with the old files from v1.3.3dev1, but everything is split up and I can't track it ^^. Would be nice someone takes a deeper look.
Locked