Re: Code thats out there!

From: Jeremy Elson (jelson@blaze.cs.jhu.edu)
Date: 06/16/95


> > on wizbits, as an aside to hex, have you guys started using that idea 
> > whereby you could stuff like 80 bits into one var? i heard some bits and 
> > pieces from pythe or fred about some sorta linked long shit or somethin, 
> > i dunno... wonderin anything ever came of that, and if so, what? ;}
> 
> I haven't heard of 'em at all..unless you're talking about a long 
> double.  I know under Borland C's DOS compiler, a long double is 80 bits, 
> but I was under the impression that it wasn't ANSI, portable, or even 
> especially kosher for use in everyday code.  You could also just use an 
> array of long[2] and write an intelligent function-like macro to figure 
> out which long to compare with, but you'll run smack up against word 
> ordering on different machines, as well as the cases where you need to 
> check bits from both elements of the array.

You can always use C-structure bitfields.  If I was writing Circle from
scratch today, I'd ditch the entire IS_SET() macros and use bitfields instead.
You can have as many bits as you want and you don't need to use macros to
access them.  i.e.:

struct player_bits {
   int killer:1;
   int thief:1;
   int frozen:1;
   int writing:1;
   int mailing:1;
   int crash:1;
   int siteok:1;
   int noshout:1;
};

etc.  The structure above takes up 8 bits (i.e. 1 byte) in memory but can
nevertheless be accessed as a normal structure, i.e.:

vict->player_bits.noshout = 1;
send_to_char("Noshout enabled.\n\r", ch);

or, 

if (ch->player_bits.noshout) {
  send_to_char("You can't shout!\n", ch);
  return;
}


   
Jeremy



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