Re: [CODING]: Object Extra Flags

From: Daniel A. Koepke (
Date: 11/19/99

On Thu, 18 Nov 1999, Ryan Kahn wrote:

> I added the checks in handler.c and objsave.c where the game checked
> to see if the item was wearable by that specific person. Everything
> over ITEM_ANTI_HUMAN, which is (1 << 19) .. Does strange things.  If
> the item is ITEM_ANTI_ for each race except one, above human, that
> race cannot wear it...

Well, I was a bit short on rent this month, so I pawned the ol' crystal
ball for a few bucks.  In other words, you'll need to provide me with a
bit more information for an actual analysis.  But what this sounds like
(and I'm only guessing) is a problem with your implementation of the
flags.  Not that it couldn't be some mysterious architecture problem, but
there's not a very good chance of that at all.

So the question is, what are these ITEM_ANTI_xxx flags defined as?  And,
moreover, how are you checking them?  Basically, the definitions should
look something like (where 'a', 'b', etc., are filling in for the
appropriate numerical literal):

    #define RACE_HUMAN             0
    #define RACE_ELF               1
    #define RACE_DWARF             2
    #define RACE_DRACONIAN         3
    #define RACE_HALFGIANT         4
    #define NUM_RACES              5


    #define ITEM_ANTI_HUMAN        (1 << a)
    #define ITEM_ANTI_ELF          (1 << b)
    #define ITEM_ANTI_DWARF        (1 << c)
    #define ITEM_ANTI_DRACONIAN    (1 << d)
    #define ITEM_ANTI_HALFGIANT    (1 << e)

You'd have some macros in utils.h like these,

    #define IS_HUMAN(ch)           (GET_RACE(ch) == RACE_HUMAN)
    #define IS_ELF(ch)             (GET_RACE(ch) == RACE_ELF)
    #define IS_DWARF(ch)           (GET_RACE(ch) == RACE_DWARF)

and the code checking for these flags would be something like:

    invalid_race (struct char_data *ch, struct obj_data *obj) {
        if ((IS_OBJ_STAT(obj, ITEM_ANTI_HUMAN) && IS_HUMAN(ch)) ||
            (IS_OBJ_STAT(obj, ITEM_ANTI_ELF) && IS_ELF(ch)) ||
            (IS_OBJ_STAT(obj, ITEM_ANTI_DWARF) && IS_DWARF(ch)) ||
                return (1);
                return (0);

Then you'd call invalid_race() in the same manner as invalid_align() and
invalid_class() are called in equip_char(), handler.c.

It's all Mailer Code(tm), of course.


     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  |

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