find random point in generated corridors, so we don't create items in moats, bunkers, or walls */
| 1313 | /* find random point in generated corridors, |
| 1314 | so we don't create items in moats, bunkers, or walls */ |
| 1315 | void |
| 1316 | mazexy(coord *cc) |
| 1317 | { |
| 1318 | coordxy x, y; |
| 1319 | int allowedtyp = (svl.level.flags.corrmaze ? CORR : ROOM); |
| 1320 | int cpt = 0; |
| 1321 | |
| 1322 | do { |
| 1323 | /* once upon a time this only considered odd values greater than 2 |
| 1324 | and less than N (for N=={x,y}_maze_max) because even values were |
| 1325 | where maze walls always got placed; when wider maze corridors |
| 1326 | were introduced it was changed to 1+rn2(N) which is just an |
| 1327 | obscure way to get rnd(N); probably ought to be using 2+rn2(N-1) |
| 1328 | to exclude the maze's outer boundary walls; trying and rejecting |
| 1329 | those walls will waste some of the 100 random attempts... */ |
| 1330 | x = rnd(gx.x_maze_max); |
| 1331 | y = rnd(gy.y_maze_max); |
| 1332 | if (levl[x][y].typ == allowedtyp) { |
| 1333 | cc->x = x; |
| 1334 | cc->y = y; |
| 1335 | return; |
| 1336 | } |
| 1337 | } while (++cpt < 100); |
| 1338 | /* 100 random attempts failed; systematically try every possibility */ |
| 1339 | for (x = 1; x <= gx.x_maze_max; x++) |
| 1340 | for (y = 1; y <= gy.y_maze_max; y++) |
| 1341 | if (levl[x][y].typ == allowedtyp) { |
| 1342 | cc->x = x; |
| 1343 | cc->y = y; |
| 1344 | return; |
| 1345 | } |
| 1346 | /* every spot on the area of map allowed for mazes has been rejected */ |
| 1347 | panic("mazexy: can't find a place!"); |
| 1348 | /*NOTREACHED*/ |
| 1349 | return; |
| 1350 | } |
| 1351 | |
| 1352 | void |
| 1353 | get_level_extends( |
no test coverage detected