| 637 | } |
| 638 | |
| 639 | void |
| 640 | digactualhole(coordxy x, coordxy y, struct monst *madeby, int ttyp) |
| 641 | { |
| 642 | struct obj *oldobjs, *newobjs; |
| 643 | struct trap *ttmp; |
| 644 | const char *surface_type, *tname, *in_thru; |
| 645 | char furniture[BUFSZ]; |
| 646 | struct rm *lev = &levl[x][y]; |
| 647 | struct monst *mtmp = m_at(x, y); /* may be madeby */ |
| 648 | boolean madeby_u = (madeby == BY_YOU), madeby_obj = (madeby == BY_OBJECT), |
| 649 | /* BY_OBJECT means the hero broke a wand, so blame her for it */ |
| 650 | heros_fault = (madeby_u || madeby_obj); |
| 651 | boolean shopdoor, at_u = u_at(x, y), wont_fall = Levitation || Flying; |
| 652 | int old_typ, old_aligntyp = A_NONE; |
| 653 | |
| 654 | if (at_u && u.utrap) { |
| 655 | if (u.utraptype == TT_BURIEDBALL) |
| 656 | buried_ball_to_punishment(); |
| 657 | else if (u.utraptype == TT_INFLOOR) |
| 658 | reset_utrap(FALSE); |
| 659 | } |
| 660 | |
| 661 | if (furniture_handled(x, y, madeby_u)) |
| 662 | return; |
| 663 | |
| 664 | if (ttyp != PIT && (!Can_dig_down(&u.uz) && !lev->candig)) { |
| 665 | impossible("digactualhole: can't dig %s on this level.", |
| 666 | trapname(ttyp, TRUE)); |
| 667 | ttyp = PIT; |
| 668 | } |
| 669 | |
| 670 | /* maketrap() might change terrain type but we deliver messages after |
| 671 | that, so prepare in advance */ |
| 672 | old_typ = lev->typ; |
| 673 | furniture[0] = '\0'; |
| 674 | if (IS_FURNITURE(lev->typ)) { |
| 675 | /* should mirror the word used by surface() for normal floor */ |
| 676 | surface_type = (IS_ROOM(lev->typ) && !Is_earthlevel(&u.uz) |
| 677 | ? "floor" : "ground"); |
| 678 | if (IS_ALTAR(lev->typ)) { |
| 679 | old_aligntyp = Amask2align(levl[x][y].altarmask & AM_MASK); |
| 680 | Strcpy(furniture, align_str(old_aligntyp)); |
| 681 | Strcat(furniture, " "); |
| 682 | } |
| 683 | Strcat(furniture, surface(x, y)); |
| 684 | } else { |
| 685 | surface_type = surface(x, y); |
| 686 | } |
| 687 | shopdoor = IS_DOOR(lev->typ) && *in_rooms(x, y, SHOPBASE); |
| 688 | oldobjs = svl.level.objects[x][y]; |
| 689 | |
| 690 | ttmp = maketrap(x, y, ttyp); |
| 691 | if (!ttmp) |
| 692 | return; |
| 693 | newobjs = svl.level.objects[x][y]; |
| 694 | ttmp->madeby_u = heros_fault; |
| 695 | ttmp->tseen = 0; |
| 696 | if (cansee(x, y)) |
no test coverage detected