[BUG] [CODE] custom who

From: Mulder (mulder@cloud9.net)
Date: 11/17/98


My MUD has murdered do_who with a variety of changes, but there is some
weird bug. Whenever the who list needs to be page string'd half of the list
repeats
itself. Can anyone help?

Here is an example of the bug in its glory:

Mortals currently online
--------------------------
[99 Hum Th] Test the Cut-Throat 99
[99 Tro Wa] Datamonkey the Forge of God 99 [Commander in Chief of Lords of
Chaos]
[99 Hum Mu] Storm the Oracle [Brig General of Army of Fire]
[94 Elf Mu] Jennafre the Archwitch 94 [The Donna of The Trouble Makers]
[92 Tro Wa] Swike emits a dark black aura [Battle Master of The Shining
Force]
[92 Hum Wa] Uther Lightbringer the Paladin [Warlord of The Shining Force]
[87 Tro Mu] Aahz Tritch [Captain of Army of Fire] (invis)
[71 Elf Cl] Thincar the Patriarch 71 [Nobleman of The Abyss]
[65 Elf Cl] Bludger emits a dark green aura from his Butt [A Punisher of The
Trouble Makers]
[29 Gno Wa] WarriorBabs the Warrior [General of Lords of Chaos]
[29 Hum Cl] Nuwbie the Cleric [Applying to Lords of Chaos]
[26 Tro Wa] Onejg the Warrior [Knight of The Shining Force]
[17 Hum Mu] Atrix the Ancient One [Lead Fighter of The Shining Force]

There are 5 visible immortals and there are 14 visible mortals.
There is a boot time high of 19 players.


[ Return to continue, (q)uit, (r)efresh, (b)ack, or page number (1/2) ]
[92 Hum Wa] Uther Lightbringer the Paladin [Warlord of The Shining Force]
[87 Tro Mu] Aahz Tritch [Captain of Army of Fire] (invis)
[71 Elf Cl] Thincar the Patriarch 71 [Nobleman of The Abyss]
[65 Elf Cl] Bludger emits a dark green aura from his Butt [A Punisher of The
Trouble Makers]
[29 Hum Cl] Nuwbie the Cleric [Applying to Lords of Chaos]
[29 Gno Wa] WarriorBabs the Warrior [General of Lords of Chaos]
[26 Tro Wa] Onejg the Warrior [Knight of The Shining Force]
[17 Hum Mu] Atrix the Ancient One [Lead Fighter of The Shining Forc
There are 2 visible immortals and there are 14 visible mortals.
There is a boot time high of 19 players.


Here is the code for the page_string etc (keep in mind this who is built on
the version by Daniel Koepke, but uses quicksort and a bunch of other stuff.
I cannot paste it here since its over 200 lines and would be annoying if not
pointless):

      /* Thargor - alright let's update the respective who_lists */
      if (!ismortal){
        /*
        immlist[Wizards] = malloc(sizeof(struct who_list));
        if (immlist[Wizards] == NULL){
          mudlog("DEBUG:Malloc failed for immlist at do_who().", PFT,
                 LVL_IMPL, TRUE);
        }else{
          immlist[Wizards]->level = GET_LEVEL(wch);
          immlist[Wizards]->desc = strdup(buf2);
          Wizards++;
        }
        */
        immlist[Wizards].level = GET_LEVEL(wch);
        if (strlen(buf2) > SMALL_BUFSIZE){
          mudlog ("DEBUG: buf2 is too long at do_who().", PFT, LVL_IMPL,
TRUE);
        }else{
          bzero(immlist[Wizards].desc, SMALL_BUFSIZE);
          strcpy(immlist[Wizards].desc, buf2);
          Wizards++;
        }
      }else{
        mortlist[Mortals].level = GET_LEVEL(wch);
        if (strlen(buf2) > SMALL_BUFSIZE){
          mudlog ("DEBUG: buf2 is too long at do_who().", PFT, LVL_IMPL,
TRUE);
        }else{
          bzero(mortlist[Mortals].desc, SMALL_BUFSIZE);
          strcpy(mortlist[Mortals].desc, buf2);
          Mortals++;
        }

      }

    }                           /* end of for */

  /* Thargor - Alright, now let's sort the whole dang shawamp thingy */
  quicksort((void *) immlist, 0, Wizards-1, whocmp);
  quicksort((void *) mortlist, 0, Mortals-1, whocmp);

  /* finally update the actual buffers used for printout */
  /*
  for (j = (Wizards-1); j >= 0; j--){
    if (immlist[j]->desc != NULL){
      sprintf(Imm_buf, "%s%s", Imm_buf, immlist[j]->desc);
      free(immlist[j]->desc);
    }
    if (immlist[j] != NULL)
      free(immlist[j]);
  }
  */
  for (j = (Wizards-1); j >= 0; j--){
    if (strlen(immlist[j].desc) > 0)
      sprintf(Imm_buf, "%s%s", Imm_buf, immlist[j].desc);
  }

  /*
  for (j = (Mortals-1); j >= 0; j--){
    if (mortlist[j]->desc !=
){
      sprintf(Mort_buf, "%s%s", Mort_buf, mortlist[j]->desc);
      free(mortlist[j]->desc);
    }
    if (mortlist[j] != NULL)
      free(mortlist[j]);
  }
  */
  for (j = (Mortals-1); j >= 0; j--){
    if (strlen(mortlist[j].desc) > 0)
      sprintf(Mort_buf, "%s%s", Mort_buf, mortlist[j].desc);
  }

//  send_to_char ("       &c-&G=&c-&G=&c- &mD &YE &mL &YT &mA &YN &mI &YA &c-&G=&c-&G=&c-&n"
//              "\r\n\r\n",ch);

  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)
  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 ? $
  if (Mortals)
    sprintf (buf, "%s %s %d visible mortal%s.", (Wizards ? buf : "There"), (Mortals == 1 ? "is" : "are"), Mort$
  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);
} /* end do_who */


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