… | |
… | |
15 | use Storable; |
15 | use Storable; |
16 | use List::Util qw(min max); |
16 | use List::Util qw(min max); |
17 | |
17 | |
18 | use Crossfire; |
18 | use Crossfire; |
19 | use Crossfire::MapWidget; |
19 | use Crossfire::MapWidget; |
|
|
20 | use File::Spec::Functions; |
|
|
21 | use Cwd 'abs_path'; |
20 | |
22 | |
21 | 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); |
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 pseudohtml2txt); |
|
|
24 | |
|
|
25 | sub pseudohtml2txt { |
|
|
26 | my ($html) = @_; |
|
|
27 | |
|
|
28 | $html =~ s/<br\s*?\/?>/\n/gsi; |
|
|
29 | $html =~ s/<b>(.*?)<\/b>/_\1_/gsi; |
|
|
30 | $html |
|
|
31 | } |
|
|
32 | |
|
|
33 | sub exit_paths { |
|
|
34 | my ($mappath, $map1path, $map2path) = @_; |
|
|
35 | $mappath = abs_path $mappath; |
|
|
36 | $map1path = abs_path $map1path; |
|
|
37 | $map2path = abs_path $map2path; |
|
|
38 | |
|
|
39 | if ( (substr $map1path, 0, length $mappath) eq $mappath |
|
|
40 | and (substr $map2path, 0, length $mappath) eq $mappath) { |
|
|
41 | substr $map1path, 0, length $mappath, ''; |
|
|
42 | substr $map2path, 0, length $mappath, ''; |
|
|
43 | |
|
|
44 | my ($v1, $d1, $f1) = File::Spec->splitpath ($map1path); |
|
|
45 | my ($v2, $d2, $f2) = File::Spec->splitpath ($map2path); |
|
|
46 | |
|
|
47 | my @di1 = File::Spec->splitdir ($d1); |
|
|
48 | my @di2 = File::Spec->splitdir ($d2); |
|
|
49 | |
|
|
50 | if ((defined $di1[1]) and (defined $di2[1]) and $di1[1] eq $di2[1]) { |
|
|
51 | my $m1 = File::Spec->abs2rel ($map1path, File::Spec->catdir (@di2)); |
|
|
52 | my $m2 = File::Spec->abs2rel ($map2path, File::Spec->catdir (@di1)); |
|
|
53 | return ($m1, $m2); |
|
|
54 | } else { |
|
|
55 | return ($map1path, $map2path); |
|
|
56 | } |
|
|
57 | } else { |
|
|
58 | return ('', ''); |
|
|
59 | } |
|
|
60 | } |
|
|
61 | |
|
|
62 | sub map2abs { |
|
|
63 | my ($dest, $mape) = @_; |
|
|
64 | |
|
|
65 | my $dir; |
|
|
66 | if (File::Spec->file_name_is_absolute($dest)) { |
|
|
67 | $dir = catdir ($::CFG->{MAPDIR}, $dest); |
|
|
68 | } else { |
|
|
69 | my ($v, $p, $f) = File::Spec->splitpath ($mape->{path}); |
|
|
70 | $dir = File::Spec->rel2abs ($dest, File::Spec->catpath ($v, $p)); |
|
|
71 | } |
|
|
72 | return $dir; |
|
|
73 | } |
22 | |
74 | |
23 | sub def($$) { |
75 | sub def($$) { |
24 | return defined ($_[0]) ? $_[0] : $_[1]; |
76 | return defined ($_[0]) ? $_[0] : $_[1]; |
25 | } |
77 | } |
26 | |
78 | |
… | |
… | |
86 | |
138 | |
87 | return 'between'; |
139 | return 'between'; |
88 | } |
140 | } |
89 | } |
141 | } |
90 | |
142 | |
|
|
143 | sub arch_is_exit { |
|
|
144 | my ($a) = @_; |
|
|
145 | my $type = $Crossfire::ARCH{$a->{_name}}->{type}; |
|
|
146 | return $type eq '66' || $type eq '41'; |
|
|
147 | } |
|
|
148 | |
91 | sub arch_is_floor { |
149 | sub arch_is_floor { |
92 | my ($a) = @_; |
150 | my ($a) = @_; |
|
|
151 | my $ar = Crossfire::arch_attr $a; |
|
|
152 | return (substr $ar->{name}, 0, 5) eq 'Floor'; |
93 | return $Crossfire::ARCH{$a->{_name}}->{is_floor}; |
153 | #return $Crossfire::ARCH{$a->{_name}}->{is_floor}; |
94 | } |
154 | } |
95 | |
155 | |
96 | sub arch_is_wall { |
156 | sub arch_is_wall { |
97 | my ($a) = @_; |
157 | my ($a) = @_; |
|
|
158 | my $ar = Crossfire::arch_attr $a; |
|
|
159 | return $ar->{name} eq 'Wall'; |
98 | return $Crossfire::ARCH{$a->{_name}}->{no_pass}; |
160 | #return $Crossfire::ARCH{$a->{_name}}->{no_pass}; |
99 | } |
161 | } |
100 | |
162 | |
101 | sub arch_is_monster { |
163 | sub arch_is_monster { |
102 | my ($a) = @_; |
164 | my ($a) = @_; |
103 | my $arch = $Crossfire::ARCH{$a->{_name}}; |
165 | my $arch = $Crossfire::ARCH{$a->{_name}}; |