Re: [Circle] Revised Player listing command

From: Rasmus 'Con' Ronlev (
Date: 08/09/96

On Mon, 5 Aug 1996, Justin Robinson - Primacy wrote:

> (The following code is a modified version of the PLAYER listing
> command that I posted earlier.  This version is corrected, and will
> now prompt for hitting ENTER every pageful of info)
>   *buf = 0;
>   for (i = 0; i <= top_of_p_table; i++) {
>     sprintf(buf, "%s  %-20.20s", buf, (player_table + i)->name);
>     count++;
>     if (count == 3) {
>       count = 0;
>       sprintf(buf, "\r\n");
>     }
>   }
>   page_string(ch->desc, buf, 1);
> }

Well, this message is really NOT about this piece of code, it's about
using the buf's and page_string() when creating output .)
It's an observation I made yesterday while I created the r/o/mlist
commands in my own flavour, i.e. lots of colors etc etc...

What happened was, that I exceeded the size of buf, which is designed to
have a size of 8k I beleave. On a system like a sun, if you exceed this
limit you crash the mud 1 nannoseccond after entering that player command
if you have a large playerbase!
I'm very tired right now, and this message sucks, but here is what should
be done (somewhere in that code).

if (strlen(buf) + 25 > sizeof(buf))
  abort abort abort...

Doing this will prevent your mashine from crashing or ending up (as in my
case) with erros in the zone reset tables, making me wonder what the f*
I'd made with the zone tables that might cause that :)

Just my two cents.
I hope this was understandable, it's 4am here, and I'm wasted, just though
I'd make this 'announcement' before the list got spammed by people saying
their code crashes all the time and in 50 different places.

Con. (btw. feel free to change the subject if replying *grin*)

     Rasmus Rønlev DOEK'94      WWW:
     Student instructor         MUD: 5000
       Student, B.Sc in Computer Science and Business Administration.

| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   |

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