Source:NetHack 5.0.0/include/timeout.h

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to timeout.h from the source code of NetHack 5.0.0. To link to a particular line, write [[Source:NetHack 5.0.0/include/timeout.h#line12]], for example.

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

1. /* NetHack 5.0	timeout.h	$NHDT-Date: 1705087443 2024/01/12 19:24:03 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.23 $ */
2. /* Copyright 1994, Dean Luick                                     */
3. /* NetHack may be freely redistributed.  See license for details. */
4. 
5. #ifndef TIMEOUT_H
6. #define TIMEOUT_H
7. 
8. /* generic timeout function */
9. typedef void (*timeout_proc)(ANY_P *, long);
10. 
11. /* kind of timer */
12. enum timer_type {
13.     TIMER_NONE = 0,
14.     TIMER_LEVEL = 1,   /* event specific to level [melting ice] */
15.     TIMER_GLOBAL = 2,  /* event follows current play [not used] */
16.     TIMER_OBJECT = 3,  /* event follows an object [various] */
17.     TIMER_MONSTER = 4, /* event follows a monster [not used] */
18.     NUM_TIMER_KINDS    /* 5 */
19. };
20. 
21. /* save/restore timer ranges */
22. #define RANGE_LEVEL 0  /* save/restore timers staying on level */
23. #define RANGE_GLOBAL 1 /* save/restore timers following global play */
24. 
25. /*
26.  * Timeout functions.  Add an enum here, then put it in the table
27.  * in timeout.c.  "One more level of indirection will fix everything."
28.  * Also add it to timerstr[] in nhl_get_timertype(nhlua.c); the entries
29.  * there match these but are spelled differently.
30.  *
31.  * Note:  if any are inserted, removed, or reordered then EDITLEVEL
32.  * needs to be incremented because timeout indices get written into save
33.  * and bones files if any timers are present while saving.  (Adding new
34.  * ones at the end isn't restricted this way since new indices won't be
35.  * present in old data.)
36.  */
37. enum timeout_types {
38.     ROT_ORGANIC = 0, /* for buried organics */
39.     ROT_CORPSE,
40.     REVIVE_MON,
41.     ZOMBIFY_MON,
42.     BURN_OBJECT,
43.     HATCH_EGG,
44.     FIG_TRANSFORM,
45.     SHRINK_GLOB,
46.     MELT_ICE_AWAY,
47. 
48.     NUM_TIME_FUNCS
49. };
50. 
51. #define timer_is_pos(ttype) ((ttype) == MELT_ICE_AWAY)
52. #define timer_is_obj(ttype) ((ttype) == ROT_ORGANIC      \
53.                              || (ttype) == ROT_CORPSE    \
54.                              || (ttype) == REVIVE_MON    \
55.                              || (ttype) == ZOMBIFY_MON   \
56.                              || (ttype) == BURN_OBJECT   \
57.                              || (ttype) == HATCH_EGG     \
58.                              || (ttype) == FIG_TRANSFORM \
59.                              || (ttype) == SHRINK_GLOB)
60. 
61. /* used in timeout.c */
62. typedef struct fe {
63.     struct fe *next;          /* next item in chain */
64.     long timeout;             /* when we time out */
65.     unsigned long tid;        /* timer ID */
66.     short kind;               /* kind of use */
67.     short func_index;         /* what to call when we time out */
68.     anything arg;             /* pointer to timeout argument */
69.     Bitfield(needs_fixup, 1); /* does arg need to be patched? */
70. } timer_element;
71. 
72. #endif /* TIMEOUT_H */