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.17 by elmex, Tue Apr 4 11:29:54 2006 UTC vs.
Revision 1.21 by elmex, Sat Oct 14 15:18:46 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 File::Basename;
22use File::Path;
23use HTTP::Request::Common;
21use Cwd 'abs_path'; 24use Cwd 'abs_path';
22 25
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); 26our @EXPORT = qw(insert_arch_stack_layer replace_arch_stack_layer new_arch_pb
27 fill_pb_from_arch arch_is_floor stack_find_floor stack_find_wall
28 stack_find arch_is_wall arch_is_monster add_table_widget quick_msg
29 def arch_is_exit map2abs exit_paths pseudohtml2txt arch_is_connector);
24 30
25sub pseudohtml2txt { 31sub pseudohtml2txt {
26 my ($html) = @_; 32 my ($html) = @_;
27 33
28 $html =~ s/<br\s*?\/?>/\n/gsi; 34 $html =~ s/<br\s*?\/?>/\n/gsi;
68 my ($dest, $mape) = @_; 74 my ($dest, $mape) = @_;
69 75
70 $mappath = abs_path $mappath; 76 $mappath = abs_path $mappath;
71 my $dir; 77 my $dir;
72 if (File::Spec->file_name_is_absolute($dest)) { 78 if (File::Spec->file_name_is_absolute($dest)) {
73 $dir = catdir ($::CFG->{MAPDIR}, $dest); 79 $dir = catdir ($::MAPDIR, $dest);
74 } else { 80 } else {
75 my ($v, $p, $f) = File::Spec->splitpath ($mape->{path}); 81 my ($v, $p, $f) = File::Spec->splitpath ($mape->{path});
76 $dir = File::Spec->rel2abs ($dest, File::Spec->catpath ($v, $p)); 82 $dir = File::Spec->rel2abs ($dest, File::Spec->catpath ($v, $p));
77 } 83 }
78 return $dir; 84 return $dir;
153} 159}
154 160
155sub arch_is_floor { 161sub arch_is_floor {
156 my ($a) = @_; 162 my ($a) = @_;
157 my $ar = Crossfire::arch_attr $a; 163 my $ar = Crossfire::arch_attr $a;
164 return (
158 return (substr $ar->{name}, 0, 5) eq 'Floor'; 165 (substr $ar->{name}, 0, 5) eq 'Floor'
159#return $Crossfire::ARCH{$a->{_name}}->{is_floor}; 166 or (substr $ar->{name}, 0, 10) eq 'Shop Floor'
167 )
168}
169
170sub arch_is_connector {
171 my ($a) = @_;
172 my $ar = Crossfire::arch_attr $a;
173 my $has_connect_field = 0;
174
175 TOP: for (@{$ar->{section}}) {
176 my $name = shift @$_;
177 my @r = @$_;
178 if ($name eq 'general') {
179 for (@r) {
180 my ($k, $s) = ($_->[0], $_->[1]);
181 if ($k eq 'connected' && $s->{name} eq 'connection') {
182 $has_connect_field = 1;
183 last TOP;
184 }
185 }
186 last TOP;
187 }
188 }
189
190 return $has_connect_field;
160} 191}
161 192
162sub arch_is_wall { 193sub arch_is_wall {
163 my ($a) = @_; 194 my ($a) = @_;
164 my $ar = Crossfire::arch_attr $a; 195 my $ar = Crossfire::arch_attr $a;
323 } 354 }
324 355
325 return \@outstack; 356 return \@outstack;
326} 357}
327 358
359sub upload {
360 my ($login, $password, $path, $rev, $mapdata) = @_;
361 require HTTP::Request::Common;
362
363 my $res = $ua->post (
364 $ENV{CFPLUS_UPLOAD},
365 Content_Type => 'multipart/form-data',
366 Content => [
367 path => $path,
368 mapdir => $::MAPDIR,
369 map => $mapdata,
370 revision => $rev,
371 cf_login => $login, #ENV{CFPLUS_LOGIN},
372 cf_password => $password, #ENV{CFPLUS_PASSWORD},
373 comment => "",
374 ]
375 );
376
377 if ($res->is_error) {
378 # fatal condition
379 warn $res->status_line;
380 } else {
381 # script replies are marked as {{..}}
382 my @msgs = $res->decoded_content =~ m/\{\{(.*?)\}\}/g;
383 warn map "$_\n", @msgs;
384 }
385}
386
328=head1 AUTHOR 387=head1 AUTHOR
329 388
330 Marc Lehmann <schmorp@schmorp.de> 389 Marc Lehmann <schmorp@schmorp.de>
331 http://home.schmorp.de/ 390 http://home.schmorp.de/
332 391

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines