I am working my way through the SMAUG FUSS code to adapt it to the Lua interface, and I have struck one strange thing. Perhaps someone can clear it up for me?
Look at the define for MAX_BITS:
OK, we can see from the above that MAX_BITS is 128 (4 * 32).
However, the first bit you can set is bit zero, right? So the highest bit you can set is MAX_BITS - 1 (127) not MAX_BITS. Agreed?
There seem to be heaps of places in the code where you are allowed to set up to, and including MAX_BITS. For example, in act_wiz.c:
Isn't that wrong? Shouldn't it be:
Ditto for about 30 other places.
Look at the define for MAX_BITS:
/*
* 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
OK, we can see from the above that MAX_BITS is 128 (4 * 32).
However, the first bit you can set is bit zero, right? So the highest bit you can set is MAX_BITS - 1 (127) not MAX_BITS. Agreed?
There seem to be heaps of places in the code where you are allowed to set up to, and including MAX_BITS. For example, in act_wiz.c:
if( value < 0 || value > MAX_BITS )
ch_printf( ch, "Unknown flag: %s\r\n", arg2 );
else
xTOGGLE_BIT( Class->affected, value );
Isn't that wrong? Shouldn't it be:
if( value < 0 || value >= MAX_BITS )
ch_printf( ch, "Unknown flag: %s\r\n", arg2 );
else
xTOGGLE_BIT( Class->affected, value );
Ditto for about 30 other places.