Re: Checking a number

From: Ron Hensley (ronh@intercom.net)
Date: 01/03/00


Im sure this has bugs, its not code i use, rather soemthing i just
cut/pasted and hacked a bit in the email to show the idea.
Debug/fix before using (It may work as is)

There are so many examples of this sort of thing in the code it's
unbelievable. This is 90% cut/paste code from elsewhere.

world[ch->in_room].people is a linked list of people in ch's room

Call it like
  if (is_tch_alone(ch))
    /* Do whatever as he/she's alone */
  else
    /* He/She has company */
  }

  /* Return True or False, is there someone in the room with tch? */
int is_tch_alone(struch char data *tch) {
 struct char_data *target;
 struct char_data *next_target;
 int found = TRUE;

 for (target = world[tch->in_room].people; target; target = next_target) {
     next_target = target->next_in_room;

       /* Error, reached end of linked list, bail out */
     if (target == NULL)
       return found;
       /* Its tch, skip him/her */
     if (target == tch)
       continue;
       /* This persons a MOB not a player, skip it
     if (IS_NPC(tch))
       continue;
     else
         /* Found at least one other person */
       found = FALSE;
   }
   return found;
}

On Mon, 3 Jan 2000, J P wrote:

> How would you check to see if there is more than one player/mob (besides
> yourself) in the room?
>
> Im trying to add an assassinate and it works, but its powerful, se I need a
> way to check to see that there is only
> one other person in the room (besides yourself).
> Any help is appriciated (as always! ;) )
>
> --LordKaT
>
>
>      +------------------------------------------------------------+
>      | Ensure that you have read the CircleMUD Mailing List FAQ:  |
>      |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
>      +------------------------------------------------------------+
>


--------------------------------------------------------------------------
Ron Hensley  (ronh@intercom.net)
Network Administrator - ICNet Internet Services
--------------------------------------------------------------------------


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT