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

Function get_level_extends

src/mkmaze.c:1352–1427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1350}
1351
1352void
1353get_level_extends(
1354 coordxy *left, coordxy *top,
1355 coordxy *right, coordxy *bottom)
1356{
1357 coordxy x, y;
1358 unsigned typ;
1359 struct rm *lev;
1360 boolean found, nonwall;
1361 coordxy xmin, xmax, ymin, ymax;
1362
1363 found = nonwall = FALSE;
1364 for (xmin = 0; !found && xmin <= COLNO; xmin++) {
1365 lev = &levl[xmin][0];
1366 for (y = 0; y <= ROWNO - 1; y++, lev++) {
1367 typ = lev->typ;
1368 if (typ != STONE) {
1369 found = TRUE;
1370 if (!IS_WALL(typ))
1371 nonwall = TRUE;
1372 }
1373 }
1374 }
1375 xmin -= (nonwall || !svl.level.flags.is_maze_lev) ? 2 : 1;
1376 if (xmin < 0)
1377 xmin = 0;
1378
1379 found = nonwall = FALSE;
1380 for (xmax = COLNO - 1; !found && xmax >= 0; xmax--) {
1381 lev = &levl[xmax][0];
1382 for (y = 0; y <= ROWNO - 1; y++, lev++) {
1383 typ = lev->typ;
1384 if (typ != STONE) {
1385 found = TRUE;
1386 if (!IS_WALL(typ))
1387 nonwall = TRUE;
1388 }
1389 }
1390 }
1391 xmax += (nonwall || !svl.level.flags.is_maze_lev) ? 2 : 1;
1392 if (xmax >= COLNO)
1393 xmax = COLNO - 1;
1394
1395 found = nonwall = FALSE;
1396 for (ymin = 0; !found && ymin <= ROWNO; ymin++) {
1397 lev = &levl[xmin][ymin];
1398 for (x = xmin; x <= xmax; x++, lev += ROWNO) {
1399 typ = lev->typ;
1400 if (typ != STONE) {
1401 found = TRUE;
1402 if (!IS_WALL(typ))
1403 nonwall = TRUE;
1404 }
1405 }
1406 }
1407 ymin -= (nonwall || !svl.level.flags.is_maze_lev) ? 2 : 1;
1408
1409 found = nonwall = FALSE;

Callers 2

bound_diggingFunction · 0.85
flip_levelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected