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.20 by elmex, Mon Aug 14 18:52:48 2006 UTC vs.
Revision 1.24 by elmex, Fri Jan 5 17:04:17 2007 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';
25use strict;
22 26
23our @EXPORT = qw(insert_arch_stack_layer replace_arch_stack_layer new_arch_pb 27our @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 28 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 29 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); 30 def arch_is_exit map2abs exit_paths pseudohtml2txt arch_is_connector);
68} 72}
69 73
70sub map2abs { 74sub map2abs {
71 my ($dest, $mape) = @_; 75 my ($dest, $mape) = @_;
72 76
73 $mappath = abs_path $mappath; 77 #$dest = abs_path $dest;
74 my $dir; 78 my $dir;
75 if (File::Spec->file_name_is_absolute($dest)) { 79 if (File::Spec->file_name_is_absolute($dest)) {
76 $dir = catdir ($::CFG->{MAPDIR}, $dest); 80 $dir = catdir ($::MAPDIR, $dest);
77 } else { 81 } else {
78 my ($v, $p, $f) = File::Spec->splitpath ($mape->{path}); 82 my ($v, $p, $f) = File::Spec->splitpath ($mape->{path});
79 $dir = File::Spec->rel2abs ($dest, File::Spec->catpath ($v, $p)); 83 $dir = File::Spec->rel2abs ($dest, File::Spec->catpath ($v, $p));
80 } 84 }
81 return $dir; 85 return $dir;
116 120
117sub fill_pb_from_arch { 121sub fill_pb_from_arch {
118 my ($pb, $a) = @_; 122 my ($pb, $a) = @_;
119 123
120 my $o = $Crossfire::ARCH{$a->{_name}}; 124 my $o = $Crossfire::ARCH{$a->{_name}};
121 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"}
122 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 }
123 130
124 $face or return; 131 $face or return;
125 132
126 $pb->fill (0x00000000); 133 $pb->fill (0x00000000);
127 $TILE->composite ($pb, 134 $TILE->composite ($pb,
351 } 358 }
352 359
353 return \@outstack; 360 return \@outstack;
354} 361}
355 362
363sub upload {
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 );
372 require HTTP::Request::Common;
373
374 my $res = $ua->post (
375 $ENV{CFPLUS_UPLOAD},
376 Content_Type => 'multipart/form-data',
377 Content => [
378 path => $path,
379 mapdir => $srcrep,
380 map => $mapdata,
381 revision => $rev,
382 cf_login => $login, #ENV{CFPLUS_LOGIN},
383 cf_password => $password, #ENV{CFPLUS_PASSWORD},
384 comment => "",
385 ]
386 );
387
388 if ($res->is_error) {
389 # fatal condition
390 warn $res->status_line;
391 } else {
392 # script replies are marked as {{..}}
393 my @msgs = $res->decoded_content =~ m/\{\{(.*?)\}\}/g;
394 warn map "$_\n", @msgs;
395 }
396}
397
356=head1 AUTHOR 398=head1 AUTHOR
357 399
358 Marc Lehmann <schmorp@schmorp.de> 400 Marc Lehmann <schmorp@schmorp.de>
359 http://home.schmorp.de/ 401 http://home.schmorp.de/
360 402

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines