… | |
… | |
20 | use File::Spec::Functions; |
20 | use File::Spec::Functions; |
21 | use File::Basename; |
21 | use File::Basename; |
22 | use File::Path; |
22 | use File::Path; |
23 | use HTTP::Request::Common; |
23 | use HTTP::Request::Common; |
24 | use Cwd 'abs_path'; |
24 | use Cwd 'abs_path'; |
|
|
25 | use strict; |
25 | |
26 | |
26 | our @EXPORT = qw(insert_arch_stack_layer replace_arch_stack_layer new_arch_pb |
27 | our @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 | 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 | 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); |
30 | def arch_is_exit map2abs exit_paths pseudohtml2txt arch_is_connector); |
… | |
… | |
71 | } |
72 | } |
72 | |
73 | |
73 | sub map2abs { |
74 | sub map2abs { |
74 | my ($dest, $mape) = @_; |
75 | my ($dest, $mape) = @_; |
75 | |
76 | |
76 | $mappath = abs_path $mappath; |
77 | $dest = abs_path $dest; |
77 | my $dir; |
78 | my $dir; |
78 | if (File::Spec->file_name_is_absolute($dest)) { |
79 | if (File::Spec->file_name_is_absolute($dest)) { |
79 | $dir = catdir ($::MAPDIR, $dest); |
80 | $dir = catdir ($::MAPDIR, $dest); |
80 | } else { |
81 | } else { |
81 | my ($v, $p, $f) = File::Spec->splitpath ($mape->{path}); |
82 | my ($v, $p, $f) = File::Spec->splitpath ($mape->{path}); |
… | |
… | |
119 | |
120 | |
120 | sub fill_pb_from_arch { |
121 | sub fill_pb_from_arch { |
121 | my ($pb, $a) = @_; |
122 | my ($pb, $a) = @_; |
122 | |
123 | |
123 | my $o = $Crossfire::ARCH{$a->{_name}}; |
124 | my $o = $Crossfire::ARCH{$a->{_name}}; |
124 | my $face = $Crossfire::FACE{$a->{face} || $o->{face} || "blank.111"} |
125 | my $face = $Crossfire::FACE{$a->{face} || $o->{face} || "blank.111"}; |
|
|
126 | unless ($face) { |
|
|
127 | $face = $Crossfire::FACE{"blank.x11"} |
125 | or warn "no gfx found for arch '$a->{_name}' at ($x|$y)\n"; |
128 | or warn "no gfx found for arch '$a->{_name}'\n"; |
|
|
129 | } |
126 | |
130 | |
127 | $face or return; |
131 | $face or return; |
128 | |
132 | |
129 | $pb->fill (0x00000000); |
133 | $pb->fill (0x00000000); |
130 | $TILE->composite ($pb, |
134 | $TILE->composite ($pb, |
… | |
… | |
355 | |
359 | |
356 | return \@outstack; |
360 | return \@outstack; |
357 | } |
361 | } |
358 | |
362 | |
359 | sub upload { |
363 | sub upload { |
360 | my ($login, $password, $path, $rev, $mapdata) = @_; |
364 | my ($login, $password, $srcrep, $path, $rev, $mapdata) = @_; |
|
|
365 | require LWP::UserAgent; |
|
|
366 | my $ua = LWP::UserAgent->new ( |
|
|
367 | agent => "gcrossedit", |
|
|
368 | keep_alive => 1, |
|
|
369 | env_proxy => 1, |
|
|
370 | timeout => 30, |
|
|
371 | ); |
361 | require HTTP::Request::Common; |
372 | require HTTP::Request::Common; |
362 | |
373 | |
363 | my $res = $ua->post ( |
374 | my $res = $ua->post ( |
364 | $ENV{CFPLUS_UPLOAD}, |
375 | $ENV{CFPLUS_UPLOAD}, |
365 | Content_Type => 'multipart/form-data', |
376 | Content_Type => 'multipart/form-data', |
366 | Content => [ |
377 | Content => [ |
367 | path => $path, |
378 | path => $path, |
368 | mapdir => $::MAPDIR, |
379 | mapdir => $srcrep, |
369 | map => $mapdata, |
380 | map => $mapdata, |
370 | revision => $rev, |
381 | revision => $rev, |
371 | cf_login => $login, #ENV{CFPLUS_LOGIN}, |
382 | cf_login => $login, #ENV{CFPLUS_LOGIN}, |
372 | cf_password => $password, #ENV{CFPLUS_PASSWORD}, |
383 | cf_password => $password, #ENV{CFPLUS_PASSWORD}, |
373 | comment => "", |
384 | comment => "", |