command interpreter

From: Sam Moggach (micken69@hotmail.com)
Date: 12/07/01


Hello. i've run into a dreadful crash bug while messing with my command
interpreter! it seems to crash whenever the user enters a command that is
not on the command list. the command you type in seems to bypass the
filter... even if it's not on the list it passes... Here is code from the
area that i changed, from my code and from stock:
//Stock
  if (*cmd_info[cmd].command == '\n')
    send_to_char("Huh?!?\r\n", ch);
  else if (!IS_NPC(ch) && PLR_FLAGGED(ch, PLR_FROZEN) && GET_LEVEL(ch)
< LVL_IMPL)
    send_to_char("You try, but the mind-numbing cold prevents you...\r\n",
ch);
  else if (cmd_info[cmd].command_pointer == NULL)
    send_to_char("Sorry, that command hasn't been implemented yet.\r\n",
ch);
  else if (IS_NPC(ch) && cmd_info[cmd].minimum_level >= LVL_IMMORT)
    send_to_char("You can't use immortal commands while switched.\r\n", ch);
  else if (GET_POS(ch) < cmd_info[cmd].minimum_position)
    switch (GET_POS(ch)) {
    case POS_DEAD:
      send_to_char("Lie still; you are DEAD!!! :-(\r\n", ch);
      break;
    case POS_INCAP:
    case POS_MORTALLYW:
      send_to_char("You are in a pretty bad shape, unable to do
anything!\r\n", ch);
      break;
    case POS_STUNNED:
      send_to_char("All you can do right now is think about the stars!\r\n",
ch);
      break;
    case POS_SLEEPING:
      send_to_char("In your dreams, or what?\r\n", ch);
      break;
    case POS_RESTING:
      send_to_char("Nah... You feel too relaxed to do that..\r\n", ch);
      break;
    case POS_SITTING:
      send_to_char("Maybe you should get on your feet first?\r\n", ch);
      break;
    case POS_FIGHTING:
      send_to_char("No way!  You're fighting for your life!\r\n", ch);
      break;
  } else if (no_specials || !special(ch, cmd, line))
    ((*cmd_info[cmd].command_pointer) (ch, line, cmd,
cmd_info[cmd].subcmd));
}

//Mine

  if (*cmd_info[cmd].command == '\n')
    send_to_char("Huh?!?\r\n", ch);
  else if (!IS_NPC(ch) && PLR_FLAGGED(ch, PLR_FROZEN) && GET_LEVEL(ch) <
LVL_IMPL)
    send_to_char("You try, but the mind-numbing cold prevents you...\r\n",
ch);
  else if (cmd_info[cmd].command_pointer == NULL)
    send_to_char("Sorry, that command hasn't been implemented yet.\r\n",
ch);
  else if (IS_NPC(ch) && cmd_info[cmd].minimum_level >= LVL_IMMORT)
    send_to_char("You can't use immortal commands while switched.\r\n", ch);
  else if (GET_POS(ch) < cmd_info[cmd].minimum_position)
    switch (GET_POS(ch)) {
    case POS_DEAD:
      send_to_char("Lie still; you are DEAD!!! :-(\r\n", ch);
      break;
    case POS_INCAP:
    case POS_MORTALLYW:
      send_to_char("You are in a pretty bad shape, unable to do
anything!\r\n", ch);
      break;
    case POS_STUNNED:
      send_to_char("All you can do right now is think about the stars!\r\n",
ch);
      break;
    case POS_SLEEPING:
      send_to_char("In your dreams, or what?\r\n", ch);
      break;
    case POS_RESTING:
      send_to_char("Nah... You feel too relaxed to do that..\r\n", ch);
      break;
    case POS_SITTING:
      send_to_char("Maybe you should get on your feet first?\r\n", ch);
      break;
  } else if (no_specials || !special(ch, cmd, line))
      if (GET_POS(ch) == POS_FIGHTING && IS_FIGHTCMD(cmd_info[cmd]) &&
                difftime(time(0), ch->player.time.lastfightcmd) == number(1,
3))
         ch->char_specials.fightcmd_in = 0;
      else if (GET_POS(ch) == POS_FIGHTING && IS_FIGHTCMD(cmd_info[cmd]) &&
!ch->char_specials.fightcmd_in) {
        ch->char_specials.fightcmd_in = 1;
        ch->player.time.lastfightcmd = time(0);
        ((*cmd_info[cmd].command_pointer) (ch, line, cmd,
cmd_info[cmd].subcmd));
      }
      else if (ch->char_specials.fightcmd_in)
        send_to_char("You are typing faster than you can think!\r\n", ch);
      else
        ((*cmd_info[cmd].command_pointer) (ch, line, cmd,
cmd_info[cmd].subcmd));
}

When i run the mud in gdb it gives me nothing, it just crashes for no
reason. When i backtrace it it traces to where the command interpreter tries
to run the function, meaning that even though the command wasn't on the list
it made it to the end and the mud TRIED to perform the command...

The only other change i've made is i have added an element to the command
list structure, but that shouldn't be the problem

Thanks!

Micken

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/24/03 PDT