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

Function search_door

src/sp_lev.c:2491–2540  ·  view source on GitHub ↗

* Search for a door in a room on a specified wall. */

Source from the content-addressed store, hash-verified

2489 * Search for a door in a room on a specified wall.
2490 */
2491staticfn boolean
2492search_door(
2493 struct mkroom *croom,
2494 coordxy *x, coordxy *y,
2495 xint16 wall, int cnt)
2496{
2497 int dx, dy;
2498 int xx, yy;
2499
2500 switch (wall) {
2501 case W_SOUTH:
2502 dy = 0;
2503 dx = 1;
2504 xx = croom->lx;
2505 yy = croom->hy + 1;
2506 break;
2507 case W_NORTH:
2508 dy = 0;
2509 dx = 1;
2510 xx = croom->lx;
2511 yy = croom->ly - 1;
2512 break;
2513 case W_EAST:
2514 dy = 1;
2515 dx = 0;
2516 xx = croom->hx + 1;
2517 yy = croom->ly;
2518 break;
2519 case W_WEST:
2520 dy = 1;
2521 dx = 0;
2522 xx = croom->lx - 1;
2523 yy = croom->ly;
2524 break;
2525 default:
2526 panic("search_door: Bad wall!");
2527 /*NOTREACHED*/
2528 }
2529 while (xx <= croom->hx + 1 && yy <= croom->hy + 1) {
2530 if (IS_DOOR(levl[xx][yy].typ) || levl[xx][yy].typ == SDOOR) {
2531 *x = xx;
2532 *y = yy;
2533 if (cnt-- <= 0)
2534 return TRUE;
2535 }
2536 xx += dx;
2537 yy += dy;
2538 }
2539 return FALSE;
2540}
2541
2542/*
2543 * Dig a corridor between two points, using terrain ftyp.

Callers 1

create_corridorFunction · 0.85

Calls 1

panicFunction · 0.50

Tested by

no test coverage detected