I'm having trouble reading an extended bit vector. I'm trying to use the isflagged functionality from SMAUGFUSS ported into SMAUG 1.4a. Everything is compiling, being set and reading/saving from disc (as far as I can tell) but there's a strange conversion error when ifchecking and reading the flag.
setting flag:
checking flag:
vstat
pfile
when stepping through the code - specifically in the "isflagged" portion of mprog_do_ifcheck(). The flag is being read as '2' which what is the value being set in script but once it does the flag = abs(flag) % MAX_BITS; it is converted to '64' and then returns as false or unset.
defines:
setting flag:
mpflag noexpire $n justtesting 2
checking flag:
if isflagged($n,justtesting,2)
mpecho checking isflagged for $n - $n has a flag
else
mpe isflagged not working yet.
endif
vstat
Vnum: 3 Tag: justtesting Timer: 0
Type: XBIT Data: [1 1]
pfile
#VARIABLE
Type 2
Flags 0
Vnum 3
Ctime 1714581585
Mtime 1714581783
Rtime 0
Timer 0
Tag justtesting~
Xbit 6
End
when stepping through the code - specifically in the "isflagged" portion of mprog_do_ifcheck(). The flag is being read as '2' which what is the value being set in script but once it does the flag = abs(flag) % MAX_BITS; it is converted to '64' and then returns as false or unset.
flag = abs(flag) % MAX_BITS; // hrmm, Vooodoo
switch (vd->type)
{
case vtSTR:
case vtINT:
return FALSE;
case vtXBIT:
if (xIS_SET(*(EXT_BV*)vd->data, flag) == TRUE)
{
bFlag = TRUE;
}
else
{
bFlag = FALSE;
}
return bFlag;
}
defines:
#define xIS_SET(var, bit) ((var).bits[(bit) >> RSV] & 1 << ((bit) & XBM))
#define xSET_BIT(var, bit) ((var).bits[(bit) >> RSV] |= 1 << ((bit) & XBM))
#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