Re: [NEWBIE] Updating code

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


On Sat, 8 Sep 2001, NeoStar wrote:

> I am trying to use the whois snippet from the CM ftp, in
> /code/commands/whois.txt. I'm guesing it's old code because one
> function is one I've never seen before. (we are using pl18)

I'm guessing you've changed your code in ways that you're not aware of.
Perhaps you are using an ASCII pfile snippet which changes the way
characters are loaded?  If it's not that, ensure you're #include'ing db.h
from within act.informative.c.

>    CREATE(victim, struct char_data, 1);
>    clear_char(victim);
>    if (load_char(argument, &tmp_store) > -1) {
>      store_to_char(&tmp_store, victim);

This is how loading is done in stock CircleMUD.  Well, a bit of a badly
written example of it, anyway.  A bit of reordering is in order:

  if (load_char(argument, &tmp_store) > -1) {
    CREATE(victim, struct char_data, 1);
    clear_char(victim);
    store_to_char(&tmp_store, victim);

    .
    .
    .
  } else
    send_to_char("That player does not exist.\r\n", ch);

so that you don't needlessly do an allocation/free.

This won't work for you if you're using ASCII pfiles (I guess).  If that's
the case, I can't be much more helpful aside from telling you to look at
how character loading is done in nanny() (interpreter.c).  (I don't know
how it's done myself, sorry.)  See the CON_GET_NAME state handler in
nanny().  There should be an example there.

BTW, this is why some wise person the other day suggested that one only
apply patches that one understands and can write oneself.  If you don't
understand how they interact, you rapidly cut-and-paste yourself into a
corner.  If you're going to apply it without understanding it beforehand,
perhaps patch by hand so that you can see what it's doing.  This will help
you learn, empower you to solve your own problems quickly and more
efficiently than the list will ever be capable of, and, hence, cut down on
list traffic due to people not knowing what they've done to their code.


-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