Re: Compiler warning:

From: ShadowLord (dkoepke@california.com)
Date: 06/21/96


On Fri, 21 Jun 1996, Mike Donais. wrote:

> Hi, I am trying to add a choice to my oasis olc, I am usually fairly
> competent at c, but I can't work this one out:
> 
> COMPILE WARNING:
> IN: db.c IN FUNCTION: reset_zone:
> db.c:1669: warning: passing arg 1 of `get_char_room' makes pointer from 
> integer without a cast

>       if ((mob = get_char_room((mob_index[ZCMD.arg2].virtual), ZCMD.arg1)) != NULL) {
>         char_from_room(mob);
>         extract_char(mob);

That meassage is kind of deceptive.  It seems to me that when I get it,
it's usually because I'm using an integer instead of a pointer.  If you'd
examine the get_char_room function you'd realize that it's first argument
is prototyped as: 'struct char_data *ch' and you're passing an integer in
it's place (namely, the virtual number).  get_char_room just gets a
CHARACTER in a room.  If you want to check for a mobile in room X, write
some function like:

  struct char_data *find_mob_room(int vnum, int room)
  { struct char_data *tmp;

    for (tmp = world[real_room(room)].people; tmp; tmp = tmp->next_in_room)
      if (IS_NPC(tmp) && real_mobile(vnum) == tmp->nr)
        break;
    return (tmp);
  }

That *should* work, but no guarantees.



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