transpose top with bottom or left with right or both; sometimes called for new special levels, or for any level via the #wizfliplevel command */
| 530 | /* transpose top with bottom or left with right or both; sometimes called |
| 531 | for new special levels, or for any level via the #wizfliplevel command */ |
| 532 | void |
| 533 | flip_level( |
| 534 | int flp, /* mask for orientation(s) to transpose */ |
| 535 | boolean extras) /* False: level creation; True: #wizfliplevel is |
| 536 | * altering an active level so more needs to be done */ |
| 537 | { |
| 538 | int x, y, i, itmp; |
| 539 | coordxy minx, miny, maxx, maxy; |
| 540 | struct rm trm; |
| 541 | struct trap *ttmp; |
| 542 | struct obj *otmp; |
| 543 | struct monst *mtmp; |
| 544 | struct engr *etmp; |
| 545 | struct mkroom *sroom; |
| 546 | timer_element *timer; |
| 547 | boolean ball_active = FALSE, ball_fliparea = FALSE; |
| 548 | stairway *stway; |
| 549 | struct exclusion_zone *ez; |
| 550 | |
| 551 | /* nothing to do unless (flp & 1) or (flp & 2) or both */ |
| 552 | if ((flp & 3) == 0) |
| 553 | return; |
| 554 | |
| 555 | get_level_extends(&minx, &miny, &maxx, &maxy); |
| 556 | /* get_level_extends() returns -1,-1 to COLNO,ROWNO at max */ |
| 557 | if (miny < 0) |
| 558 | miny = 0; |
| 559 | if (minx < 1) |
| 560 | minx = 1; |
| 561 | if (maxx >= COLNO) |
| 562 | maxx = (COLNO - 1); |
| 563 | if (maxy >= ROWNO) |
| 564 | maxy = (ROWNO - 1); |
| 565 | |
| 566 | if (extras) { |
| 567 | if (Punished && uball->where != OBJ_FREE) { |
| 568 | ball_active = TRUE; |
| 569 | /* if hero and ball and chain are all inside flip area, |
| 570 | flip b&c coordinates along with other objects; if they |
| 571 | are all outside, leave them to be rejected when flipping |
| 572 | so that they stay as is; if some are inside and some are |
| 573 | outside, un-place here and subsequently re-place them on |
| 574 | hero's [possibly new] spot below */ |
| 575 | if (carried(uball)) |
| 576 | uball->ox = u.ux, uball->oy = u.uy; |
| 577 | ball_fliparea = ((inFlipArea(uball->ox, uball->oy) |
| 578 | == inFlipArea(uchain->ox, uchain->oy)) |
| 579 | && (inFlipArea(uball->ox, uball->oy) |
| 580 | == inFlipArea(u.ux, u.uy))); |
| 581 | if (!ball_fliparea) |
| 582 | unplacebc(); |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | /* stairs and ladders */ |
| 587 | for (stway = gs.stairs; stway; stway = stway->next) { |
| 588 | if (flp & 1) |
| 589 | stway->sy = FlipY(stway->sy); |
no test coverage detected