couple of new routines (trunk only)
Groundwork for forthcoming stethoscope fix: add an object list traveral routine (there must be something like this already, but I couldn't find it...) and a couple of timer access routines.
This commit is contained in:
@@ -787,6 +787,7 @@ E void FDECL(freeinv, (struct obj *));
|
|||||||
E void FDECL(delallobj, (int,int));
|
E void FDECL(delallobj, (int,int));
|
||||||
E void FDECL(delobj, (struct obj *));
|
E void FDECL(delobj, (struct obj *));
|
||||||
E struct obj *FDECL(sobj_at, (int,int,int));
|
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 struct obj *FDECL(carrying, (int));
|
||||||
E boolean NDECL(have_lizard);
|
E boolean NDECL(have_lizard);
|
||||||
E struct obj *FDECL(o_on, (unsigned int,struct obj *));
|
E struct obj *FDECL(o_on, (unsigned int,struct obj *));
|
||||||
@@ -2004,10 +2005,12 @@ E void FDECL(end_burn, (struct obj *, BOOLEAN_P));
|
|||||||
E void NDECL(do_storms);
|
E void NDECL(do_storms);
|
||||||
E boolean FDECL(start_timer, (long, SHORT_P, SHORT_P, genericptr_t));
|
E boolean FDECL(start_timer, (long, SHORT_P, SHORT_P, genericptr_t));
|
||||||
E long FDECL(stop_timer, (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 NDECL(run_timers);
|
||||||
E void FDECL(obj_move_timers, (struct obj *, struct obj *));
|
E void FDECL(obj_move_timers, (struct obj *, struct obj *));
|
||||||
E void FDECL(obj_split_timers, (struct obj *, struct obj *));
|
E void FDECL(obj_split_timers, (struct obj *, struct obj *));
|
||||||
E void FDECL(obj_stop_timers, (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 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_expires, (XCHAR_P,XCHAR_P,SHORT_P));
|
||||||
E long FDECL(spot_time_left, (XCHAR_P,XCHAR_P,SHORT_P));
|
E long FDECL(spot_time_left, (XCHAR_P,XCHAR_P,SHORT_P));
|
||||||
|
|||||||
+27
-7
@@ -1,4 +1,4 @@
|
|||||||
/* 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. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -563,16 +563,36 @@ register struct obj *obj;
|
|||||||
obfree(obj, (struct obj *) 0); /* frees contents also */
|
obfree(obj, (struct obj *) 0); /* frees contents also */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* try to find a particular type of object at designated map location */
|
||||||
struct obj *
|
struct obj *
|
||||||
sobj_at(n,x,y)
|
sobj_at(otyp, x, y)
|
||||||
register int n, x, y;
|
int otyp;
|
||||||
|
int x, y;
|
||||||
{
|
{
|
||||||
register struct obj *otmp;
|
register struct obj *otmp;
|
||||||
|
|
||||||
for(otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere)
|
for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere)
|
||||||
if(otmp->otyp == n)
|
if (otmp->otyp == otyp) break;
|
||||||
return(otmp);
|
|
||||||
return((struct obj *)0);
|
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 *
|
struct obj *
|
||||||
|
|||||||
+39
-2
@@ -1,4 +1,4 @@
|
|||||||
/* 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. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -1242,6 +1242,9 @@ do_storms()
|
|||||||
* timer would have gone off. If no timer is found, return 0.
|
* timer would have gone off. If no timer is found, return 0.
|
||||||
* If an object, decrement the object's timer count.
|
* 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)
|
* void run_timers(void)
|
||||||
* Call timers that have timed out.
|
* Call timers that have timed out.
|
||||||
*
|
*
|
||||||
@@ -1271,6 +1274,9 @@ do_storms()
|
|||||||
*
|
*
|
||||||
* void obj_stop_timers(struct obj *obj)
|
* void obj_stop_timers(struct obj *obj)
|
||||||
* Stop all timers attached to 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
|
#ifdef WIZARD
|
||||||
@@ -1482,7 +1488,24 @@ genericptr_t arg;
|
|||||||
free((genericptr_t) doomed);
|
free((genericptr_t) doomed);
|
||||||
return timeout;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1555,6 +1578,20 @@ obj_stop_timers(obj)
|
|||||||
obj->timed = 0;
|
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.
|
* Stop all timers of index func_index at this spot.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user