An Extended Bitvectors Problem

Posted by Nick Cash on Fri 16 Jan 2004 01:59 AM — 7 posts, 16,415 views.

USA #0
I was helpping a friend of mine install a quest snippet she found into her mud, but her mud uses extended bit vectors, so these are the only stragglers that I've got no clue how to fix since I don't use extended bit vectors. Now, I don't know if it was a problem with the installation of the extended bit vectors, or really anything else. Anyways, have a look.

SMAUG1.4a R4 now compiling... o/quest.o
quest.c: In function `find_quest_mob':
quest.c:724: request for member `bits' in something not a structure or union
quest.c: In function `find_quest_obj':
quest.c:773: request for member `bits' in something not a structure or union
make[1]: *** [o/quest.o] Error 1

Now, the lines (724 and 773 ) are the same, and both look like this:

       && !xIS_SET(victim->in_room->room_flags, ROOM_SAFE)

One of the functions is as follows:

CHAR_DATA *find_quest_mob( CHAR_DATA *ch)
{
  CHAR_DATA *victim=NULL;
  int counter, mob_vnum, level_diff;

     for (counter = 0; counter < 2000; counter ++)
     {
	mob_vnum = number_range(50, 32000); /* Raise 32000 to your highest mobile vnum */

	if ( (victim = get_mob(mob_vnum) ) != NULL )
	{
	    level_diff = victim->level - ch->level;

            if (((level_diff < questmaster->level_range && level_diff > -questmaster->level_range) 
                || (ch->level > 30 && ch->level < 40 && victim->level > 30 && victim->level < 50) 
                || (ch->level > 40 && victim->level > 40)) 
	        && victim->pIndexData->pShop == NULL 
		&& victim->pIndexData->rShop == NULL 
    		&& !xIS_SET( victim->act, ACT_PRACTICE) 
             && !xIS_SET(victim->in_room->room_flags, ROOM_SAFE)
                && in_hard_range(ch, victim->in_room->area)
                && !xIS_SET( victim->act, ACT_NOQUEST) 
                && !xIS_SET( victim->act, ACT_PET) 
    		&& !xIS_SET( victim->act, ACT_IMMORTAL))
             return victim;
	    else 
             continue;
	}
    }
  return victim;
}

The other does the same thing for objects.

Hopefully you can tell me what the error is about because it looks fine to me, then again, I'm an SWR person.

Thanks in advance.
Amended on Fri 16 Jan 2004 02:09 AM by Nick Cash
USA #1
What is xIS_SET defined to?
USA #2
Same thing as IS_SET, just with extended bits I think.
USA #3
But "with extended bits" is the important part. :) Could you paste it please?
USA #4
In all likelyhood, the room flags on that mud aren't extended bitvectors. Try just removing the x in the xIS_SET call and see what you get.
USA #5
A safer solution would be to actually go look up exactly what xIS_SET does, and to set exactly what the room flags are... changing things without knowing what you're doing can lead to big trouble.
Australia Forum Administrator #6
xIS_SET is in mud.h, like this:


/*
 * Here are the extended bitvector macros:
 */
#define xIS_SET(var, bit)       ((var).bits[(bit) >> RSV] & 1 << ((bit) & XBM))
#define xSET_BIT(var, bit)      ((var).bits[(bit) >> RSV] |= 1 << ((bit) & XBM))
#define xSET_BITS(var, bit)     (ext_set_bits(&(var), &(bit)))
#define xREMOVE_BIT(var, bit)   ((var).bits[(bit) >> RSV] &= ~(1 << ((bit) & XBM)))
#define xREMOVE_BITS(var, bit)  (ext_remove_bits(&(var), &(bit)))
#define xTOGGLE_BIT(var, bit)   ((var).bits[(bit) >> RSV] ^= 1 << ((bit) & XBM))
#define xTOGGLE_BITS(var, bit)  (ext_toggle_bits(&(var), &(bit)))
#define xCLEAR_BITS(var)        (ext_clear_bits(&(var)))
#define xIS_EMPTY(var)          (ext_is_empty(&(var)))
#define xHAS_BITS(var, bit)     (ext_has_bits(&(var), &(bit)))
#define xSAME_BITS(var, bit)    (ext_same_bits(&(var), &(bit)))


However you are right that you need to be cautious in applying a snippet that uses a different way of handling bit vectors.

I would take a look at the definition for room_flags, as that is what is causing the problem. In my copy I see this:


    int                 room_flags;
    EXT_BV              progtypes;           /* mudprogs */


Note that room_flags is *not* an extended bitvector, whereas progtypes is.

Now, you might make room_flags an EXT_BV, so that particular line compiles, but you will then hit problems with loading/saving the area, as the load/save routines have to change to reflect that.

Alternatively, go to the normal bitflags (IS_SET not xIS_SET), if you can make that work (eg. if all the bits are not already in use).