Re: Finding a class in a room

From: ShadowLord (dkoepke@california.com)
Date: 06/08/96


On Sat, 8 Jun 1996, Rob Stewart wrote:

>   if (IS_SET(bitvector, FIND_CHAR_ROOM)) {
>     if ((*tar_ch = get_char_room_vis(ch, name))) {
>       return (FIND_CHAR_ROOM);
>     }
>   }

You can't assign a integer to a variable cast as a char_data.  What you
could d is something like:


  struct char_data * get_class_room (struct char_data *ch, int class)
  {
    struct char_data * tch;

    for (tch = world[ch->in_room].people; tch; tch = tch->next_in_room)
      if (GET_CLASS(tch) == class)
        return (tch);

    return NULL;
  }


...make FIND_CLASS_WARRIOR, FIND_CLASS_THIEF, FIND_CLASS_MAGE, etc. then
in generic_find do things like:

  if (IS_SET(bitvector, FIND_CLASS_WARRIOR)) {
    if ((*tar_ch = get_class_room(ch, CLASS_WARRIOR))) {
      return (FIND_CLASS_WARRIOR);
    }
  }

Instead of those last two steps, you can keep the get_class_room()
function and then, in generic_find(), do:

  if (IS_SET(bitvector, FIND_CLASS)) {
    if ((*tar_ch = get_class_room(ch, atoi(name)))) {
      return (FIND_CLASS);
    }
  }

Then pass the class number as a string (eg., "0"==CLASS_MAGIC_USER).
That's just two ways to do it.  Also, the get_class_room() function
doesn't check if 'ch' can see the selected character.  You can easily
modify that function or make a seperate function that does a simple little
CAN_SEE(ch, tch)...  No biggy.

Good luck.

	-dak



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