--- deliantra/gde/GCE/Util.pm 2006/08/14 18:52:48 1.20 +++ deliantra/gde/GCE/Util.pm 2007/01/05 17:04:17 1.24 @@ -18,7 +18,11 @@ use Crossfire; use Crossfire::MapWidget; use File::Spec::Functions; +use File::Basename; +use File::Path; +use HTTP::Request::Common; use Cwd 'abs_path'; +use strict; our @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 @@ -70,10 +74,10 @@ sub map2abs { my ($dest, $mape) = @_; - $mappath = abs_path $mappath; + #$dest = abs_path $dest; my $dir; if (File::Spec->file_name_is_absolute($dest)) { - $dir = catdir ($::CFG->{MAPDIR}, $dest); + $dir = catdir ($::MAPDIR, $dest); } else { my ($v, $p, $f) = File::Spec->splitpath ($mape->{path}); $dir = File::Spec->rel2abs ($dest, File::Spec->catpath ($v, $p)); @@ -118,8 +122,11 @@ my ($pb, $a) = @_; my $o = $Crossfire::ARCH{$a->{_name}}; - my $face = $Crossfire::FACE{$a->{face} || $o->{face} || "blank.111"} - or warn "no gfx found for arch '$a->{_name}' at ($x|$y)\n"; + my $face = $Crossfire::FACE{$a->{face} || $o->{face} || "blank.111"}; + unless ($face) { + $face = $Crossfire::FACE{"blank.x11"} + or warn "no gfx found for arch '$a->{_name}'\n"; + } $face or return; @@ -353,6 +360,41 @@ return \@outstack; } +sub upload { + my ($login, $password, $srcrep, $path, $rev, $mapdata) = @_; + require LWP::UserAgent; + my $ua = LWP::UserAgent->new ( + agent => "gcrossedit", + keep_alive => 1, + env_proxy => 1, + timeout => 30, + ); + require HTTP::Request::Common; + + my $res = $ua->post ( + $ENV{CFPLUS_UPLOAD}, + Content_Type => 'multipart/form-data', + Content => [ + path => $path, + mapdir => $srcrep, + map => $mapdata, + revision => $rev, + cf_login => $login, #ENV{CFPLUS_LOGIN}, + cf_password => $password, #ENV{CFPLUS_PASSWORD}, + comment => "", + ] + ); + + if ($res->is_error) { + # fatal condition + warn $res->status_line; + } else { + # script replies are marked as {{..}} + my @msgs = $res->decoded_content =~ m/\{\{(.*?)\}\}/g; + warn map "$_\n", @msgs; + } +} + =head1 AUTHOR Marc Lehmann