On Thu, 19 Dec 1996, Daniel Koepke wrote: > On Thu, 19 Dec 1996, The Dark One wrote: > > > could I do this? > > #define AFF_FLAGS(ch) ((ch)->char_specials.save.affected_by[4]) > > You wouldn't want to, since that'd still just give you 32 bits. You > want the following two macros: > > #define FIELD(x) ((x) < 32 ? 1 : (x) / 32) That should be: #define FIELD(x) ((x) < 32 ? 0 : (x) / 32) if you want it right [A 4 space array goes from 0 to 3] But then again, if you do this: #define FIELD(x) (int) ((x) / 32) then (x < 32) / 32 will always be 0, which was I had in mind first time. > #define BIT(x) ((x) < 32 ? (x) : (x) % 32) Ofcoz this works, but (x < 32) MOD 32) will always be x [% is MOD, or the rest of x / 32) > > Now we change AFF_FLAGS(ch) to: > > #define AFF_FLAGS(ch, v) ((ch)->char_specials.saved.affected_by[(v)]) > > And AFF_FLAGGED(ch) to: > > #define AFF_FLAGGED(ch, bit) \ > IS_SET(AFF_FLAGS((ch), FIELD(bit)), (1 << BIT(bit))) > > Note that I changed the original posters FIELD/BIT [whatever he named > them] macros. BIT(x) was original defined as ((x) % 32) which, when the > number was under 32 would return a decimal value [and always equate to > 1]. I've still yet to test this, but it seems feasible from where I'm > sitting... Dont know what you use of compiler, but in my books % always give the rest of a division. Or is my brain totally dead ? [I have been away from MUD coding for a few months now :/ ] Erik Niese-Petersen Aka Quint the typo dane Realms of Darkness IMP +-----------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://cspo.queensu.ca/~fletcher/Circle/list_faq.html | +-----------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/18/00 PST