[Circle] do_who, Headache Level 50

From: linebacker (linebacker@microlink.net)
Date: 07/24/96


Okay here is the do_who code I am using.

I have also tried the code without my Mortlevels
string array addition.
I have also added the patch straight into a cherry
copy of bl11 and it did the same thing.

It is adding a space after the second character, then two 
spaces after the third, and then four, and I tried up to 8 chars
and it was  dding an extra space each time.

Also, please don't rag me for the way i imped the Mortlevels
array, it is temp only, just wanted to see how it would look.

act.information.c
CODE:

/*********************************************************************
* New 'do_who' by Daniel Koepke [aka., "Argyle Macleod"] of The Keep *
******************************************************************* */

char *WHO_USAGE =
  "Usage: who [minlev[-maxlev]] [-n name] [-c classes] [-rzqimo]\r\n"
  "\r\n"
  "Classes: (M)age, (C)leric, (T)hief, (W)arrior\r\n"
  "\r\n"
  " Switches: \r\n"
  "_.,-'~'-,._\r\n"
  "\r\n"
  "  -r = who is in the current room\r\n"
  "  -z = who is in the current zone\r\n"
  "\r\n"
  "  -q = only show questers\r\n"
  "  -i = only show immortals\r\n"
  "  -m = only show mortals\r\n"
  "  -o = only show outlaws\r\n"
  "\r\n";

ACMD(do_who)
{
  struct descriptor_data *d;
  struct char_data *wch;
  char Imm_buf[MAX_STRING_LENGTH];
  char Mort_buf[MAX_STRING_LENGTH];
  char name_search[MAX_NAME_LENGTH+1];
  char mode;

  int low = 0, high = LVL_IMPL, showclass = 0;
  bool who_room = FALSE, who_zone = FALSE, who_quest = 0;
  bool outlaws = FALSE, noimm = FALSE, nomort = FALSE;
  
  int Wizards = 0, Mortals = 0;
  size_t i;
  
  const char *WizLevels[LVL_IMPL - (LVL_IMMORT-1)] = {
    " Immortal     ",
    " Lesser God   ",
    " Greater God  ",
    "*REALM MASTER*"
  };
/* THIS IS TEMP, I KNOW THEIR IS AN EASIER WAY */
/* NOT THE PORBLEM HOWEVER */
  const char *Mortlevels[LVL_IMPL - 4] = {
" Newcomer ",  
" Newcomer ",
" Newcomer ",
" Newcomer ",
" Newcomer ",
" Trainee ",
" Trainee ",
" Trainee ",
" Trainee ",
" Trainee ",
" Initiate ",  
" \\c06Initiate\\c00 ",
" \\c06Initiate\\c00 ",
" \\c06Initiate\\c00 ",
" \\c06Initiate\\c00 ",
" \\c06Initiate\\c00 ",
" \\c06Initiate\\c00 ",
" \\c06Initiate\\c00 ",
" \\c06Initiate\\c00 ",
" \\c06Initiate\\c00 ",
" \\c02Traveller\\c00 ", 
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" \\c03Journeymen\\c00 ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" \\c04Adventurer\\c00 ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" \\c05Greater Lord\\c00 ", 
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" \\c01Leader\\c00 ", 
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" \\c11Instructor\\c00 ", 
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
"\\c11**\\c14Lore Master\\c11**\\c00", 
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
" a ",
"\\c08**\\c10 DragonLord\\c08 **\\c00", 
" a ",
" a ",
" a ",
" a ",
" a ", 
" a ",
" a ",
" a ",
" a "
};

  /* This part is from the stock CircleMUD 'do_who'; No reason to rewrite
     it.  Don't want to take credit for something I didn't write... */
  skip_spaces(&argument);
  strcpy(buf, argument);
  name_search[0] = '\0';

  while (*buf) {
    half_chop(buf, arg, buf1);
    if (isdigit(*arg)) {
      sscanf(arg, "%d-%d", &low, &high);
      strcpy(buf, buf1);
    } else if (*arg == '-') {
      mode = *(arg + 1);	/* just in case; we destroy arg in the switch */
      switch (mode) {
      case 'o':
	outlaws = TRUE;
	strcpy(buf, buf1);
	break;
      case 'z':
	who_zone = TRUE;
	strcpy(buf, buf1);
	break;
      case 'q':
	who_quest = TRUE;
	strcpy(buf, buf1);
	break;
      case 'l':
	half_chop(buf1, arg, buf);
	sscanf(arg, "%d-%d", &low, &high);
	break;
      case 'n':
	half_chop(buf1, name_search, buf);
	break;
      case 'r':
	who_room = TRUE;
	strcpy(buf, buf1);
	break;
      case 'c':
	half_chop(buf1, arg, buf);
	for (i = 0; i < strlen(arg); i++)
	  showclass |= find_class_bitvector(arg[i]);
	break;
      default:
	send_to_char(WHO_USAGE, ch);
	return;
	break;
      }				/* end of switch */

    } else {			/* endif */
      send_to_char(WHO_USAGE, ch);
      return;
    }
  }				/* end while (parser) */
  strcpy(Imm_buf, "\\c06+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r\n     \\c00Immortals of Hidden Daze\r\n\\c06+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\\c00\r\n");
  strcpy(Mort_buf,"\\c06+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\r\n     \\c00Mortals of Hidden Daze\\c06\r\n+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\\c00\r\n");

  for (d = descriptor_list; d; d = d->next) {
    if (d->connected)
      continue;

    if (d->original)
      wch = d->original;
    else if (!(wch = d->character))
      continue;

    if (!CAN_SEE(ch, wch))
      continue;
    if (GET_LEVEL(wch) < low || GET_LEVEL(wch) > high)
      continue;
    if ((noimm && GET_LEVEL(wch) >= LVL_IMMORT) || (nomort && GET_LEVEL(wch) < LVL_IMMORT))
      continue;
    if (*name_search && str_cmp(GET_NAME(wch), name_search) && !strstr(GET_TITLE(wch), name_search))
      continue;
    if (outlaws && !PLR_FLAGGED(wch, PLR_KILLER) && !PLR_FLAGGED(wch, PLR_THIEF))
      continue;
    if (who_quest && !PRF_FLAGGED(wch, PRF_QUEST))
      continue;
    if (who_zone && world[ch->in_room].zone != world[wch->in_room].zone)
      continue;
    if (who_room && (wch->in_room != ch->in_room))
      continue;
    if (showclass && !(showclass & (1 << GET_CLASS(wch))))
      continue;


    if (GET_LEVEL(wch) >= LVL_IMMORT) {
      sprintf(Imm_buf, "%s%s[%s] %s %s", Imm_buf, CCYEL(ch, C_SPR), 
              WizLevels[GET_LEVEL(wch)-LVL_IMMORT], GET_NAME(wch), 
              GET_TITLE(wch));
      Wizards++;
    } else {
      sprintf(Mort_buf, "%s[%16s %s] %s %s", Mort_buf, Mortlevels[GET_LEVEL(wch) - 0], CLASS_ABBR(wch), GET_NAME(wch), GET_TITLE(wch));
      Mortals++; 
    }

    if (GET_INVIS_LEV(wch))
      sprintf(buf, "%s (i%d)", buf, GET_INVIS_LEV(wch));
    else if (IS_AFFECTED(wch, AFF_INVISIBLE))
      strcat(buf, " (Invis)");
    if (IS_AFFECTED(wch, AFF_SHADOW_FORM))
      strcat(buf, " (ShadowForm)");

    if (PLR_FLAGGED(wch, PLR_MAILING))
      strcat(buf, " (Mailing)");
    else if (PLR_FLAGGED(wch, PLR_WRITING))
      strcat(buf, " (Writing)");

    if (PRF_FLAGGED(wch, PRF_DEAF))
      strcat(buf, " (Deaf)");
    if (PRF_FLAGGED(wch, PRF_NOTELL))
      strcat(buf, " (NoTell)");
    if (PRF_FLAGGED(wch, PRF_QUEST))
      strcat(buf, " (Quest)");
    if (PLR_FLAGGED(wch, PLR_THIEF))
      strcat(buf, " (* THIEF *)");
    if (PLR_FLAGGED(wch, PLR_KILLER))
      strcat(buf, " (* KILLER *)");
    if (GET_LEVEL(wch) >= LVL_IMMORT)
      strcat(buf, CCNRM(ch, C_SPR));
     strcat(buf, "\r\n"); 
    
    if (GET_LEVEL(wch) >= LVL_IMMORT)
      strcat(Imm_buf, buf);
    else
      strcat(Mort_buf, buf);
    send_to_char(buf, ch);

  }				/* end of for */

  if (Wizards) {
    page_string(ch->desc, Imm_buf, 0);
    send_to_char("\r\n", ch);
  }
  
  if (Mortals) {
    page_string(ch->desc, Mort_buf, 0);
     send_to_char("\r\n", ch); 
  }
  
  if ((Wizards + Mortals) == 0)
    strcpy(buf, "No wizards or mortals are currently visible to you.\r\n");
  if (Wizards)
    sprintf(buf, "There %s %d visible immortal%s%s", (Wizards == 1 ? "is" : "are"), Wizards, (Wizards == 1 ? "" : "s"), (Mortals ? " and there " : "."));
  if (Mortals)
    sprintf(buf, "%s%s %d visible mortal%s.", (Wizards ? buf : "There"), (Mortals == 1 ? "is" : "are"), Mortals, (Mortals == 1 ? "" : "s"));
  strcat(buf, "\r\n");
  
  if ((Wizards + Mortals) > boot_high)
    boot_high = Wizards+Mortals;
  sprintf(buf, "%sThere is a boot time high of %d player%s.\r\n", buf, boot_high, (boot_high == 1 ? "" : "s"));
  send_to_char(buf, ch);
}

*******************************************************
I am having a major breakdown over this problem.

Here is a brief exmaple of what the who output looks like:

+-+-+-+-+- blah blah
[  Leader     Wiz ] Tray
[  Initiate   War ] Bagget

[  Adventurer Pal ] Drace


[  Adventurer Asn ] Shade
and so on, one extra space after each new entry

Can anyone track this bug????

Thanks, Chuck



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