MCPcopy Create free account
hub / github.com/NetHack/NetHack / run_timers

Function run_timers

src/timeout.c:2221–2241  ·  view source on GitHub ↗

* Pick off timeout elements from the global queue and call their functions. * Do this until their time is less than or equal to the move count. */

Source from the content-addressed store, hash-verified

2219 * Do this until their time is less than or equal to the move count.
2220 */
2221void
2222run_timers(void)
2223{
2224 timer_element *curr;
2225
2226 /*
2227 * Always use the first element. Elements may be added or deleted at
2228 * any time. The list is ordered; we are done when the first element
2229 * is in the future.
2230 */
2231 while (gt.timer_base && gt.timer_base->timeout <= svm.moves) {
2232 curr = gt.timer_base;
2233 gt.timer_base = curr->next;
2234
2235 if (curr->kind == TIMER_OBJECT)
2236 (curr->arg.a_obj)->timed--;
2237 (*timeout_funcs[curr->func_index].f)(&curr->arg, curr->timeout);
2238 (void) memset((genericptr_t) curr, 0, sizeof(timer_element));
2239 free((genericptr_t) curr);
2240 }
2241}
2242
2243/*
2244 * Start a timer. Return TRUE if successful.

Callers 3

goto_levelFunction · 0.85
dorecoverFunction · 0.85
nh_timeoutFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected