Manual:DIL Manual/isset()
Jump to navigation
Jump to search
isset()
Function (integer). Tells whether any of some bits are set in an integer.
isset(value : integer, bits : integer)
Most flag fields (flags, charflags, manipulate, openflags, exit_info[dir], ...) hold several flags as bits of one integer. isset(value, bits) is TRUE (1) when value and bits have at least one bit in common, and FALSE (0) when they have none.
Parameters
| Name | Type | Meaning |
|---|---|---|
| value | integer | The integer to look at, usually a flag field. |
| bits | integer | The bit or bits to look for: a flag constant such as EX_CLOSED, or several joined with |.
|
Returns
Integer: 1 if any bit of bits is set in value, otherwise 0. If either argument fails (for example a field of a null unit), the result fails, and a failed value is false in every test.
Notes
- With several bits,
isset(u.charflags, CHAR_BLIND | CHAR_HIDE)is true when either is set. To require all of them, test each:isset(f, A) and isset(f, B). - The flag constants are in
vme/include/vme.h(UNIT_FL_*,CHAR_*,MANIPULATE_*,EX_*, ...) andvalues.h. set()andunset()change the bits;isset()only reads them.- A field of a null unit fails, so
isset(u.flags, X)andnot isset(u.flags, X)behave oddly whenuis null: testu == nullfirst.
Example
dilbegin integer door_closed(rm : unitptr, dir : integer);
code
{
if (rm == null)
return (FALSE);
if (rm.type != UNIT_ST_ROOM)
return (FALSE);
return (isset(rm.exit_info[dir], EX_CLOSED));
}
dilend
Tells whether the exit in direction dir of a room is closed.