LIB: larger bitvectors - file conversion

From: Robert Mattern (
Date: 06/19/02

This post assumes that you want to convert to 128 bit bitvectors using
the code by Niese-Petersen and Patch by Tony Robbins
It also assumes that you use ascii pfiles.

Heres a way to keep the old pfiles with 32 bit bitvectors running
without a conversion... and switches to the expandable
or more)

This should make a character file(ascii file) entry for preference flags

Pref: abcfgKLM
Prf : 12345:12345:12345:12345

where 12345 is an integer value (using atoi) and the parser
keeps parsing these integers till you max out on the array
size or until the colon is reached, then it substitutes 0 values
for any array members that aren't in the pfile.

I suppose you could do this with world flags also, so that you
don't have to convert them... or at least not until you use olc
on them. You can read in the flags as a single string without
trying to add another space delimited field.

   Takes a character array of format "12345:12345:12345"
   where 12345 represents an integer, and puts each field
   into an integer member of the array of bitvectors.
void sprintarray_conv(long *bitvector, char *flag, int maxar)
  int i, found = FALSE;
  char flag_temp[MAX_STRING_LENGTH];
  char test[MAX_STRING_LENGTH];
  char *p, *q;

  strcpy(test, flag);

  p = test;

  for(i = 0; i < maxar; i++)
    q = flag_temp;
    found = FALSE;
    while(*p && *p != ':') {
      *q = *p;
      found = TRUE;
      *q = '\n';
      bitvector[i] = atoi(flag_temp);
      bitvector[i] = 0;


/* returns the format 12345:12345:12345:12345
   where 12345 is an item in the bitvector array
   maxar times -ironfist
char* sprintarray_write(long bitvector[], int maxar)
  int i;
  char array_buf[MAX_STRING_LENGTH];

  *array_buf = '\0';

  for(i = 0; i < maxar; i++)
    sprintf(buf, "%ld:", bitvector[i]);
    strcat(array_buf, buf);
  return str_dup(array_buf);

this is in load_char(db.c):

        /* remove this after a pwipe when
           all of the chars are converted -ironfist 06-19-2002*/
       else if(!strcmp(tag, "Pref")) {
          /* this puts the converted ascii data in the first integer
             array bitvector */
          ch->player_specials->saved.pref[0] = asciiflag_conv(line);
          /* this sets the rest of the array to 0 */
          for(i = 1; i < PR_ARRAY_MAX; i++)
            ch->player_specials->saved.pref[i] = 0;
        /* end of remove this after a pwipe */
        /* new 128 bits stuff -ironfist */
        else if(!strcmp(tag, "Prf "))
          sprintarray_conv(PRF_FLAGS(ch), line, PR_ARRAY_MAX);

this is in save_char:

/*  can remove this ASAP, dont want to save in char flags anymore...
       sprintbits(PRF_FLAGS(ch), bits);
       fbprintf(fl, "Pref: %s\n", bits);
      fbprintf(fl, "Prf : %s\n",

Anyone see a problem with this code?


   | FAQ: |
   | Archives: |
   | Newbie List:   |

This archive was generated by hypermail 2b30 : 06/25/03 PDT