From: "Methos" <methos@FIRST-RULE.NET>
> From: "Michael Toomey" <mat70@TXCYBER.COM>
> if (world[i->in_room].zone != world[ch->in_room].zone)
> continue;
if i->in_room == NOWHERE, you'll crash.
> if (world[i->carried_by->in_room].zone != world[ch->in_room].zone)
> continue;
if you by pure luck didn't crash above, you'll go down here, if
the object isn't being carried by anyone. (dereferencing NULL).
> if (world[i->worn_by->in_room].zone != world[ch->in_room].zone)
> continue;
See above..
> if (world[i->in_obj->in_room].zone != world[ch->in_room].zone)
> continue;
What if the object containing i is being worn/carried/is inside another
container ? (Yes, you'll crash.)
>
> Thanks for the help but Ive already tried that approach. If I have the
first
> two lines of that code in, it does
> actually find objects on the ground, only in the zone your standing in.
But
> if I add the rest it either crashes
> or finds nothing at all when the spell is cast.
/* returns the real room number that the object or object's carrier is in */
room_rnum obj_room(obj_data *obj)
{
if (IN_ROOM(obj) != NOWHERE)
return IN_ROOM(obj);
if (obj->carried_by)
return IN_ROOM(obj->carried_by);
if (obj->worn_by)
return IN_ROOM(obj->worn_by);
if (obj->in_obj)
return obj_room(obj->in_obj);
return NOWHERE;
}
room_rnum tmp;
...
tmp = obj_room(i); /*to avoid calling obj_room twice */
/* (it can be expensive) - Welcor */
if (tmp == NOWHERE || world[tmp].zone != world[IN_ROOM(ch)].zone)
continue;
Welcor
--
+---------------------------------------------------------------+
| FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
| Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
| Newbie List: http://groups.yahoo.com/group/circle-newbies/ |
+---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 06/26/03 PDT