… | |
… | |
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; |
20 | use File::Spec::Functions; |
|
|
21 | use Cwd 'abs_path'; |
21 | |
22 | |
22 | 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); |
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 =~ s/<\/?\s*li>//gi; |
|
|
31 | $html =~ s/<\/?\s*ul>//gi; |
|
|
32 | $html =~ s/>/>/g; |
|
|
33 | $html =~ s/</</g; |
|
|
34 | $html |
|
|
35 | } |
|
|
36 | |
|
|
37 | sub exit_paths { |
|
|
38 | my ($mappath, $map1path, $map2path) = @_; |
|
|
39 | $mappath = abs_path $mappath; |
|
|
40 | $map1path = abs_path $map1path; |
|
|
41 | $map2path = abs_path $map2path; |
|
|
42 | |
|
|
43 | if ( (substr $map1path, 0, length $mappath) eq $mappath |
|
|
44 | and (substr $map2path, 0, length $mappath) eq $mappath) { |
|
|
45 | substr $map1path, 0, length $mappath, ''; |
|
|
46 | substr $map2path, 0, length $mappath, ''; |
|
|
47 | |
|
|
48 | my ($v1, $d1, $f1) = File::Spec->splitpath ($map1path); |
|
|
49 | my ($v2, $d2, $f2) = File::Spec->splitpath ($map2path); |
|
|
50 | |
|
|
51 | my @di1 = File::Spec->splitdir ($d1); |
|
|
52 | my @di2 = File::Spec->splitdir ($d2); |
|
|
53 | |
|
|
54 | if ((defined $di1[1]) and (defined $di2[1]) and $di1[1] eq $di2[1]) { |
|
|
55 | my $m1 = File::Spec->abs2rel ($map1path, File::Spec->catdir (@di2)); |
|
|
56 | my $m2 = File::Spec->abs2rel ($map2path, File::Spec->catdir (@di1)); |
|
|
57 | return ($m1, $m2); |
|
|
58 | } else { |
|
|
59 | return ($map1path, $map2path); |
|
|
60 | } |
|
|
61 | } else { |
|
|
62 | return ('', ''); |
|
|
63 | } |
|
|
64 | } |
23 | |
65 | |
24 | sub map2abs { |
66 | sub map2abs { |
25 | my ($dest, $mape) = @_; |
67 | my ($dest, $mape) = @_; |
26 | |
68 | |
27 | my $dir; |
69 | my $dir; |
28 | if (File::Spec->file_name_is_absolute($dest)) { |
70 | if (File::Spec->file_name_is_absolute($dest)) { |
29 | $dir = catdir ($Crossfire::LIB, 'maps', $dest); |
71 | $dir = catdir ($::CFG->{MAPDIR}, $dest); |
30 | } else { |
72 | } else { |
31 | my ($v, $p, $f) = File::Spec->splitpath ($mape->{path}); |
73 | my ($v, $p, $f) = File::Spec->splitpath ($mape->{path}); |
32 | $dir = File::Spec->rel2abs ($dest, File::Spec->catpath ($v, $p)); |
74 | $dir = File::Spec->rel2abs ($dest, File::Spec->catpath ($v, $p)); |
33 | } |
75 | } |
34 | return $dir; |
76 | return $dir; |
… | |
… | |
108 | return $type eq '66' || $type eq '41'; |
150 | return $type eq '66' || $type eq '41'; |
109 | } |
151 | } |
110 | |
152 | |
111 | sub arch_is_floor { |
153 | sub arch_is_floor { |
112 | my ($a) = @_; |
154 | my ($a) = @_; |
|
|
155 | my $ar = Crossfire::arch_attr $a; |
|
|
156 | return (substr $ar->{name}, 0, 5) eq 'Floor'; |
113 | return $Crossfire::ARCH{$a->{_name}}->{is_floor}; |
157 | #return $Crossfire::ARCH{$a->{_name}}->{is_floor}; |
114 | } |
158 | } |
115 | |
159 | |
116 | sub arch_is_wall { |
160 | sub arch_is_wall { |
117 | my ($a) = @_; |
161 | my ($a) = @_; |
|
|
162 | my $ar = Crossfire::arch_attr $a; |
|
|
163 | return $ar->{name} eq 'Wall'; |
118 | return $Crossfire::ARCH{$a->{_name}}->{no_pass}; |
164 | #return $Crossfire::ARCH{$a->{_name}}->{no_pass}; |
119 | } |
165 | } |
120 | |
166 | |
121 | sub arch_is_monster { |
167 | sub arch_is_monster { |
122 | my ($a) = @_; |
168 | my ($a) = @_; |
123 | my $arch = $Crossfire::ARCH{$a->{_name}}; |
169 | my $arch = $Crossfire::ARCH{$a->{_name}}; |