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

Function get_room_loc

src/sp_lev.c:1359–1378  ·  view source on GitHub ↗

* Get a relative position inside a room. * negative values for x or y means RANDOM! */

Source from the content-addressed store, hash-verified

1357 * negative values for x or y means RANDOM!
1358 */
1359staticfn void
1360get_room_loc(coordxy *x, coordxy *y, struct mkroom *croom)
1361{
1362 coord c;
1363
1364 if (*x < 0 && *y < 0) {
1365 if (somexy(croom, &c)) {
1366 *x = c.x;
1367 *y = c.y;
1368 } else
1369 panic("get_room_loc : can't find a place!");
1370 } else {
1371 if (*x < 0)
1372 *x = rn2(croom->hx - croom->lx + 1);
1373 if (*y < 0)
1374 *y = rn2(croom->hy - croom->ly + 1);
1375 *x += croom->lx;
1376 *y += croom->ly;
1377 }
1378}
1379
1380/*
1381 * Get a relative position inside a room.

Callers 1

get_free_room_locFunction · 0.85

Calls 3

somexyFunction · 0.85
rn2Function · 0.85
panicFunction · 0.50

Tested by

no test coverage detected