--- deliantra/gde/GCE/Util.pm 2006/03/23 11:57:13 1.12 +++ deliantra/gde/GCE/Util.pm 2006/04/01 18:45:05 1.13 @@ -18,8 +18,38 @@ use Crossfire; use Crossfire::MapWidget; use File::Spec::Functions; +use Cwd 'abs_path'; -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); +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); + +sub exit_paths { + my ($mappath, $map1path, $map2path) = @_; + $mappath = abs_path $mappath; + $map1path = abs_path $map1path; + $map2path = abs_path $map2path; + + if ( (substr $map1path, 0, length $mappath) eq $mappath + and (substr $map2path, 0, length $mappath) eq $mappath) { + substr $map1path, 0, length $mappath, ''; + substr $map2path, 0, length $mappath, ''; + + my ($v1, $d1, $f1) = File::Spec->splitpath ($map1path); + my ($v2, $d2, $f2) = File::Spec->splitpath ($map2path); + + my @di1 = File::Spec->splitdir ($d1); + my @di2 = File::Spec->splitdir ($d2); + + if ((defined $di1[1]) and (defined $di2[1]) and $di1[1] eq $di2[1]) { + my $m1 = File::Spec->abs2rel ($map1path, File::Spec->catdir (@di2)); + my $m2 = File::Spec->abs2rel ($map2path, File::Spec->catdir (@di1)); + return ($m1, $m2); + } else { + return ($map1path, $map2path); + } + } else { + return ('', ''); + } +} sub map2abs { my ($dest, $mape) = @_;