… | |
… | |
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); |
|
|
24 | |
|
|
25 | sub exit_paths { |
|
|
26 | my ($mappath, $map1path, $map2path) = @_; |
|
|
27 | $mappath = abs_path $mappath; |
|
|
28 | $map1path = abs_path $map1path; |
|
|
29 | $map2path = abs_path $map2path; |
|
|
30 | |
|
|
31 | if ( (substr $map1path, 0, length $mappath) eq $mappath |
|
|
32 | and (substr $map2path, 0, length $mappath) eq $mappath) { |
|
|
33 | substr $map1path, 0, length $mappath, ''; |
|
|
34 | substr $map2path, 0, length $mappath, ''; |
|
|
35 | |
|
|
36 | my ($v1, $d1, $f1) = File::Spec->splitpath ($map1path); |
|
|
37 | my ($v2, $d2, $f2) = File::Spec->splitpath ($map2path); |
|
|
38 | |
|
|
39 | my @di1 = File::Spec->splitdir ($d1); |
|
|
40 | my @di2 = File::Spec->splitdir ($d2); |
|
|
41 | |
|
|
42 | if ((defined $di1[1]) and (defined $di2[1]) and $di1[1] eq $di2[1]) { |
|
|
43 | my $m1 = File::Spec->abs2rel ($map1path, File::Spec->catdir (@di2)); |
|
|
44 | my $m2 = File::Spec->abs2rel ($map2path, File::Spec->catdir (@di1)); |
|
|
45 | return ($m1, $m2); |
|
|
46 | } else { |
|
|
47 | return ($map1path, $map2path); |
|
|
48 | } |
|
|
49 | } else { |
|
|
50 | return ('', ''); |
|
|
51 | } |
|
|
52 | } |
23 | |
53 | |
24 | sub map2abs { |
54 | sub map2abs { |
25 | my ($dest, $mape) = @_; |
55 | my ($dest, $mape) = @_; |
26 | |
56 | |
27 | my $dir; |
57 | my $dir; |