ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/MapWidget.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/MapWidget.pm (file contents):
Revision 1.92 by root, Wed Nov 8 01:22:00 2006 UTC vs.
Revision 1.93 by root, Thu Nov 16 19:42:45 2006 UTC

67 ::stop_game (); 67 ::stop_game ();
68 local $::PROFILE->{host} = $server; 68 local $::PROFILE->{host} = $server;
69 ::start_game (); 69 ::start_game ();
70} 70}
71 71
72sub check_lwp($) {
73 my ($res) = @_;
74
75 $res->is_error
76 and die $res->status_line;
77
78 $res
79}
80
81sub editor_invoke { 72sub editor_invoke {
82 my $editsup = $::CONN && $::CONN->{editor_support} 73 my $editsup = $::CONN && $::CONN->{editor_support}
83 or return; 74 or return;
84 75
85 CFPlus::background { 76 CFPlus::background {
86 print "preparing editor startup...\n"; 77 print "preparing editor startup...\n";
87 CFPlus::set_proxy;
88 78
89 my $server = $editsup->{gameserver} || "default"; 79 my $server = $editsup->{gameserver} || "default";
90 $server =~ s/([^a-zA-Z0-9_\-])/sprintf "=%x=", ord $1/ge; 80 $server =~ s/([^a-zA-Z0-9_\-])/sprintf "=%x=", ord $1/ge;
91 81
92 local $ENV{CROSSFIRE_MAPDIR} = my $mapdir = "$Crossfire::VARDIR/map.$server"; mkdir $mapdir; 82 local $ENV{CROSSFIRE_MAPDIR} = my $mapdir = "$Crossfire::VARDIR/map.$server"; mkdir $mapdir;
93 local $ENV{CROSSFIRE_LIBDIR} = my $libdir = "$Crossfire::VARDIR/lib.$server"; mkdir $libdir; 83 local $ENV{CROSSFIRE_LIBDIR} = my $libdir = "$Crossfire::VARDIR/lib.$server"; mkdir $libdir;
94 84
95 print "map directory is $mapdir\n"; 85 print "map directory is $mapdir\n";
96 print "lib directory is $libdir\n"; 86 print "lib directory is $libdir\n";
97 87
98 require LWP::UserAgent; 88 my $ua = CFPlus::lwp_useragent;
99
100 my $ua = LWP::UserAgent->new (
101 agent => "cfplus $CFPlus::VERSION",
102 keep_alive => 1,
103 env_proxy => 1,
104 timeout => 30,
105 );
106 89
107 for my $file (qw(archetypes crossfire.0)) { 90 for my $file (qw(archetypes crossfire.0)) {
108 my $url = "$editsup->{lib_root}$file"; 91 my $url = "$editsup->{lib_root}$file";
109 print "mirroring $url...\n"; 92 print "mirroring $url...\n";
110 check_lwp $ua->mirror ($url, "$libdir/$file"); 93 CFPlus::lwp_check $ua->mirror ($url, "$libdir/$file");
111 printf "%s size %d octets\n", $file, -s "$libdir/$file"; 94 printf "%s size %d octets\n", $file, -s "$libdir/$file";
112 } 95 }
113 96
114 if (1) { # upload a map 97 if (1) { # upload a map
115 my $mapname = $::CONN->{map_info}[0]; 98 my $mapname = $::CONN->{map_info}[0];
120 103
121 print "getting map revision for $mapname...\n"; 104 print "getting map revision for $mapname...\n";
122 105
123 # try to get the most recent head revision, what a hack, 106 # try to get the most recent head revision, what a hack,
124 # this should have been returned while downloading *sigh* 107 # this should have been returned while downloading *sigh*
125 my $log = (check_lwp $ua->get ("$editsup->{cvs_root}/$mapname?view=log&logsort=rev"))->decoded_content; 108 my $log = (CFPlus::lwp_check $ua->get ("$editsup->{cvs_root}/$mapname?view=log&logsort=rev"))->decoded_content;
126 109
127 if ($log =~ /\?rev=(\d+\.\d+)"/) { 110 if ($log =~ /\?rev=(\d+\.\d+)"/) {
128 my $rev = $1; 111 my $rev = $1;
129 112
130 print "downloading revision $rev...\n"; 113 print "downloading revision $rev...\n";
131 114
132 my $map = (check_lwp $ua->get ("$editsup->{cvs_root}/$mapname?rev=$rev"))->decoded_content; 115 my $map = (CFPlus::lwp_check $ua->get ("$editsup->{cvs_root}/$mapname?rev=$rev"))->decoded_content;
133 116
134 my $meta = { 117 my $meta = {
135 %$editsup, 118 %$editsup,
136 path => $mapname, 119 path => $mapname,
137 revision => $rev, 120 revision => $rev,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines