… | |
… | |
16 | use List::Util qw(min max); |
16 | use List::Util qw(min max); |
17 | |
17 | |
18 | use Crossfire; |
18 | use Crossfire; |
19 | use Crossfire::MapWidget; |
19 | use Crossfire::MapWidget; |
20 | use File::Spec::Functions; |
20 | use File::Spec::Functions; |
|
|
21 | use File::Basename; |
|
|
22 | use File::Path; |
|
|
23 | use HTTP::Request::Common; |
21 | use Cwd 'abs_path'; |
24 | use Cwd 'abs_path'; |
22 | |
25 | |
23 | our @EXPORT = qw(insert_arch_stack_layer replace_arch_stack_layer new_arch_pb |
26 | our @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 |
27 | 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 |
28 | stack_find arch_is_wall arch_is_monster add_table_widget quick_msg |
… | |
… | |
71 | my ($dest, $mape) = @_; |
74 | my ($dest, $mape) = @_; |
72 | |
75 | |
73 | $mappath = abs_path $mappath; |
76 | $mappath = abs_path $mappath; |
74 | my $dir; |
77 | my $dir; |
75 | if (File::Spec->file_name_is_absolute($dest)) { |
78 | if (File::Spec->file_name_is_absolute($dest)) { |
76 | $dir = catdir ($::CFG->{MAPDIR}, $dest); |
79 | $dir = catdir ($::MAPDIR, $dest); |
77 | } else { |
80 | } else { |
78 | my ($v, $p, $f) = File::Spec->splitpath ($mape->{path}); |
81 | my ($v, $p, $f) = File::Spec->splitpath ($mape->{path}); |
79 | $dir = File::Spec->rel2abs ($dest, File::Spec->catpath ($v, $p)); |
82 | $dir = File::Spec->rel2abs ($dest, File::Spec->catpath ($v, $p)); |
80 | } |
83 | } |
81 | return $dir; |
84 | return $dir; |
… | |
… | |
351 | } |
354 | } |
352 | |
355 | |
353 | return \@outstack; |
356 | return \@outstack; |
354 | } |
357 | } |
355 | |
358 | |
|
|
359 | sub 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 | |
356 | =head1 AUTHOR |
387 | =head1 AUTHOR |
357 | |
388 | |
358 | Marc Lehmann <schmorp@schmorp.de> |
389 | Marc Lehmann <schmorp@schmorp.de> |
359 | http://home.schmorp.de/ |
390 | http://home.schmorp.de/ |
360 | |
391 | |