On Sun, 18 Jan 1998, Zervun wrote:
> Well I've started diving in and trying to convert obuild to the 128
> bitvector stuff. Some of the fixes seem to be simple however
> I'm having trouble with sprintbits/sprintbitarray
I htink I'd change it to something like this:
+/* warning! mailer code */
> void sprintbits(long vektor,char *outstring)
> {
+#define ARRAY_SIZE 4
! int i, j, *p;
> char flags[53]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
>
> strcpy(outstring,"");
+ for (j = 0, p = &vektor; j < ARRAY_SIZE; j++, p++) {
> for(i=0;i<32;i++)
> {
! if (*p & 1) {
> *outstring=flags[i];
> outstring++;
> };
> vektor>>=1;
> };
+ if(j < ARRAY_SIZE - 1)
+ *(outstring++) = ' ';
+ }
> *outstring=0;
> };
I think that should work, assuming you always have exactly 128-bit
bitvectors and your outstring has enogh space for a fully loaded bitvector
group. Just pass it the first element of the bitvector set, as in:
sprintbits(MOB_FLAGS(mob_proto + i), buf);
If you expand to greater than 128 bits, just change the ARRAY_SIZE.
Sam
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST