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

Function initworm

src/worm.c:119–137  ·  view source on GitHub ↗

* initworm() * * Use if (mon->wormno = get_wormno()) before calling this function! * * Initialize the worm entry. This will set up the worm grow time, and * create and initialize the dummy segment for wheads[] and wtails[]. * * If the worm has no tail (ie get_wormno() fails) then this function * need not be called. */

Source from the content-addressed store, hash-verified

117 * need not be called.
118 */
119void
120initworm(struct monst *worm, int wseg_count)
121{
122 struct wseg *seg, *new_tail = create_worm_tail(wseg_count);
123 int wnum = worm->wormno;
124
125 if (new_tail) {
126 wtails[wnum] = new_tail;
127 for (seg = new_tail; seg->nseg; seg = seg->nseg)
128 continue;
129 wheads[wnum] = seg;
130 } else {
131 wtails[wnum] = wheads[wnum] = seg = newseg();
132 seg->nseg = (struct wseg *) 0;
133 }
134 seg->wx = worm->mx;
135 seg->wy = worm->my;
136 wgrowtime[wnum] = 0L;
137}
138
139/*
140 * toss_wsegs()

Callers 3

mon_arriveFunction · 0.85
newchamFunction · 0.85
makemonFunction · 0.85

Calls 1

create_worm_tailFunction · 0.85

Tested by

no test coverage detected