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

Function pick_room

src/mkroom.c:219–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217
218/* pick an unused room, preferably with only one door */
219staticfn struct mkroom *
220pick_room(boolean strict)
221{
222 struct mkroom *sroom;
223 int i = svn.nroom;
224
225 for (sroom = &svr.rooms[rn2(svn.nroom)]; i--; sroom++) {
226 if (sroom == &svr.rooms[svn.nroom])
227 sroom = &svr.rooms[0];
228 if (sroom->hx < 0)
229 return (struct mkroom *) 0;
230 if (sroom->rtype != OROOM)
231 continue;
232 if (!strict) {
233 if (has_upstairs(sroom) || (has_dnstairs(sroom) && rn2(3)))
234 continue;
235 } else if (has_upstairs(sroom) || has_dnstairs(sroom))
236 continue;
237 if (sroom->doorct == 1 || !rn2(5) || wizard)
238 return sroom;
239 }
240 return (struct mkroom *) 0;
241}
242
243staticfn void
244mkzoo(int type)

Callers 2

mkzooFunction · 0.85
mktempleFunction · 0.85

Calls 3

rn2Function · 0.85
has_upstairsFunction · 0.85
has_dnstairsFunction · 0.85

Tested by

no test coverage detected