Re: Lighting rooms with objects in your inventory.

From: Daniel A. Koepke (
Date: 04/24/02

On Wed, 24 Apr 2002, David Cole wrote:

> > try using OBJ_FLAGGED(obj, ITEM_ILLUMINATE) instead of extra_flags =
> > item_illuminate
> Tha made it look a little better, [...]

Well, it did more than merely make it look better; it made it (more)
correct.  Unless the ONLY flag set was ITEM_ILLUMINATE, the extra_flags
equality check would NOT evaluate true.  In this instance, you can think
of '==' as an element-wise comparison of the bitsets -- both the left and
right side must have all the same elements (bits set, flags) for it be
true.  The OBJ_FLAGGED macro, which is just a convenience form for
bit-twiddling, is used to test for a single element of the given bitset.

> Any other ideas?

Only, in the future, use effective communication.  Chances are, you're not
paying by the word for your outgoing messages, so there's not much excuse
to leave us with just, "it's not working."  For a variety of (mostly
obvious) reasons, being that obtuse decreases your chance of getting a
meaningful response.

>     for (obj = ch->carrying; obj; obj = next_obj) {
>       next_obj = obj->next_content;
>         world[ch->in_room].light ++;
>  }

Knowing that you've already solved your own problem by looking at the
existing source code (which, if I might suggest, you ought to quite
thoroughly before asking), I'll provide a quick rundown of the solutions,

Assuming you're really intending to check the inventory, and not the
equipment of the character, this loop is correct, but can be shortened to:

  for ( obj = ch->carrying; obj; obj = obj->next_content )

If you're wanting to go through their equipment:

  for ( i = 0; i < NUM_WEARS; i++ )
      if ( GET_EQ(ch, i) && OBJ_FLAGGED(GET_EQ(ch, i), ITEM_ILLUMINATE) )

-dak: s/contributed contributions/contributed translations/

   | FAQ: |
   | Archives: |
   | Newbie List:   |

This archive was generated by hypermail 2b30 : 06/25/03 PDT