Re: [CODE] Scan snippet [FIX]

From: Chris Jacobson (fear@ATHENET.NET)
Date: 04/28/98


Here is a small fix: when I went to get the snippet from the code, I
realized there was a better way I could do it, and re-wrote some small
portions.  However, when I went to get the LList<> snippet, I realized I
made a small mistake.  Here is the fix:

(quickie: just replace the  iter.Peek()  calls with  iter.Next()  calls)

*** Begin Snippet ***


void list_scanned_chars(LList<CharData *> &list, CharData * ch, int
distance, int door) {
        const char *    how_far[] = {
                "close by",
                "nearby",
                "to the",
                "far off",
                "far in the distance"
        };
        char                    relation;
        CharData *              i;
        UInt32                  count = 0, one_sent = 0;
        LListIterator<CharData *>       iter(list);

        while((i = iter.Next())) {
                if (ch->CanSee(i))
                        count++;
        }

        if (!count)
                return;

        iter.Reset();
        while((i = iter.Next())) {
                if (!ch->CanSee(i))
                        continue;

                relation = relation_colors[ch->GetRelation(i)];

                if (!one_sent)  ch->send("You see `%c%s", relation, i->GetName());
                else ch->send("`%c%s", relation, i->GetName());

                if (--count > 1)        send_to_char("`n, ", ch);
                else if (count == 1) send_to_char(" `nand ", ch);
                else ch->send(" `n%s %s.\r\n", how_far[distance], dirs[door]);
                one_sent++;
        }
}


*** End Snippet ***


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