[CODE][NEWBIE??] Problem with IS_NPC(ch) (LONG)

From: Rich M Carpenter (carppy@juno.com)
Date: 04/16/01


I don't often write to the list, prefering to figure out my own
problems, but this one is baffling me.
I am running 3.0bpl17 with Oasis 2.0.0 and no other patches.
I have added races, a few classes, various skills and spells,
as well as more than a few flags of various sorts.
I am running this on Windows ME under Cygwin32 Beta 19.

My problem is this:
A select few of my mobs have found a way past an IS_NPC(ch) check,
and are thus trying to use code meant only for players.
These mobs contain nothing unusual about them, and worked until
yesterday.
I was working on my combat system when the problem began, and the check
they wre bypassing isnt in the combat code.

Here is the code:
int invalid_race(struct char_data *ch, struct obj_data *obj) {
        if (IS_NPC(ch))                <------- This is the check they
are bypassing.
                                     return FALSE;
else {


                                                    if (!IS_OBJ_STAT(obj,
ITEM_DRAGON) && GET_RACE(ch) == RACE_DRAGON)  <- segfault here
                                    return TRUE;


           if (IS_OBJ_STAT(obj, ITEM_DRAGON) && GET_RACE(ch) !=
RACE_DRAGON)
                  return TRUE;

                                                               else


                                                                  return
FALSE;

                                  }
}
GET_RACE(ch) is a player_specials->saved and isn't used for mobs.
I even went so far as to remove all of the action bitvectors for one of
the offenders,
             and hand set the ISNPC bit.  This mob still made it through
the test. Gdb gives a segfault error
on the line noted above.  it returns 64 "@" as the value for saved.race.
If anyone has any idea as to what the problem may be, I'd greatly
appreciate it.
I hope I gave enough info to be useful, if not, let me know what else
would be useful.
sorry about the formatting, My email software is acting a bit strange
right now.
[OFF-TOPIC]
I know how everyone hates basic C questions, but I hought i understood
how this works,
but now I'm seeing clues that I may have been wrong.
When you use something like:
diceroll = number(1, 20);
does it assign a value to diceroll, or does any further use of diceroll
cause a new number to be generated?
Thank You in advance for any help that you can give.
Brand - Implementor of an as of yet Unnamed, homeless mud
________________________________________________________________
GET INTERNET ACCESS FROM JUNO!
Juno offers FREE or PREMIUM Internet access for less!
Join Juno today!  For your FREE software, visit:
http://dl.www.juno.com/get/tagj.

--
   +---------------------------------------------------------------+
   | 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/05/01 PST