… | |
… | |
57 | } |
57 | } |
58 | |
58 | |
59 | if ($msg->{do_erase}) { |
59 | if ($msg->{do_erase}) { |
60 | if ($pl->ob->flag (cf::FLAG_WIZ)) { |
60 | if ($pl->ob->flag (cf::FLAG_WIZ)) { |
61 | my ($top) = reverse $pl->ob->map->at ($x, $y); |
61 | my ($top) = reverse $pl->ob->map->at ($x, $y); |
62 | $top->destroy if $top; |
62 | $top->destroy if ($top and $top->flag (cf::FLAG_IS_BUILDABLE)); |
63 | } else { |
63 | } else { |
64 | for my $ob ($pl->ob->map->at ($x, $y)) { |
64 | for my $ob ($pl->ob->map->at ($x, $y)) { |
65 | unless ($ob->type == cf::WALL || $ob->type == cf::FLOOR || $ob->flag (cf::FLAG_IS_FLOOR)) { |
65 | unless ($ob->type == cf::BUILDABLE_WALL || $ob->type == cf::FLOOR || $ob->flag (cf::FLAG_IS_FLOOR)) { |
66 | $ob->destroy; |
66 | $ob->destroy if $ob->flag (cf::FLAG_IS_BUILDABLE); |
67 | } |
67 | } |
68 | } |
68 | } |
69 | } |
69 | } |
70 | } |
70 | } |
71 | |
71 | |
… | |
… | |
75 | my $arch = cf::arch::find $msg->{item}; |
75 | my $arch = cf::arch::find $msg->{item}; |
76 | |
76 | |
77 | if ($arch->clone->subtype == cf::ST_MAT_FLOOR) { |
77 | if ($arch->clone->subtype == cf::ST_MAT_FLOOR) { |
78 | my $above_floor; |
78 | my $above_floor; |
79 | for my $ob ($pl->ob->map->at ($x, $y)) { |
79 | for my $ob ($pl->ob->map->at ($x, $y)) { |
80 | if ($ob->type == cf::WALL) { |
80 | if ($ob->type == cf::BUILDABLE_WALL) { |
81 | undef $above_floor if $above_floor == $ob; |
81 | undef $above_floor if $above_floor == $ob; |
82 | $ob->destroy; |
82 | $ob->destroy; |
83 | } elsif ($ob->type == cf::FLOOR || $ob->flag (cf::FLAG_IS_FLOOR)) { |
83 | } elsif ($ob->type == cf::FLOOR || $ob->flag (cf::FLAG_IS_FLOOR)) { |
84 | undef $above_floor if $above_floor == $ob; |
84 | undef $above_floor if $above_floor == $ob; |
85 | $above_floor = $ob->above; |
85 | $above_floor = $ob->above; |
… | |
… | |
98 | |
98 | |
99 | } elsif ($arch->clone->subtype == cf::ST_MAT_WALL) { |
99 | } elsif ($arch->clone->subtype == cf::ST_MAT_WALL) { |
100 | my @obs = $pl->ob->map->at ($x, $y); |
100 | my @obs = $pl->ob->map->at ($x, $y); |
101 | my $prev_wall; |
101 | my $prev_wall; |
102 | for (@obs) { |
102 | for (@obs) { |
103 | if ($_->type == cf::WALL) { |
103 | if ($_->type == cf::BUILDABLE_WALL) { |
104 | $prev_wall = $_; |
104 | $prev_wall = $_; |
105 | last; |
105 | last; |
106 | } |
106 | } |
107 | } |
107 | } |
108 | |
108 | |
… | |
… | |
114 | if ($above_floor) { |
114 | if ($above_floor) { |
115 | return; |
115 | return; |
116 | } |
116 | } |
117 | |
117 | |
118 | my $wall = cf::object::new $arch->clone->slaying; |
118 | my $wall = cf::object::new $arch->clone->slaying; |
119 | $wall->type (cf::WALL); |
119 | $wall->type (cf::BUILDABLE_WALL); |
120 | $wall->flag (cf::FLAG_IS_BUILDABLE, 1); |
120 | $wall->flag (cf::FLAG_IS_BUILDABLE, 1); |
121 | $wall->insert_ob_in_map_at ($pl->ob->map, undef, cf::INS_ABOVE_FLOOR_ONLY, $x, $y); |
121 | $wall->insert_ob_in_map_at ($pl->ob->map, undef, cf::INS_ABOVE_FLOOR_ONLY, $x, $y); |
122 | if ($prev_wall) { |
122 | if ($prev_wall) { |
123 | $prev_wall->destroy; |
123 | $prev_wall->destroy; |
124 | $pl->ob->map->fix_walls ($pl->ob->x + $dx, $pl->ob->y + $dy); |
124 | $pl->ob->map->fix_walls ($pl->ob->x + $dx, $pl->ob->y + $dy); |