Re: Very Strange Results on an Alpha

From: John Evans (evansj@DATAWEST.NET)
Date: 06/16/98


On Wed, 17 Jun 1998, Chuck Carson wrote:

> I have 34 PRF's defined as so:
>
> #define PRF_BRIEF               0
> ...
> ...
> #define PRF_DISP_MAXEMOVE       31
> #define PRF_DISP_MAXMANA        32
> #define PRF_DISP_VIS            33
>
> All flags work except 31. If I try and use it like in
> an if statement, I get warning, always evaluates to 0.

I don't remember if you used the same methods that I did or not. I used
the method from Niese-Petersen <Tenp@cris.com>, and in there is alot of
division by 32 to make sure that the right bits get toggled on the right
ints. This caused problems once I hit bit 31 and above because computers
start counting at 0, and to seperate the vector off to the right int for
fiddling with, I had to change all the code like:

void sprintbitarray(int bitvector[], char *names[], int maxar,
                    char *result)
{
  int nr, teller, found = FALSE;

  *result = '\0';

  for(teller = 0; teller < maxar && !found; teller++)
    for (nr = 0; nr < 32 && !found; nr++) {
      if (IS_SET_AR(bitvector, (teller*31)+nr))
        if (*names[(teller*32)+nr] != '\n') {
          if (*names[(teller*32)+nr] != '\0') {
            strcat(result, names[(teller*32)+nr]);
            strcat(result, " ");
          }
        } else {
          strcat(result, "UNDEFINED ");
        }
      if (*names[(teller*32)+nr] == '\n')
        found = TRUE;
    }

  if (!*result)
    strcpy(result, "NOBITS ");
}

To the following:
void sprintbitarray(int bitvector[], char *names[], int maxar,
                    char *result)
{
  int nr, teller, found = FALSE;

  *result = '\0';

  for(teller = 0; teller < maxar && !found; teller++)
    for (nr = 0; nr < 31 && !found; nr++) {
      if (IS_SET_AR(bitvector, (teller*31)+nr))
        if (*names[(teller*31)+nr] != '\n') {
          if (*names[(teller*31)+nr] != '\0') {
            strcat(result, names[(teller*31)+nr]);
            strcat(result, " ");
          }
        } else {
          strcat(result, "UNDEFINED ");
        }
      if (*names[(teller*31)+nr] == '\n')
        found = TRUE;
    }

  if (!*result)
    strcpy(result, "NOBITS ");
}


Notice that the only thing that I changed was the '32's to '31's. Nothing
else needed to be changed. There are several point throughout the code
that need this change in the code and in the header files as well.

If you're using some other system, then perhaps my info will give you some
insight into your particular problem.

Good luck!

John Evans <evansj@datawest.net>
http://www.hi-line.net/~evansj/              telnet://spear.gator.net:1066

Any sufficiently advanced technology is indistinguishable from magic.
--Arthur C. Clarke


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