Re: Titles on the who list (CODE)

From: Rafiq Premji (jurniman@BETTERBOX.NET)
Date: 02/26/98


Here's my who code.  Change as necessary and ponder giving me credit : P
----------

ACMD(do_who)
{
  struct descriptor_data *d;
  struct char_data *tch;
  char name_search[MAX_INPUT_LENGTH];
  char mode;
  size_t i;
  int low = 0, high = LVL_IMPL, localwho = 0, questwho = 0;
  int showclass = 0, short_list = 0, outlaws = 0, num_can_see = 0;
  int who_room = 0;

  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':
      case 'k':
 outlaws = 1;
 strcpy(buf, buf1);
 break;
      case 'z':
 localwho = 1;
 strcpy(buf, buf1);
 break;
      case 's':
 short_list = 1;
 strcpy(buf, buf1);
 break;
      case 'q':
 questwho = 1;
 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 = 1;
 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_FORMAT, ch);
 return;
 break;
      }    /* end of switch */

    } else {   /* endif */
      send_to_char(WHO_FORMAT, ch);
      return;
    }
  }    /* end while (parser) */

  send_to_char("Players\r\n-------\r\n", ch);

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

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

    if (*name_search && str_cmp(GET_NAME(tch), name_search) &&
 !strstr(GET_TITLE(tch), name_search))
      continue;
    if (!CAN_SEE(ch, tch) || GET_LEVEL(tch) < low || GET_LEVEL(tch) > high)
      continue;
    if (outlaws && !PLR_FLAGGED(tch, PLR_KILLER) &&
 !PLR_FLAGGED(tch, PLR_THIEF))
      continue;
    if (questwho && !PRF_FLAGGED(tch, PRF_QUEST))
      continue;
    if (localwho && world[ch->in_room].zone != world[tch->in_room].zone)
      continue;
    if (who_room && (tch->in_room != ch->in_room))
      continue;
    if (showclass && !(showclass & (1 << GET_CLASS(tch))))
      continue;
    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);
    } else {
      num_can_see++;
      if (GET_LEVEL(tch) >= LVL_IMMORT) {
        char la[32];
               if (GET_LEVEL(tch) == LVL_IMMORT)
                 strcpy (la, "Low Immortal");
                else if (GET_LEVEL(tch) == LVL_MED_IMMORT)
                 strcpy (la,"Immortal");
                else if (GET_LEVEL(tch) == LVL_HIGH_IMMORT)
                 strcpy (la, "High Immortal");
                else if (GET_LEVEL(tch) == LVL_SNR_IMMORT)
                 strcpy (la, "Senior Immortal");
                else if (GET_LEVEL(tch) == LVL_DEMI_GOD)
                 strcpy (la, "Demi God");
                else if (GET_LEVEL(tch) == LVL_GOD)
                 strcpy (la, "God");
                else if (GET_LEVEL(tch) == LVL_GRGOD)
                 strcpy (la, "High God");
                else if (GET_LEVEL(tch) == LVL_SNR_GOD)
                 strcpy (la, "Senior God");
                else if (GET_LEVEL(tch) == LVL_PATRON)
                 strcpy (la, "Patron");
                else if (GET_LEVEL(tch) == LVL_IMPL)
                 strcpy (la, "Implementor");
  else
   strcpy (la, "GAME ERROR");
        sprintf(buf, "[%s] %s %s",
               la, GET_NAME(tch), GET_TITLE(tch)); }
      else {
      sprintf(buf, "%s[%2d %s - %s] %s %s",
       (GET_LEVEL(tch) >= LVL_IMMORT ? CCYEL(ch, C_SPR) : ""),
       GET_LEVEL(tch), CLASS_ABBR(tch), RACE_ABBR(tch),
       GET_NAME(tch), GET_TITLE(tch)); }

      if (GET_INVIS_LEV(tch))
 sprintf(buf, "%s (i%d)", buf, GET_INVIS_LEV(tch));
      else if (IS_AFFECTED(tch, AFF_INVISIBLE))
 strcat(buf, " (invis)");

      if (PLR_FLAGGED(tch, PLR_MAILING))
 strcat(buf, " (mailing)");
      else if (PLR_FLAGGED(tch, PLR_WRITING))
 strcat(buf, " (writing)");

      if (PRF_FLAGGED(tch, PRF_DEAF))
 strcat(buf, " (deaf)");
      if (PRF_FLAGGED(tch, PRF_NOTELL))
 strcat(buf, " (notell)");
      if (PRF_FLAGGED(tch, PRF_QUEST))
 strcat(buf, " (quest)");
      if (PLR_FLAGGED(tch, PLR_THIEF))
 strcat(buf, " (THIEF)");
      if (PLR_FLAGGED(tch, PLR_KILLER))
 strcat(buf, " (KILLER)");
      if (GET_LEVEL(tch) >= LVL_IMMORT)
 strcat(buf, CCNRM(ch, C_SPR));
      strcat(buf, "\r\n");
      send_to_char(buf, ch);
    }    /* endif shortlist */
  }    /* end of for */
  if (short_list && (num_can_see % 4))
    send_to_char("\r\n", ch);
  if (num_can_see == 0)
    sprintf(buf, "\r\nNo-one at all!\r\n");
  else if (num_can_see == 1)
    sprintf(buf, "\r\nOne lonely character displayed.\r\n");
  else
    sprintf(buf, "\r\n%d characters displayed.\r\n", num_can_see);
  send_to_char(buf, ch);
}

----------
Rafiq "JurniMan" Premji
Implementor of PythonMUD - jurniman.com 6666


     +------------------------------------------------------------+
     | 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/15/00 PST