Re: bitfield advantages

From: Michael Buselli (mhbusell@midway.uchicago.edu)
Date: 03/11/96


On Mon, 11 Mar 1996, Jaco van Iterson wrote:

> Switching your own code over to bitfields is very hard work and I suggest
> you only do that when you realy need to do it, if you are running out of
> flags and you want to clean up your code. 

     How do bitfields help if you are running out of flags?  I'm currently
using about 40 affection flags and I doubt that bitfields would have let
me squeeezed them into that 32 bit long integer that standard circle uses. 
The addition of more than 32 flags would force the player file to become
corrupted anyway.  In addition, I have several places in my code, namely
do_stat_char(), that look something like this:

  for (j = 0; j < AFFECT_VECTS; j++)
    for (i = 0; i < BITS_IN_LONG; i++)
      if (IS_AFFECTEDX(k, j, (1 << i)))
        /* do interesting stuff here */

/* #define IS_AFFECTEDX(ch, j, flag) (IS_SET(AFFX_FLAGS((ch), (j)), (flag))) */
/* #define AFFX_FLAGS(ch, j)    ((ch)->char_specials.saved.affected_by[(j)]) */

Can you do that with bitfields?  Because if it's possible to do it without
some special home made function call or unionizing (which I'm not sure is
possible) something in the declarations, I've never seen any code
implementing it.

> It would be very nice if the standard circle code would switch over
> to bitfields though.

     See above concerns about this.  I don't think the standard should be
using something that makes it more difficult for me to expand my mud.  How
would you represent the situation I presented above with bitfields?

--
Michael Buselli m-buselli@uchicago.edu
http://student-www.uchicago.edu/users/mhbusell/



This archive was generated by hypermail 2b30 : 12/07/00 PST