[code] Tightening do_spec_comm

From: Daniel Koepke (dkoepke@CALIFORNIA.COM)
Date: 09/21/97


So I was running through act.comm.c (I finally got off my lazy ass and
installed Linux and CircleMUD earlier today) and I noticed that
do_spec_comm could be tightened.  While I agree with the comment that it
could be tied in with do_tell(), as the comment suggests, the do_tell()
function is called often and should be kept as clean as possible.  On
the other hand, perform_tell() can go a ways towards creating more
function do_tell() like commands without complicating or confusing the
code.

All that is needed is the addition of two char pointer arguments to
perform_tell() that accept the verb to use (one time for "You <verb>
$N" and another for "$N <verbs> you").  This requires very minimal
change to perform_tell().  Just the addition of the two arguments and
then a change to the sprintf() statements.

Next, in do_tell() you change perform_tell() to account for the two
new arguments; same as in do_reply().  In do_reply() I actually
decided to change it to "reply" and "replies" instead of "tell" and
"tells" (and added a bool so that you can have "You reply" or "$N
replies" instead of "You reply to $N" or "$N replies to you").

Next, I went down to do_spec_comm() and changed that block of code
starting at the last "else {" and going down to the
"act(action_others, . . . .)" line to just a single
perform_tell(ch, vict, argument, action_sing, action_plur, TRUE).

Here's my new perform_tell():

void perform_tell(struct char_data *ch, struct char_data *vict,
                  char *arg, char *verb, char *sverb, bool targ)
{
  sprintf(buf, "&B$n &w%s%s, &L'&W%s&L'&w", sverb, arg, (targ ? " you" : ""));
  act(buf, FALSE, ch, 0, vict, TO_VICT | TO_SLEEP);

  if (PRF_FLAGGED(ch, PRF_NOREPEAT))
    send_to_char(OK, ch);
  else {
    sprintf(buf, "You %s%s, &L'&W%s&L'&w", verb, arg, (targ ? " &B$N" : ""));
    act(buf, FALSE, ch, 0, vict, TO_CHAR | TO_SLEEP);
  }

  /* GET_LAST_TELL(vict) moved to do_tell() and do_reply() */
}

Passing TRUE for the last argument ('targ') appends the ' you' or ' $N'
for "$N tells you" or "You tell $N".  If it is FALSE, they are left off,
so you get "$N tells" or "You tell" (which is only useful for "reply",
so far).  Also, note that I'm using my own color code system.  Change
to your liking or whatever.  I did this to further "encapsulate" the
code.  It doesn't necessarily give any "superior" functionality, but it
does cut down on the code in do_spec_comm() and makes do_reply() look
a bit nicer without so much code as it has now.  Kind of like the recall
code encapsulation...:)~


--
Daniel Koepke -:- dkoepke@california.com -:-  [Shadowlord/Nether]
Think.


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST