Re: [CODE] Whois command for C30bpl18 with ASCII

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


On Mon, 10 Sep 2001, NeoStar wrote:

> Well the reason I did this was because the MUD I help code for has
> about 14 races and maybe 5 classes and the Imp wanted special strings
> for each race/class combo.

I'd still recommend adding these to class.c (or where you define your
races, perhaps) so that when you add new races/classes, it becomes clear
that this needs to change.  I'm of the opinion that many Muds simply
stagnate because as their code is being casually evolved (rather than
carefully designed and implemented) its growing more and more
unmaintainable, until it completely devolves into a mish-mash of code
that's too hard to work with for anyone not getting paid for it to deal
with it.  Taking even small steps towards simple things like logical
placement, etc., may be able to obviate a later need for a larger code
clean-up.

> Where'd I have a global buffer?

buf1 and buf are both global buffers.  Anything that's not defined in your
function or its argument list, but exists, is either a file local (static
variable declared somewhere above the function in the same file) or a
global (an extern'd variable, originally declared/defined somewhere else).
The same is true of functions.

These global buffers are used throughout CircleMUD.  For now.

Net effect: things like the below example seem to perform inexplicably odd
because they're both changing the same global buffer:

  void whois_char(struct char_data *ch, struct char_data *vict)
  {
    . . .
    sprintf(buf, "%s %s is a level %d %s.\r\n", ...);
    . . .
  }

  ACMD(do_whois)
  {
    . . .
    sprintf(buf, "Results from query WHOIS %s >>\r\n");
    whois_char(ch, vict);
    send_to_char(buf, ch);
    . . .
  }

The output of this command to the person that executes it will always look
something like:

  Dak the Acronym is a level 34 Magic User.
  Dak the Acronym is a level 34 Magic User.

Naturally, you weren't doing anything like the above, so your code should
have worked fine (and, I suspect, did).  On the other hand, it doesn't
always just depend upon whether the code in front of you is behaving
nicely.  Sometimes it's everything it calls and everything that calls it
that can mercilessly confuse the matter.

-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