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

Function get_wormno

src/worm.c:95–106  ·  view source on GitHub ↗

* get_wormno() * * Find an unused worm tail slot and return the index. A zero means that * there are no slots available. This means that the worm head can exist, * it just cannot ever grow a tail. * * It, also, means that there is an optimization to made. The [0] positions * of the arrays are never used. Meaning, we really *could* have one more * tailed worm on the level, or use

Source from the content-addressed store, hash-verified

93 * Implementation is left to the interested hacker.
94 */
95int
96get_wormno(void)
97{
98 int new_wormno = 1;
99
100 while (new_wormno < MAX_NUM_WORMS) {
101 if (!wheads[new_wormno])
102 return new_wormno; /* found empty wtails[] slot at new_wormno */
103 new_wormno++;
104 }
105 return 0; /* level infested with worms */
106}
107
108/*
109 * initworm()

Callers 4

cutwormFunction · 0.85
mon_arriveFunction · 0.85
newchamFunction · 0.85
makemonFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected