Re: WARNING: CODE SPAMMAGE

From: ShadowLord (dkoepke@california.com)
Date: 06/11/96


I did a patch which I uploaded to cambot some time ago that replaced 'who'
with a real nice looking version.

On Tue, 11 Jun 1996 phantasm@aztechnet.com wrote:

> [snip]
> if (short_list) {
>   sprintf(buf, "%s[%2d %s] %-12.12s%s%s",
>       (GET_LEVEL(tch) >= LVL_IMMORT ? CCYEL(ch, C_SPR) : ""),
>         GET_LEVEL(tch), CLASS_ABBR(tch), GET_NAME(tch),
>           (GET_LEVEL(tch) >= LVL_IMMORT ? CCNRM(ch, C_SPR) : ""),
>         ((!(++num_can_see % 4)) ? "\r\n" : ""));
>   send_to_char(buf, ch);
> send_to_char("This is the short list!",ch);

This will show:

  Players
  -------
  [31 Cl] David
  This is the short list!
  [14 Ma] Bobby
  This is the short list!
  [ 1 Wa] Garry
  This is the short list
  .
  .
  .

Not exactly pretty, eh?

> } else {
>  if (GET_LEVEL(tch) < 31) {
> num_can_see++;
> sprintf(buf, "%s[%2d %s ] %s %s",
>         (GET_LEVEL(tch) >= LVL_IMMORT ? CCYEL(ch, C_SPR) : ""),
>           GET_LEVEL(tch), CLASS_ABBR(tch), GET_NAME(tch),
>         GET_TITLE(tch));
> }
> if (GET_LEVEL(tch) > 30) {
> num_can_see++;
> if (GET_LEVEL(tch) == 31)
> { sprintf(imm_title, "   %sWizard%s  ",
>  CCRED(ch, C_SPR), CCMAG(ch, C_SPR) );
> }
> if (GET_LEVEL(tch) == 32)
> { sprintf(imm_title, "  %sImmortal%s ",
>           CCGRN(ch, C_SPR), CCMAG(ch, C_SPR) );
> }
> if (GET_LEVEL(tch) == 33)
> { sprintf(imm_title, "%sGreater God%s",
>                 CCBLU(ch, C_SPR), CCMAG(ch, C_SPR) );
> }
> if (GET_LEVEL(tch) == 34)
> { sprintf(imm_title, "%sImplementor%s",
>                 CCCYN(ch, C_SPR), CCMAG(ch, C_SPR) );
> }

This could be much shorter (eg., the way I do it in my 'who' patch).
Also, you could move the CCMAG down the general sprintf line and make this
whole block of if's an else-if.  But, like I said, my code for this is
much smaller.

> send_to_char(buf, ch);

You are sending the short list twice!



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