* Remove roomno from the rooms array, decrementing nroom. * The last room is swapped with the being-removed room and locations * within it have their roomno field updated. Other rooms are unaffected. * Assumes level structure contents corresponding to roomno have already * been reset. * Currently handles only the removal of rooms that have no subrooms. */
| 409 | * Currently handles only the removal of rooms that have no subrooms. |
| 410 | */ |
| 411 | staticfn void |
| 412 | remove_room(unsigned int roomno) |
| 413 | { |
| 414 | struct mkroom *croom = &svr.rooms[roomno]; |
| 415 | struct mkroom *maxroom = &svr.rooms[--svn.nroom]; |
| 416 | coordxy x, y; |
| 417 | unsigned oroomno; |
| 418 | |
| 419 | if (croom != maxroom) { |
| 420 | /* since the order in the array only matters for making corridors, |
| 421 | * copy the last room over the one being removed on the assumption |
| 422 | * that corridors have already been dug. */ |
| 423 | *croom = *maxroom; |
| 424 | |
| 425 | /* since maxroom moved, update affected level roomno values */ |
| 426 | oroomno = svn.nroom + ROOMOFFSET; |
| 427 | roomno += ROOMOFFSET; |
| 428 | for (x = croom->lx; x <= croom->hx; ++x) |
| 429 | for (y = croom->ly; y <= croom->hy; ++y) { |
| 430 | if (levl[x][y].roomno == oroomno) |
| 431 | levl[x][y].roomno = roomno; |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | maxroom->hx = -1; /* just like add_room */ |
| 436 | } |
| 437 | |
| 438 | #define N_P1_ITER 1 /* tune map generation via this value */ |
| 439 | #define N_P2_ITER 1 /* tune map generation via this value */ |