Issue adding surname states to nanny, please help?

From: Mathew Earle Reuther (graymere@zipcon.net)
Date: 07/15/02


I am having problems getting a surname selection functional in my nanny.
I'm going from where nanny would normally jump to CON_QSEX and sending it
instead to CON_GET_SURNAME (defined where all other CON states are
defined in structs.h, along with my surname confirmation state) where I
want to be able to input something, parse it, and set it if they're sure
it's what they want, then move on to getting their sex.  So far this is
not terribly successful!  My code is below:  Anyone feel like poitning out
to me what I'm doing wrong?  (Compile errors for parse error and
undeclared tmp_surname . . .)

    if (STATE(d) == CON_CNFPASSWD) {
      write_to_output(d, "\r\nPlease enter your surname: ");
      STATE(d) = CON_GET_SURNAME;
    } else {
      save_char(d->character);
      write_to_output(d, "\r\nDone.\r\n%s", MENU);
      STATE(d) = CON_MENU;
    }
    break;

  /*
   * This is a new con state added to allow for selection of a surname
during character
   * generation - Corwynn
   */

  case CON_GET_SURNAME:
    char buf[MAX_INPUT_LENGTH], tmp_surname[MAX_INPUT_LENGTH];

    if ((_parse_name(arg, tmp_surname)) || strlen(tmp_surname) < 2 ||
    strlen(tmp_surname) > MAX_SURNAME_LENGTH || !Valid_Name(tmp_surname)
||
    fill_word(strcpy(buf, tmp_surname)) || reserved_word(buf)) {        /*
strcpy: OK (mutual MAX_INPUT_LENGTH) */
        write_to_output(d, "That's not a valid surname, please try
something else.\r\nSurname: ");
        return;
    } else {
        CREATE(d->character->player.surname, char, strlen(tmp_surname) +
1);
        strcpy(d->character->player.surname, CAP(tmp_surname)); /* strcpy:
OK (size checked above) */

        write_to_output(d, "\r\nDo you wish your surname to be %s? ([Y]es
or [N]o)? ", tmp_surname);
        STATE(d) = CON_SURNAME_CNF;
        }

        break;

  /*
   * This new con state allows confirmation of the surname entered by the
player - Corwynn
   */

  case CON_SURNAME_CNF:         /* wait for conf. of new surname name
*/
    switch (*arg) {
    case 'y':
    case 'Y':
      break;
    case 'n':
    case 'N':
      free(d->character->player.surname);
      d->character->player.surname = NULL;
      write_to_output(d, "Please enter your surname: ");
      STATE(d) = CON_GET_SURNAME;
      break;
    default:
      write_to_output(d, "That is not a valid response!\r\n([Y]es or
[N]o): ");
      return;
    }

    write_to_output(d, "\r\nWhat is your sex? ([M]ale or [F]emale): ");
    STATE(d) = CON_QSEX;
    break;

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



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