Gammon Forum
Entire forum
SMAUG
SMAUG coding
Bitvectors are all used...
Bitvectors are all used...
|
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| AlaricX
(23 posts) bio
|
Date
| Sat 25 May 2002 04:47 PM (UTC) |
Message
| i am getting frustrated, because i need to add room_flags but i am out of bitvectors, i just now tried a
typedef enum
{
}
containing all of them, but is there a better way to do this to get more than 32 room flags?
--Alaric X | top |
|
Posted by
| Nick Gammon
Australia (22,973 posts) bio
Forum Administrator |
Date
| Reply #1 on Sun 26 May 2002 02:09 AM (UTC) |
Message
| The latest SMAUG uses "extended bitvectors" which are supposed to give you about 4 times that many.
Look for this stuff in mud.h ...
/*
* Defines for extended bitvectors
*/
#ifndef INTBITS
#define INTBITS 32
#endif
#define XBM 31 /* extended bitmask ( INTBITS - 1 ) */
#define RSV 5 /* right-shift value ( sqrt(XBM+1) ) */
#define XBI 4 /* integers in an extended bitvector */
#define MAX_BITS XBI * INTBITS
/*
* Structure for extended bitvectors -- Thoric
*/
struct extended_bitvector
{
int bits[XBI];
};
...
/*
* 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)))
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| AlaricX
(23 posts) bio
|
Date
| Reply #2 on Sun 26 May 2002 05:22 AM (UTC) |
Message
| like the ones for objject types or object flags? will they still work right if i convery the current ones to extended bitvectors? or would i need to change all the code? am example of how to change these two example values would be greatly appreciated: (these are just examples)
#define ROOM_DARK BV00
#define ROOM_DEATH BV01
thanks in advance. | top |
|
Posted by
| Nick Gammon
Australia (22,973 posts) bio
Forum Administrator |
Date
| Reply #3 on Mon 27 May 2002 01:04 AM (UTC) |
Message
| For the defines, instead of:
#define ROOM_DARK BV00
#define ROOM_DEATH BV01
you would have:
#define ROOM_DARK 0
#define ROOM_DEATH 1
To test, instead of:
if ( IS_SET(pRoomIndex->room_flags, ROOM_DARK) )
you would have:
if ( xIS_SET(pRoomIndex->room_flags, ROOM_DARK) )
For the room flags, instead of:
int room_flags;
you would have:
EXT_BV room_flags;
To read the bits, instead of:
room_flags = fread_number (fp);
you would have:
room_flags = fread_bitvector (fp);
... and so on. It will be a big job. :)
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| AlaricX
(23 posts) bio
|
Date
| Reply #4 on Mon 27 May 2002 05:33 AM (UTC) |
Message
| argh... :( too bad. thanks for the help anyway. | top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
12,484 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
top
Quick links:
MUSHclient.
MUSHclient help.
Forum shortcuts.
Posting templates.
Lua modules.
Lua documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.