Re: [long] AFF2 flag

From: Thomas Arp (t_arp@stofanet.dk)
Date: 06/05/02


----- Original Message -----
From: "Ray Campbell" <thrawn@COX.NET>
> I decided to go the AFF2 route after many failed attempts at adding
> 128 bits to my heavily modified, now pl19 code base.  This question
> is posed pertaining to ASCII pfiles and the saving of the AFF2 flags
> to the file.  I copied all instances of AFF, in db.c (I believe this
> is the only place that handles setting up the pfiles?)  My code
> compiles just fine, but the AFF2 flags aren't actually working.
> No weird crashes are happening, it just won't affect the character.

The bug is below - all tags must be 4 chars - "Aff2 " is 5 chars long.

> --snip--
>
>       case 'A':
>         if(!strcmp(tag, "Ac  "))
>           GET_AC(ch) = num;
>         else if(!strcmp(tag, "Act "))
>           PLR_FLAGS(ch) = num;
>         else if(!strcmp(tag, "Aff "))
>           AFF_FLAGS(ch) = asciiflag_conv(line);
   -        else if (!strcmp(tag, "Aff2 "))
   +        else if (!strcmp(tag, "Aff2"))  /* all tags are 4 chars */
>           AFF2_FLAGS(ch) = asciiflag_conv(line);
>         else if(!strcmp(tag, "Affs")) {
>           i = 0;
>           do {
>             fbgetline(fl, line);
>             sscanf(line, "%d %d %d %d %d %d",
>                          &num, &num2, &num3, &num4, &num5, &num6);
>             if(num > 0) {
>               af.type = num;
>               af.duration = num2;
>               af.modifier = num3;
>               af.location = num4;
>               af.bitvector = num5;
>               af.bitvector2 = num6;
>               affect_to_char(ch, &af);
>               i++;
>             }
>           } while (num != 0);
>         } else if(!strcmp(tag, "Alin"))
> --snip--
> above, num6 was added with the af.bitvector2 in db.c, to me this seemed
> like the obvious place where it was setting up the structure of what to
> write in the pfile.  Again, I just followed all instances of AFF.  Does
> anyone see a problem with the above.

Not as long as you make sure to set af.bitvector2 to 0 when initialising.

> One thing I was unsure of, is if that I had to actually make all
> new af.xxx structures, for the new aff2 flags.  It appeared that just
> adding a  .bitvector2 to struct affected_type in structs.h should do
> the trick.  Perhaps i'm wrong?

No, not at all. This is the obvious way to do it.

> My other question, and this I believe is what is making the actuall
> AFF2 flag not stick to the character to begin with is this in utils.c:
<snip of sprintbit func>

NO, don't change sprintbit(). Sprintbit is called throughout the code,
when a bitvector needs to be output as text - 'stat' comes to mind.
What you need to do is call sprintbits(). Difference:

char bitbuf[50];
const char *test[] = {
  "testbit1",
  "testbit2",
  "testbit3",
  "\n"
};

sprintbits(5, bitbuf);
printf("%s\r\n", bitbuf);

sprintbit(5, test, bitbuf);
printf("%s\r\n", bitbuf);

gives the output:

ac
testbit1 testbit3

So you wish to call sprintbits() like this when saving:

    if(AFF2_FLAGS(ch) != PFDEF_AFF2FLAGS) {
      sprintbits(AFF2_FLAGS(ch), bits);
      fbprintf(fl, "Aff2: %s\n", bits);
    }
Note no space between Aff2 and : .


> I do believe, perhaps, if this second hurdle is conqoured, than the
> first will work, for if it actually ever sets the bit, it might actually
> save the thing.

If you look in your pfiles, what format has it saved AFF2 flags in ?

Welcor

--
   +---------------------------------------------------------------+
   | 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