i am getting frustrated, because i need to add room_flags but i am out of bitvectors, i just now tried a
typedef enum
{
}
containing all of them, but is there a better way to do this to get more than 32 room flags?
--Alaric X
The latest SMAUG uses "extended bitvectors" which are supposed to give you about 4 times that many.
Look for this stuff in mud.h ...
/*
* Defines for extended bitvectors
*/
#ifndef INTBITS
#define INTBITS 32
#endif
#define XBM 31 /* extended bitmask ( INTBITS - 1 ) */
#define RSV 5 /* right-shift value ( sqrt(XBM+1) ) */
#define XBI 4 /* integers in an extended bitvector */
#define MAX_BITS XBI * INTBITS
/*
* Structure for extended bitvectors -- Thoric
*/
struct extended_bitvector
{
int bits[XBI];
};
...
/*
* Here are the extended bitvector macros:
*/
#define xIS_SET(var, bit) ((var).bits[(bit) >> RSV] & 1 << ((bit) & XBM))
#define xSET_BIT(var, bit) ((var).bits[(bit) >> RSV] |= 1 << ((bit) & XBM))
#define xSET_BITS(var, bit) (ext_set_bits(&(var), &(bit)))
#define xREMOVE_BIT(var, bit) ((var).bits[(bit) >> RSV] &= ~(1 << ((bit) & XBM
)))
#define xREMOVE_BITS(var, bit) (ext_remove_bits(&(var), &(bit)))
#define xTOGGLE_BIT(var, bit) ((var).bits[(bit) >> RSV] ^= 1 << ((bit) & XBM))
#define xTOGGLE_BITS(var, bit) (ext_toggle_bits(&(var), &(bit)))
#define xCLEAR_BITS(var) (ext_clear_bits(&(var)))
#define xIS_EMPTY(var) (ext_is_empty(&(var)))
#define xHAS_BITS(var, bit) (ext_has_bits(&(var), &(bit)))
#define xSAME_BITS(var, bit) (ext_same_bits(&(var), &(bit)))
like the ones for objject types or object flags? will they still work right if i convery the current ones to extended bitvectors? or would i need to change all the code? am example of how to change these two example values would be greatly appreciated: (these are just examples)
#define ROOM_DARK BV00
#define ROOM_DEATH BV01
thanks in advance.
For the defines, instead of:
#define ROOM_DARK BV00
#define ROOM_DEATH BV01
you would have:
#define ROOM_DARK 0
#define ROOM_DEATH 1
To test, instead of:
if ( IS_SET(pRoomIndex->room_flags, ROOM_DARK) )
you would have:
if ( xIS_SET(pRoomIndex->room_flags, ROOM_DARK) )
For the room flags, instead of:
int room_flags;
you would have:
EXT_BV room_flags;
To read the bits, instead of:
room_flags = fread_number (fp);
you would have:
room_flags = fread_bitvector (fp);
... and so on. It will be a big job. :)
argh... :( too bad. thanks for the help anyway.