Re: [CODE]Pet System

From: Daniel A. Koepke (dkoepke@circlemud.org)
Date: 09/22/01


On Fri, 21 Sep 2001, Ramsey Stone wrote:

> Could someone help me? I was thinking like when someone buys a pet,
> you could set a short description, [... snip ...]

If you simply have the player set the short_description from the command
line (instead of throwing them into an editor, which is a bit intrusive)
then you can pretty much copy the pet_name code.  The buy command becomes:

  > buy [pet] [name] [short_desc]

and you barely have to write any code:

  } else if (CMD_IS("buy")) {
    argument = two_arguments(argument, buf, pet_name);
    skip_spaces(&argument);

    .
    .
    .

    if (*argument)
      pet->player.short_descr = str_dup(argument);

    .
    .
    .
  }

There's no clean-up or anything to do.  You don't need to free() the
previous short_descr because it's shared with the prototype; you don't
need to free() it later because CircleMUD handles this for you.


-dak

--
   +---------------------------------------------------------------+
   | 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 : 12/06/01 PST