Re: [NEWBIE][CODE] invalid_race/invalid_class

From: Jared Noble (jnoble@inreach.com)
Date: 03/06/01


> Check each of the ITEM_ANTI_XXXXX
> that is probably where your error is..

I've rewrote the entire thing several times by hand assuming it was a
spacing problem. I've double checked that indeed the ITEM_ANTI_XXXXX's are
defined properly in structs.h and they are.

Parse errors are normally due to a missing () {} [] or funky carrage returns
from cut/pasting from a text editor right?

Anyhow, I went ahead and cut invalid_class and pasted it over invalid_race,
changed the class names to the race names etc... again I got the warning to
add parentheses. So, I went ahead and added them but still I'm having the
same parse problem.

int 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_HALF_ELF) && IS_HALF_ELF(ch))) ||
      ((IS_OBJ_STAT(obj, ITEM_ANTI_DWARF) && IS_DWARF(ch)))
      ((IS_OBJ_STAT(obj, ITEM_ANTI_HALFLING) && IS_HALFLING(ch))) ||
      ((IS_OBJ_STAT(obj, ITEM_ANTI_GNOME) && IS_GNOME(ch)))) ||
        return 1;
  else
        return 0;
}

Ok... let's start backwards. Here are my race definitions from utils.h

#define IS_HUMAN(ch)            (!IS_NPC(ch) && \
                                (GET_RACE(ch) == RACE_HUMAN)
#define IS_ELF(ch)              (!IS_NPC(ch) && \
                                (GET_RACE(ch) == RACE_ELF)
#define IS_HALF_ELF(ch)         (!IS_NPC(ch) && \
                                (GET_RACE(ch) == RACE_HALF_ELF)
#define IS_DWARF(ch)            (!IS_NPC(ch) && \
                                (GET_RACE(ch) == RACE_DWARF)
#define IS_HALFLING(ch)         (!IS_NPC(ch) && \
                                (GET_RACE(ch) == RACE_HALFLING)
#define IS_GNOME(ch)            (!IS_NPC(ch) && \
                                (GET_RACE(ch) == RACE_GNOME)

And here are my Anti-Race definitions structs.h:

#define ITEM_ANTI_HUMAN    (1 << 17)    /* Not usable by Humans         */
#define ITEM_ANTI_ELF      (1 << 18)    /* Not usable by Elves          */
#define ITEM_ANTI_HALF_ELF (1 << 19)    /* Not usable by Half-Elves     */
#define ITEM_ANTI_DWARF    (1 << 20)    /* Not usable by Dwarves        */
#define ITEM_ANTI_HALFLING (1 << 21)    /* Not usable by Halflings      */
#define ITEM_ANTI_GNOME    (1 << 22)    /* Not usable by Gnomes         */

Oh and the definition for IS_OBJ_STAT although I should mention the faq did
not say to modify this is any way.

#define IS_OBJ_STAT(obj,stat)   (IS_SET((obj)->obj_flags.extra_flags,stat))

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/04/01 PST