As usual, I am struggling with bitvector_t and 64 flag problems. :) Say I have a line like this: sprintbit(GET_OBJ_EXTRA(OLC_OBJ(d)), extra_bits, bitbuf, sizeof(bitbuf)); I have 35 options in the menu itself. I can choose 1-31 just fine, but when I press 32 or more, it prints out the wrong bits. (Say 34 is ANTI_DRUID, it prints BLAZING UNUSED UNUSED UNUSED or something.) Any idea what causes this? I'm been banging my head against bitvector issues for months, and I can never manage to get them solved. I keep trying to work around them, but it seems that in this case due to my design decisions, I really do need to be able to have more than 32 flags. Archive searches have turned up numerous discussions, but I can't manage to apply the principles to my mud in order to actually cause the damn thing to respect my desires to have 64 flags that read in and out and respond correctly in game. *sigh* Also, I was hoping is that someone could take a look at my functions to see if they are appropriately set up to work with each other in the pursuit of having 64 bitvectors. Any assistance at all is appreciated. This is so amazingly frustrating, because of all the really good modifications I've managed to pout in the code . . . it seems so terrible to be brought down by something which is always referred to as being such a simple series of changes to make. :( Here are my functions (Mostly ones I found in list archives and modified): /* Sprintbit changed to bitvector_t from size_t */ bitvector_t sprintbit(bitvector_t bitvector, const char *names[], char *result, size_t reslen) { size_t len = 0, nlen; long nr; *result = '\0'; for (nr = 0; bitvector && len < reslen; bitvector >>= 1) { if (IS_SET(bitvector, 1)) { nlen = snprintf(result + len, reslen - len, "%s ", *names[nr] != '\n' ? names[nr] : "UNDEFINED"); if (len + nlen >= reslen || nlen < 0) break; len += nlen; } if (*names[nr] != '\n') nr++; } if (!*result) len = strlcpy(result, "NOBITS ", reslen); return (len); } /* Sprintbits has 64 flags and the loop counts to 64 instead of 32 */ void sprintbits(bitvector_t vektor,char *outstring) { int i; char flags[65]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ#$%&'()*+,-."; strcpy(outstring,""); for (i=0;i<64;i++) { if (vektor & 1) { *outstring=flags[i]; outstring++; }; vektor>>=1; }; *outstring=0; }; /* Asciiflag_conv works with the same flags as sprintbits (I think) :) */ bitvector_t asciiflag_conv(char *flag) { bitvector_t flags = 0; int is_number = 1; register char *p; for (p = flag; *p; p++) { if (islower(*p)) flags |= 1 << (*p - 'a'); else if (isupper(*p)) flags |= 1 << (26 + (*p - 'A')); else if (ispunct(*p)) flags |= 1 << (52 + (*p - '#')); if (!isdigit(*p)) is_number = 0; } if (is_number) sscanf(flag, "%Lu", &flags); return (flags); } -Mathew -- +---------------------------------------------------------------+ | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html | | Newbie List: http://groups.yahoo.com/group/circle-newbies/ | +---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 06/25/03 PDT