… | |
… | |
18 | use Crossfire; |
18 | use Crossfire; |
19 | use Crossfire::MapWidget; |
19 | use Crossfire::MapWidget; |
20 | use File::Spec::Functions; |
20 | use File::Spec::Functions; |
21 | use Cwd 'abs_path'; |
21 | use Cwd 'abs_path'; |
22 | |
22 | |
23 | our @EXPORT = qw(insert_arch_stack_layer replace_arch_stack_layer new_arch_pb fill_pb_from_arch arch_is_floor stack_find_floor stack_find_wall stack_find arch_is_wall arch_is_monster add_table_widget quick_msg def arch_is_exit map2abs exit_paths); |
23 | our @EXPORT = qw(insert_arch_stack_layer replace_arch_stack_layer new_arch_pb |
|
|
24 | fill_pb_from_arch arch_is_floor stack_find_floor stack_find_wall |
|
|
25 | stack_find arch_is_wall arch_is_monster add_table_widget quick_msg |
|
|
26 | def arch_is_exit map2abs exit_paths pseudohtml2txt arch_is_connector); |
|
|
27 | |
|
|
28 | sub pseudohtml2txt { |
|
|
29 | my ($html) = @_; |
|
|
30 | |
|
|
31 | $html =~ s/<br\s*?\/?>/\n/gsi; |
|
|
32 | $html =~ s/<b>(.*?)<\/b>/_\1_/gsi; |
|
|
33 | $html =~ s/<li>/\n* /gi; |
|
|
34 | $html =~ s/<\/?\s*li>//gi; |
|
|
35 | $html =~ s/<\/?\s*ul>//gi; |
|
|
36 | $html =~ s/>/>/g; |
|
|
37 | $html =~ s/</</g; |
|
|
38 | $html |
|
|
39 | } |
24 | |
40 | |
25 | sub exit_paths { |
41 | sub exit_paths { |
26 | my ($mappath, $map1path, $map2path) = @_; |
42 | my ($mappath, $map1path, $map2path) = @_; |
27 | $mappath = abs_path $mappath; |
43 | $mappath = abs_path $mappath; |
28 | $map1path = abs_path $map1path; |
44 | $map1path = abs_path $map1path; |
… | |
… | |
52 | } |
68 | } |
53 | |
69 | |
54 | sub map2abs { |
70 | sub map2abs { |
55 | my ($dest, $mape) = @_; |
71 | my ($dest, $mape) = @_; |
56 | |
72 | |
|
|
73 | $mappath = abs_path $mappath; |
57 | my $dir; |
74 | my $dir; |
58 | if (File::Spec->file_name_is_absolute($dest)) { |
75 | if (File::Spec->file_name_is_absolute($dest)) { |
59 | $dir = catdir ($::CFG->{MAPDIR}, $dest); |
76 | $dir = catdir ($::CFG->{MAPDIR}, $dest); |
60 | } else { |
77 | } else { |
61 | my ($v, $p, $f) = File::Spec->splitpath ($mape->{path}); |
78 | my ($v, $p, $f) = File::Spec->splitpath ($mape->{path}); |
… | |
… | |
140 | |
157 | |
141 | sub arch_is_floor { |
158 | sub arch_is_floor { |
142 | my ($a) = @_; |
159 | my ($a) = @_; |
143 | my $ar = Crossfire::arch_attr $a; |
160 | my $ar = Crossfire::arch_attr $a; |
144 | return (substr $ar->{name}, 0, 5) eq 'Floor'; |
161 | return (substr $ar->{name}, 0, 5) eq 'Floor'; |
145 | #return $Crossfire::ARCH{$a->{_name}}->{is_floor}; |
162 | } |
|
|
163 | |
|
|
164 | sub arch_is_connector { |
|
|
165 | my ($a) = @_; |
|
|
166 | my $ar = Crossfire::arch_attr $a; |
|
|
167 | my $has_connect_field = 0; |
|
|
168 | |
|
|
169 | TOP: for (@{$ar->{section}}) { |
|
|
170 | my $name = shift @$_; |
|
|
171 | my @r = @$_; |
|
|
172 | if ($name eq 'general') { |
|
|
173 | for (@r) { |
|
|
174 | my ($k, $s) = ($_->[0], $_->[1]); |
|
|
175 | if ($k eq 'connected' && $s->{name} eq 'connection') { |
|
|
176 | $has_connect_field = 1; |
|
|
177 | last TOP; |
|
|
178 | } |
|
|
179 | } |
|
|
180 | last TOP; |
|
|
181 | } |
|
|
182 | } |
|
|
183 | |
|
|
184 | return $has_connect_field; |
146 | } |
185 | } |
147 | |
186 | |
148 | sub arch_is_wall { |
187 | sub arch_is_wall { |
149 | my ($a) = @_; |
188 | my ($a) = @_; |
150 | my $ar = Crossfire::arch_attr $a; |
189 | my $ar = Crossfire::arch_attr $a; |