src/gen-util.c
void alloc_stairs(struct chunk *c, int feat, int num, int walls)
{
    int y, x, i, j, done;

    /* Place "num" stairs */
    for (i = 0; i < num; i++) {
		/* Place some stairs */
		for (done = FALSE; !done; ) {
			/* Try several times, then decrease "walls" */
			for (j = 0; !done && j <= 1000; j++) {
				find_empty(c, &y, &x);

				if (next_to_walls(c, y, x) < walls) continue;

				place_stairs(c, y, x, feat);
				done = TRUE;
			}

			/* Require fewer walls */
			if (walls) walls--;
		}
    }
}
/**
 * Place some staircases near walls.
 * \param c the current chunk
 * \param feat the stair terrain type
 * \param num number of staircases to place
 * \param walls number of walls to surround the stairs (negotiable)
 */
Place some staircases near walls.
\param c the current chunk
\param feat the stair terrain type
\param num number of staircases to place
\param walls number of walls to surround the stairs (negotiable)
Place some staircases near walls . \ param c the current chunk \ param feat the stair terrain type \ param num number of staircases to place \ param walls number of walls to surround the stairs ( negotiable )
void alloc_stairs(struct chunk *c, int feat, int num, int walls)
{
    int y, x, i, j, done;
    for (i = 0; i < num; i++) {
		for (done = FALSE; !done; ) {
			for (j = 0; !done && j <= 1000; j++) {
				find_empty(c, &y, &x);
				if (next_to_walls(c, y, x) < walls) continue;
				place_stairs(c, y, x, feat);
				done = TRUE;
			}
			if (walls) walls--;
		}
    }
}
void alloc_stairs ( struct chunk * c , int feat , int num , int walls ) { int y , x , i , j , done ; for ( i = 0 ; i < num ; i ++ ) { for ( done = FALSE ; ! done ; ) { for ( j = 0 ; ! done && j <= 1000 ; j ++ ) { find_empty ( c , & y , & x ) ; if ( next_to_walls ( c , y , x ) < walls ) continue ; place_stairs ( c , y , x , feat ) ; done = TRUE ; } if ( walls ) walls -- ; } } }
Place some staircases near walls.
Place some staircases near walls .
/* Place "num" stairs */ /* Place some stairs */ /* Try several times, then decrease "walls" */ /* Require fewer walls */