starting from x,y going towards dir, find a good location for a door */
| 103 | |
| 104 | /* starting from x,y going towards dir, find a good location for a door */ |
| 105 | staticfn boolean |
| 106 | finddpos_shift(coordxy *x, coordxy *y, int dir, struct mkroom *aroom) |
| 107 | { |
| 108 | coordxy dx, dy; |
| 109 | |
| 110 | dir = DIR_180(dir); |
| 111 | |
| 112 | dx = xdir[dir]; |
| 113 | dy = ydir[dir]; |
| 114 | |
| 115 | if (good_rm_wall_doorpos(*x, *y, dir, aroom)) |
| 116 | return TRUE; |
| 117 | |
| 118 | /* irregular rooms may have the room wall away from the room rectangular |
| 119 | area; go into the area until we encounter something */ |
| 120 | if (aroom->irregular) { |
| 121 | coordxy rx = *x, ry = *y; |
| 122 | boolean fail = FALSE; |
| 123 | |
| 124 | while (!fail && isok(rx, ry) |
| 125 | && (levl[rx][ry].typ == STONE || levl[rx][ry].typ == CORR)) { |
| 126 | rx += dx; |
| 127 | ry += dy; |
| 128 | if (good_rm_wall_doorpos(rx, ry, dir, aroom)) { |
| 129 | *x = rx; |
| 130 | *y = ry; |
| 131 | return TRUE; |
| 132 | } |
| 133 | if (!(levl[rx][ry].typ == STONE || levl[rx][ry].typ == CORR)) |
| 134 | fail = TRUE; |
| 135 | if (rx < aroom->lx || rx > aroom->hx |
| 136 | || ry < aroom->ly || ry > aroom->hy) |
| 137 | fail = TRUE; |
| 138 | } |
| 139 | } |
| 140 | return FALSE; |
| 141 | } |
| 142 | |
| 143 | /* find a valid door position at room edge. |
| 144 | dir is the preferred edge of the room. |
no test coverage detected