[CODE] send_to_char

From: John Evans (evansj@HI-LINE.NET)
Date: 10/01/97


Inspired by George's new log() and mudlogf() funtions, I'm going through
my MUD and re-coding send_to_char(), send_to_room(), and send_to_all() in
the same fashion as those new functions....

Here's what I did with send_to_char. NOTE: This does NOT REPLACE
send_to_char. This is in addition to send_to_char in comm.c.

----------
In comm.c:
Look for:
#include "sysdep.h"

Add in:
#include "stdarg.h"


Look for:
void send_to_char(char *messg, struct char_data *ch)
{
  if (ch->desc && messg)
    SEND_TO_Q(messg, ch->desc);
}

Add in:
void send_to_charf(struct char_data *ch, const char *format, ...)
{
  char messg[MAX_STRING_LENGTH];
  va_list args;

  va_start(args, format);
  vsprintf(messg, format, args);
  va_end(args);

  if (ch->desc && messg)
    SEND_TO_Q(messg, ch->desc);
}

----------
In comm.h:
Look for:
void    send_to_char(char *messg, struct char_data *ch);

Add in:
void    send_to_charf(struct char_data *ch, const char *format, ...);


Of course, this doesn't change much at all. This just gives you a new
function that you can all like so:

send_to_charf(ch, "Your name is %s.", GET_NAME(ch));

instead of the old:
sprintf(buf, "Your name is %s.", GET_NAME(ch));
send_to_char(buf, ch);


I'll leave it up to you guys to go through and replace all the sprintf and
send_to_char calls yourself as I don't have time to alter the stock code and
make a patch out of it at the moment. Sorry.

Oh... The changes to send_to_roomf(), and send_to_allf() should be apparent
from what is shown in send_to_charf(). Don't forget to put the prototypes
in comm.h

Good luck!

John Evans <evansj@hi-line.net>

May the source be with you.


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