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

Function check_room

src/sp_lev.c:1406–1479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1404}
1405
1406boolean
1407check_room(
1408 coordxy *lowx, coordxy *ddx,
1409 coordxy *lowy, coordxy *ddy,
1410 boolean vault)
1411{
1412 int x, y, hix = *lowx + *ddx, hiy = *lowy + *ddy;
1413 struct rm *lev;
1414 int xlim, ylim, ymax;
1415 coordxy s_lowx, s_ddx, s_lowy, s_ddy;
1416
1417 s_lowx = *lowx; s_ddx = *ddx;
1418 s_lowy = *lowy; s_ddy = *ddy;
1419
1420 xlim = XLIM + (vault ? 1 : 0);
1421 ylim = YLIM + (vault ? 1 : 0);
1422
1423 if (*lowx < 3)
1424 *lowx = 3;
1425 if (*lowy < 2)
1426 *lowy = 2;
1427 if (hix > COLNO - 3)
1428 hix = COLNO - 3;
1429 if (hiy > ROWNO - 3)
1430 hiy = ROWNO - 3;
1431 chk:
1432 if (hix <= *lowx || hiy <= *lowy)
1433 return FALSE;
1434
1435 if (gi.in_mk_themerooms && (s_lowx != *lowx) && (s_ddx != *ddx)
1436 && (s_lowy != *lowy) && (s_ddy != *ddy))
1437 return FALSE;
1438
1439 /* check area around room (and make room smaller if necessary) */
1440 for (x = *lowx - xlim; x <= hix + xlim; x++) {
1441 if (x <= 0 || x >= COLNO)
1442 continue;
1443 y = *lowy - ylim;
1444 ymax = hiy + ylim;
1445 if (y < 0)
1446 y = 0;
1447 if (ymax >= ROWNO)
1448 ymax = (ROWNO - 1);
1449 lev = &levl[x][y];
1450 for (; y <= ymax; y++) {
1451 if (lev++->typ != STONE) {
1452 if (!vault) {
1453 debugpline2("strange area [%d,%d] in check_room.", x, y);
1454 }
1455 if (!rn2(3))
1456 return FALSE;
1457 if (gi.in_mk_themerooms)
1458 return FALSE;
1459 if (x < *lowx)
1460 *lowx = x + xlim + 1;
1461 else
1462 hix = x - xlim - 1;
1463 if (y < *lowy)

Callers 2

makelevelFunction · 0.85
create_roomFunction · 0.85

Calls 1

rn2Function · 0.85

Tested by

no test coverage detected