Thread: Jog Command
View Single Post
Old 04-05-2004, 01:35 PM   #1
Jaegar
New Member
 
Join Date: Apr 2002
Posts: 14
Jaegar is on a distinguished road
I have just implemented an old jog command that I had found but am having a problem with it accepting some of the input.

The code is supposed to accept numbers before the direction and interpret it into the movement as well as accept an "o" for open then a direction to open.

Here is how the code should read the directions input

jog 12eos3ses4w

However the code will not accept the #'s and the open is not recognized either.

Here is the code from act_move.c

This is for a Rom2.4 mud.


 void do_jog( CHAR_DATA *ch, char *argument )
  {
     char buf[MAX_INPUT_LENGTH], arg[MAX_INPUT_LENGTH];
     char *p;
     bool dFound = FALSE;

     if (!ch->desc || *argument == '\0')
     {
        send_to_char("You run in place!\n\r", ch);
        return;
     }

     buf[0] = '\0';
     while (*argument != '\0')
     {
        argument = one_argument(argument,arg);
        strcat(buf,arg);
     }

     for ( p = buf + strlen(buf) -1; p >= buf; p-- )
     {
        if (!isdigit(*p))
        {
           switch( *p )
           {
              case 'n':
              case 's':
              case 'e':
              case 'w':
              case 'u':
              case 'd': dFound = TRUE;
                 break;
              case 'o':
                 break;
              default: send_to_char("Invalid direction!\n\r",ch);
                 return;
           }
        }
        else if (!dFound) *p = '\0';
     }

     if (!dFound)
     {
        send_to_char("No directions specified!\n\r",ch);
        return;
     }

     ch->desc->run_buf = str_dup( buf );
     ch->desc->run_head = ch->desc->run_buf;
     send_to_char("You start running...\n\r",ch);
     return;
  }


Any help would be appreciated.

Jaegar
Jaegar is offline   Reply With Quote