ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/GCE/Util.pm
(Generate patch)

Comparing deliantra/gde/GCE/Util.pm (file contents):
Revision 1.9 by elmex, Mon Mar 20 02:53:49 2006 UTC vs.
Revision 1.17 by elmex, Tue Apr 4 11:29:54 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines