Re: Bitvectors

From: Mike Stilson (mike@velgarian.sytes.net)
Date: 01/04/02


On Fri, Jan 04, 2002 at 02:38:21AM -0600, David Cole wrote:
>Chuck Reed Wrote:
>> Did you remember to modify AFF_FLAGGED so that it understands your new
>> bitvector scheme?
>>
>
>Mike Breuer Wrote:
>>If you have different affect slots now, you'll need to make IS_AFFECTED2()
>>IS_AFFECTED3 macros to handle that.  That's just a guess from what you've
>>given me though.
>
>
>If your meaning the macro's:
>
>#define AFF_FLAGS(ch) ((ch)->char_specials.saved.affected_by)
[snip]
>#define IS_AFFECTED4(ch, skill) (AFF4_FLAGGED((ch), (skill)))
>

What about changing it to an array in char_specials_saved
(affected_by[4]) then change the definitions to

#define AFF_FLAGGED(ch, num, flag) (IS_SET(AFF_FLAGS(ch), (num)), (flag))
#define AFF_FLAGS(ch, num) ((ch)->char_specials_saved.affected_by[(num)])
#define IS_AFFECTED(ch, num, flag) (AFF_FLAGGED((ch), (num), (skill))

That'll break all the aff_flag usages and need a bunch of editing but
it'll also make sure you get all of them changed, and it's pretty simple
to handle with a perl/sed/awk (take your pick) script.

My scripts are all rusty again, but...
something like
gawk {if $0 ~ "IS_AFFECTED(.*, .*)") sub(/, /, ", 0, "); print $0;}
to convert all the normal "IS_AFFECTED()"'s to the new format, then:
perl -i -pe 's/IS_AFFECTED(\d+)\((.*), (.*)\)/IS_AFFECTED($2, $1, $3)/g' *.c
to convert all of your IS_AFFECTED's to the 3-arg format.

Substitute as needed for other macro calls, or just switch them all to
AFF_FLAGGED for consistency such as AFF(\d+)_FLAGGED\(....\)

Just a thought.
-mike

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT