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.15 by elmex, Sun Apr 2 17:57:37 2006 UTC vs.
Revision 1.19 by elmex, Mon Aug 14 03:55:50 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 pseudohtml2txt); 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);
24 27
25sub pseudohtml2txt { 28sub pseudohtml2txt {
26 my ($html) = @_; 29 my ($html) = @_;
27 30
28 $html =~ s/<br\s*?\/?>/\n/gsi; 31 $html =~ s/<br\s*?\/?>/\n/gsi;
29 $html =~ s/<b>(.*?)<\/b>/_\1_/gsi; 32 $html =~ s/<b>(.*?)<\/b>/_\1_/gsi;
33 $html =~ s/<li>/\n* /gi;
30 $html =~ s/<\/?\s*li>//gi; 34 $html =~ s/<\/?\s*li>//gi;
31 $html =~ s/<\/?\s*ul>//gi; 35 $html =~ s/<\/?\s*ul>//gi;
32 $html =~ s/&gt;/>/g; 36 $html =~ s/&gt;/>/g;
33 $html =~ s/&lt;/</g; 37 $html =~ s/&lt;/</g;
34 $html 38 $html
64} 68}
65 69
66sub map2abs { 70sub map2abs {
67 my ($dest, $mape) = @_; 71 my ($dest, $mape) = @_;
68 72
73 $mappath = abs_path $mappath;
69 my $dir; 74 my $dir;
70 if (File::Spec->file_name_is_absolute($dest)) { 75 if (File::Spec->file_name_is_absolute($dest)) {
71 $dir = catdir ($::CFG->{MAPDIR}, $dest); 76 $dir = catdir ($::CFG->{MAPDIR}, $dest);
72 } else { 77 } else {
73 my ($v, $p, $f) = File::Spec->splitpath ($mape->{path}); 78 my ($v, $p, $f) = File::Spec->splitpath ($mape->{path});
151} 156}
152 157
153sub arch_is_floor { 158sub arch_is_floor {
154 my ($a) = @_; 159 my ($a) = @_;
155 my $ar = Crossfire::arch_attr $a; 160 my $ar = Crossfire::arch_attr $a;
161 warn "NAME: $ar->{name}\n";
162 return (
156 return (substr $ar->{name}, 0, 5) eq 'Floor'; 163 (substr $ar->{name}, 0, 5) eq 'Floor'
157#return $Crossfire::ARCH{$a->{_name}}->{is_floor}; 164 or (substr $ar->{name}, 0, 10) eq 'Shop Floor'
165 )
166}
167
168sub arch_is_connector {
169 my ($a) = @_;
170 my $ar = Crossfire::arch_attr $a;
171 my $has_connect_field = 0;
172
173 TOP: for (@{$ar->{section}}) {
174 my $name = shift @$_;
175 my @r = @$_;
176 if ($name eq 'general') {
177 for (@r) {
178 my ($k, $s) = ($_->[0], $_->[1]);
179 if ($k eq 'connected' && $s->{name} eq 'connection') {
180 $has_connect_field = 1;
181 last TOP;
182 }
183 }
184 last TOP;
185 }
186 }
187
188 return $has_connect_field;
158} 189}
159 190
160sub arch_is_wall { 191sub arch_is_wall {
161 my ($a) = @_; 192 my ($a) = @_;
162 my $ar = Crossfire::arch_attr $a; 193 my $ar = Crossfire::arch_attr $a;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines