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

Function create_room

src/sp_lev.c:1485–1661  ·  view source on GitHub ↗

* Create a new room. * This is still very incomplete... */

Source from the content-addressed store, hash-verified

1483 * This is still very incomplete...
1484 */
1485boolean
1486create_room(
1487 coordxy x, coordxy y,
1488 coordxy w, coordxy h,
1489 coordxy xal, coordxy yal,
1490 xint16 rtype, xint16 rlit)
1491{
1492 coordxy xabs = 0, yabs = 0;
1493 int wtmp, htmp, xaltmp, yaltmp, xtmp, ytmp;
1494 NhRect *r1 = 0, r2;
1495 int trycnt = 0;
1496 boolean vault = FALSE;
1497 int xlim = XLIM, ylim = YLIM;
1498
1499 if (rtype == -1) /* Is the type random ? */
1500 rtype = OROOM;
1501
1502 if (rtype == VAULT) {
1503 vault = TRUE;
1504 xlim++;
1505 ylim++;
1506 }
1507
1508 /* on low levels the room is lit (usually) */
1509 /* some other rooms may require lighting */
1510
1511 /* is light state random ? */
1512 rlit = litstate_rnd(rlit);
1513
1514 /*
1515 * Here we will try to create a room. If some parameters are
1516 * random we are willing to make several try before we give
1517 * it up.
1518 */
1519 do {
1520 coordxy xborder, yborder;
1521
1522 wtmp = w;
1523 htmp = h;
1524 xtmp = x;
1525 ytmp = y;
1526 xaltmp = xal;
1527 yaltmp = yal;
1528
1529 /* First case : a totally random room */
1530
1531 if ((xtmp < 0 && ytmp < 0 && wtmp < 0 && xaltmp < 0 && yaltmp < 0)
1532 || vault) {
1533 coordxy hx, hy, lx, ly, dx, dy;
1534
1535 r1 = rnd_rect(); /* Get a random rectangle */
1536
1537 if (!r1) { /* No more free rectangles ! */
1538 debugpline0("No more rects...");
1539 return FALSE;
1540 }
1541 hx = r1->hx;
1542 hy = r1->hy;

Callers 2

makeroomsFunction · 0.85
build_roomFunction · 0.85

Calls 8

litstate_rndFunction · 0.85
rnd_rectFunction · 0.85
rn2Function · 0.85
check_roomFunction · 0.85
rndFunction · 0.85
get_rectFunction · 0.85
split_rectsFunction · 0.85
add_roomFunction · 0.85

Tested by

no test coverage detected