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.13 by elmex, Sat Apr 1 18:45:05 2006 UTC vs.
Revision 1.20 by elmex, Mon Aug 14 18:52:48 2006 UTC

18use Crossfire; 18use Crossfire;
19use Crossfire::MapWidget; 19use Crossfire::MapWidget;
20use File::Spec::Functions; 20use File::Spec::Functions;
21use Cwd 'abs_path'; 21use Cwd 'abs_path';
22 22
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); 23our @EXPORT = qw(insert_arch_stack_layer replace_arch_stack_layer new_arch_pb
24 fill_pb_from_arch arch_is_floor stack_find_floor stack_find_wall
25 stack_find arch_is_wall arch_is_monster add_table_widget quick_msg
26 def arch_is_exit map2abs exit_paths pseudohtml2txt arch_is_connector);
27
28sub pseudohtml2txt {
29 my ($html) = @_;
30
31 $html =~ s/<br\s*?\/?>/\n/gsi;
32 $html =~ s/<b>(.*?)<\/b>/_\1_/gsi;
33 $html =~ s/<li>/\n* /gi;
34 $html =~ s/<\/?\s*li>//gi;
35 $html =~ s/<\/?\s*ul>//gi;
36 $html =~ s/&gt;/>/g;
37 $html =~ s/&lt;/</g;
38 $html
39}
24 40
25sub exit_paths { 41sub exit_paths {
26 my ($mappath, $map1path, $map2path) = @_; 42 my ($mappath, $map1path, $map2path) = @_;
27 $mappath = abs_path $mappath; 43 $mappath = abs_path $mappath;
28 $map1path = abs_path $map1path; 44 $map1path = abs_path $map1path;
52} 68}
53 69
54sub map2abs { 70sub map2abs {
55 my ($dest, $mape) = @_; 71 my ($dest, $mape) = @_;
56 72
73 $mappath = abs_path $mappath;
57 my $dir; 74 my $dir;
58 if (File::Spec->file_name_is_absolute($dest)) { 75 if (File::Spec->file_name_is_absolute($dest)) {
59 $dir = catdir ($::CFG->{MAPDIR}, $dest); 76 $dir = catdir ($::CFG->{MAPDIR}, $dest);
60 } else { 77 } else {
61 my ($v, $p, $f) = File::Spec->splitpath ($mape->{path}); 78 my ($v, $p, $f) = File::Spec->splitpath ($mape->{path});
139} 156}
140 157
141sub arch_is_floor { 158sub arch_is_floor {
142 my ($a) = @_; 159 my ($a) = @_;
143 my $ar = Crossfire::arch_attr $a; 160 my $ar = Crossfire::arch_attr $a;
161 return (
144 return (substr $ar->{name}, 0, 5) eq 'Floor'; 162 (substr $ar->{name}, 0, 5) eq 'Floor'
145#return $Crossfire::ARCH{$a->{_name}}->{is_floor}; 163 or (substr $ar->{name}, 0, 10) eq 'Shop Floor'
164 )
165}
166
167sub arch_is_connector {
168 my ($a) = @_;
169 my $ar = Crossfire::arch_attr $a;
170 my $has_connect_field = 0;
171
172 TOP: for (@{$ar->{section}}) {
173 my $name = shift @$_;
174 my @r = @$_;
175 if ($name eq 'general') {
176 for (@r) {
177 my ($k, $s) = ($_->[0], $_->[1]);
178 if ($k eq 'connected' && $s->{name} eq 'connection') {
179 $has_connect_field = 1;
180 last TOP;
181 }
182 }
183 last TOP;
184 }
185 }
186
187 return $has_connect_field;
146} 188}
147 189
148sub arch_is_wall { 190sub arch_is_wall {
149 my ($a) = @_; 191 my ($a) = @_;
150 my $ar = Crossfire::arch_attr $a; 192 my $ar = Crossfire::arch_attr $a;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines