E void FDECL(delallobj, (int,int));
E void FDECL(delobj, (struct obj *));
E struct obj *FDECL(sobj_at, (int,int,int));
+E struct obj *FDECL(nxtobj, (struct obj *,int,BOOLEAN_P));
E struct obj *FDECL(carrying, (int));
E boolean NDECL(have_lizard);
E struct obj *FDECL(o_on, (unsigned int,struct obj *));
E void NDECL(do_storms);
E boolean FDECL(start_timer, (long, SHORT_P, SHORT_P, genericptr_t));
E long FDECL(stop_timer, (SHORT_P, genericptr_t));
+E long FDECL(peek_timer, (SHORT_P,genericptr_t));
E void NDECL(run_timers);
E void FDECL(obj_move_timers, (struct obj *, struct obj *));
E void FDECL(obj_split_timers, (struct obj *, struct obj *));
E void FDECL(obj_stop_timers, (struct obj *));
+E boolean FDECL(obj_has_timer, (struct obj *,SHORT_P));
E void FDECL(spot_stop_timers, (XCHAR_P,XCHAR_P,SHORT_P));
E long FDECL(spot_time_expires, (XCHAR_P,XCHAR_P,SHORT_P));
E long FDECL(spot_time_left, (XCHAR_P,XCHAR_P,SHORT_P));
-/* SCCS Id: @(#)invent.c 3.4 2003/05/25 */
+/* SCCS Id: @(#)invent.c 3.4 2003/11/18 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
obfree(obj, (struct obj *) 0); /* frees contents also */
}
+/* try to find a particular type of object at designated map location */
struct obj *
-sobj_at(n,x,y)
-register int n, x, y;
+sobj_at(otyp, x, y)
+int otyp;
+int x, y;
{
register struct obj *otmp;
- for(otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere)
- if(otmp->otyp == n)
- return(otmp);
- return((struct obj *)0);
+ for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere)
+ if (otmp->otyp == otyp) break;
+
+ return otmp;
+}
+
+/* sobj_at(&c) traversal -- find next object of specified type */
+struct obj *
+nxtobj(obj, type, by_nexthere)
+struct obj *obj;
+int type;
+boolean by_nexthere;
+{
+ register struct obj *otmp;
+
+ otmp = obj; /* start with the object after this one */
+ do {
+ otmp = !by_nexthere ? otmp->nobj : otmp->nexthere;
+ if (!otmp) break;
+ } while (otmp->otyp != type);
+
+ return otmp;
}
struct obj *
-/* SCCS Id: @(#)timeout.c 3.4 2002/12/17 */
+/* SCCS Id: @(#)timeout.c 3.4 2003/11/18 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
* timer would have gone off. If no timer is found, return 0.
* If an object, decrement the object's timer count.
*
+ * long peek_timer(short func_index, genericptr_t arg)
+ * Return time specified timer will go off (0 if no such timer).
+ *
* void run_timers(void)
* Call timers that have timed out.
*
*
* void obj_stop_timers(struct obj *obj)
* Stop all timers attached to obj.
+ *
+ * boolean obj_has_timer(struct obj *object, short timer_type)
+ * Check whether object has a timer of type timer_type.
*/
#ifdef WIZARD
free((genericptr_t) doomed);
return timeout;
}
- return 0;
+ return 0L;
+}
+
+/*
+ * Find the timeout of specified timer; return 0 if none.
+ */
+long
+peek_timer(type, arg)
+ short type;
+ genericptr_t arg;
+{
+ timer_element *curr;
+
+ for (curr = timer_base; curr; curr = curr->next) {
+ if (curr->func_index == type && curr->arg == arg)
+ return curr->timeout;
+ }
+ return 0L;
}
obj->timed = 0;
}
+/*
+ * Check whether object has a timer of type timer_type.
+ */
+boolean
+obj_has_timer(object, timer_type)
+ struct obj *object;
+ short timer_type;
+{
+ long timeout = peek_timer(timer_type, (genericptr_t)object);
+
+ return (boolean)(timeout != 0L);
+}
+
+
/*
* Stop all timers of index func_index at this spot.
*