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

Function right_side

src/vision.c:1665–1851  ·  view source on GitHub ↗

* Mark positions as visible on one quadrant of the right side. The * quadrant is determined by the value of the global variable step. * * Arguments: * row current row * left first (left side) visible spot on prev row * right_mark last (right side) visible spot on prev row * limits points at range limit for current row, or NULL */

Source from the content-addressed store, hash-verified

1663 * limits points at range limit for current row, or NULL
1664 */
1665staticfn void
1666right_side(
1667 int row,
1668 int left,
1669 int right_mark,
1670 const coordxy *limits)
1671{
1672 int right; /* right limit of "could see" */
1673 int right_edge; /* right edge of an opening */
1674 int nrow; /* new row (calculate once) */
1675 int deeper; /* if TRUE, call self as needed */
1676 int result; /* set by q?_path() */
1677 int i; /* loop counter */
1678 seenV *rowp = NULL; /* row optimization */
1679 coordxy *row_min = NULL; /* left most [used by macro set_min()] */
1680 coordxy *row_max = NULL; /* right most [used by macro set_max()] */
1681 int lim_max; /* right most limit of circle */
1682
1683 nrow = row + step;
1684 /*
1685 * Can go deeper if the row is in bounds and the next row is within
1686 * the circle's limit. We tell the latter by checking to see if the next
1687 * limit value is the start of a new circle radius (meaning we depend
1688 * on the structure of circle_data[]).
1689 */
1690 deeper = good_row(nrow) && (!limits || (*limits >= *(limits + 1)));
1691 if (!vis_func) {
1692 rowp = cs_rows[row]; /* optimization */
1693 row_min = &cs_left[row];
1694 row_max = &cs_right[row];
1695 }
1696 if (limits) {
1697 lim_max = start_col + *limits;
1698 if (lim_max > COLNO - 1)
1699 lim_max = COLNO - 1;
1700 if (right_mark > lim_max)
1701 right_mark = lim_max;
1702 limits++; /* prepare for next row */
1703 } else
1704 lim_max = COLNO - 1;
1705
1706 while (left <= right_mark) {
1707 right_edge = right_ptrs[row][left];
1708 if (right_edge > lim_max)
1709 right_edge = lim_max;
1710
1711 if (!is_clear(row, left)) {
1712 /*
1713 * Jump to the far side of a stone wall. We can set all
1714 * the points in between as seen.
1715 *
1716 * If the right edge goes beyond the right mark, check to see
1717 * how much we can see.
1718 */
1719 if (right_edge > right_mark) {
1720 /*
1721 * If the mark on the previous row was a clear position,
1722 * the odds are that we can actually see part of the wall

Callers 1

view_fromFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected