Re: send_to_charf, Take 2

From: George Greer (greerga@circlemud.org)
Date: 07/10/01


On Tue, 10 Jul 2001, Peter Ajamian wrote:

>George Greer wrote:
>>
>>   actf(TO_CHAR, 0, "You are hungry.\r\n", ch);
>>   actf(TO_ROOM, 0, "$n is hungry.\r\n", ch);
>
>I was thinking more like this:
>
>actf(TO_CHAR, 0, "$cYou tickle $n.\r\n", ch, tch);
>actf(TO_CHAR, 0, "$c$n tickles you.\r\n", tch, ch);
>actf(TO_NOTCHAR, 0, "$c$c$n tickles $n.\r\n", ch, tch, ch, tch);

Uuurk! I'm trying to avoid heart attacks, thanks. :)

You've just made the sending string encode a parameter.  Why stop there? We
can just do:

  actf("TO_ROOM:0:$cYou tickle $n.\r\nTO_CHAR:0:$c$n tickles you.\r\n"
        "TO_NOTCHAR:0:$c$c$n tickles $n.\r\n", ch, tch, tch, ch,
        ch, tch, ch, tch);

Then we can get rid of all those three act() statements and compress it all
down to one easy-to-read printout. Right?

(Please don't say yes.)

>Of course (just as an aside thought), most of those are relatively easy
>to do with %s without the formatter (ie, you can always use %s and
>GET_NAME(ch) instead of $n and ch) but I think that may be moving
>backwards (something to ponder, at any rate).

  $n = IS_INVIS_TO_TARGET(actor) ? "Someone" : GET_NAME(actor)

So no, we'd not want to do that.

>> That's a bit of abuse of variable arguments, no?
>
>How so?

We're not actually passing the argument to the format, we're just including
it because no other information was given as to whom to send the string
to.  Whenever someone is actually the target, the argument is omitted
because it is included already.  It seems an awfully "special" case to be
required that way.

I'm not exactly sure what to do with act() at the moment.  It's a rather
general function...  The only real trouble cases I can think of are
queries like:

  Send to all indoor rooms in the zone.
        (TO_ZONE | TO_INDOOR | TO_NOT)
  Send to all outdoor rooms not in the zone.

Oops, which is the case described by the bitmask?

Other fun ones are the case of sending to a character not included in the
format specification, where's the argument goes? If we include it as a
fixed parameter, we'll need it everywhere.  If we include it as an argument
without being in the format then we've just made a rather huge
inconsistency with the arguments based on the format. (Now, if it wasn't
based on the format, I wouldn't have a problem with the various arguments
thrown in.)

> >> Not that we could use GCC
> >> printf format checking anyway due to handling $-style parameters
> >> ourselves.
>
>Hrmmm, I see what you mean.  I can't help but think there's got to be a
>way to extract or change parameters from the list and pass the balance
>on to the vsprintf() function.

Sure we could, but the compiler still couldn't check the arguments at
compile time. It only recognizes "%foo = argument", not "$foo = argument"
as well.

>Too bad we have to stay Windoze (and others) compatible, GNU has
>facilities to specify our own printf() conversion functions.  Do Windoze
>and other platforms have similar functions?  It _could_ be made to work
>via that route.

I'm not sure the printf() would have enough information to determine things
like visibility.

--
George Greer
greerga@circlemud.org

--
   +---------------------------------------------------------------+
   | 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