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.85 by root, Sun Oct 8 21:22:30 2006 UTC vs.
Revision 1.88 by root, Mon Oct 9 01:06:36 2006 UTC

80 80
81sub editor_invoke { 81sub editor_invoke {
82 my $editsup = $::CONN && $::CONN->{editor_support} 82 my $editsup = $::CONN && $::CONN->{editor_support}
83 or return; 83 or return;
84 84
85 # putting the password into the env is somewhat tasteless 85 CFPlus::background {
86# local $ENV{CFPLUS_LOGIN} = $::PROFILE->{user};
87# local $ENV{CFPLUS_PASSWORD} = $::PROFILE->{password};
88# local $ENV{CFPLUS_UPLOAD} = $::CONN->{upload};
89
90 my ($pid, $fh);
91 unless ($pid = open $fh, "-|:utf8", "-") {
92 $SIG{__DIE__} = sub {
93 warn "@_\n";
94 CFPlus::_exit 99;
95 };
96
97 open STDERR, ">&STDOUT";
98 binmode STDOUT, ":utf8";
99 binmode STDERR, ":utf8";
100 close $fh;
101
102 $| = 1;
103 print "preparing editor startup...\n"; 86 print "preparing editor startup...\n";
104 CFPlus::set_proxy; 87 CFPlus::set_proxy;
105 88
106 my $server = $editsup->{gameserver} || "default"; 89 my $server = $editsup->{gameserver} || "default";
107 $server =~ s/([^a-zA-Z0-9_\-])/sprintf "=%x=", ord $1/ge; 90 $server =~ s/([^a-zA-Z0-9_\-])/sprintf "=%x=", ord $1/ge;
129 } 112 }
130 113
131 if (1) { # upload a map 114 if (1) { # upload a map
132 my $mapname = $::CONN->{map_info}[0]; 115 my $mapname = $::CONN->{map_info}[0];
133 116
117 my $mappath = "$mapdir/$mapname";
118
119 -e $mappath and die "$mappath already exists\n";
120
134 print "getting map revision for $mapname...\n"; 121 print "getting map revision for $mapname...\n";
135 122
136 # try to get the most recent head revision, what a hack, 123 # try to get the most recent head revision, what a hack,
137 # this should have been returned while downloading *sigh* 124 # this should have been returned while downloading *sigh*
138 my $log = (check_lwp $ua->get ("$editsup->{cvs_root}/$mapname?view=log&logsort=rev"))->decoded_content; 125 my $log = (check_lwp $ua->get ("$editsup->{cvs_root}/$mapname?view=log&logsort=rev"))->decoded_content;
141 my $rev = $1; 128 my $rev = $1;
142 129
143 print "downloading revision $rev...\n"; 130 print "downloading revision $rev...\n";
144 131
145 my $map = (check_lwp $ua->get ("$editsup->{cvs_root}/$mapname?rev=$rev"))->decoded_content; 132 my $map = (check_lwp $ua->get ("$editsup->{cvs_root}/$mapname?rev=$rev"))->decoded_content;
133
134 my $meta = {
135 %$editsup,
136 path => $mapname,
137 revision => $rev,
138 cf_login => $::PROFILE->{user},
139 };
140
141 require File::Basename;
142 require File::Path;
143
144 File::Path::mkpath (File::Basename::dirname ($mappath));
145 open my $fh, ">:raw:perlio", "$mappath.meta"
146 or die "$mappath.meta: $!\n";
147 print $fh CFPlus::to_json $meta;
148 close $fh;
149 open my $fh, ">:raw:perlio:utf8", $mappath
150 or die "$mappath: $!\n";
151 print $fh $map;
152 close $fh;
153
154 print "saved as $mappath\n";
155
156 print "invoking editor...\n";
157 exec "/root/s2/gce $mappath";#d#
146 158
147 # now upload it 159 # now upload it
148# require HTTP::Request::Common; 160# require HTTP::Request::Common;
149# 161#
150# my $res = $ua->post ( 162# my $res = $ua->post (
171# } 183# }
172 } else { 184 } else {
173 die "viewvc parse error, unable to detect revision\n"; 185 die "viewvc parse error, unable to detect revision\n";
174 } 186 }
175 } 187 }
176
177 print "invoking editor...\n";
178 exec "/root/s2/gce";#d#
179
180 CFPlus::_exit;
181 }
182
183 my $buffer;
184
185 Event->io (fd => $fh, poll => 'r', cb => sub {
186 unless (sysread $fh, $buffer, 4096, length $buffer) {
187 $_[0]->w->cancel;
188 $buffer .= "done\n";
189 }
190
191 while ($buffer =~ s/^(.*)\n//) {
192 ::message ({
193 markup => "editor($pid): " . CFPlus::asxml $1,
194 });
195 }
196 }); 188 }
197} 189}
198 190
199sub invoke_button_down { 191sub invoke_button_down {
200 my ($self, $ev, $x, $y) = @_; 192 my ($self, $ev, $x, $y) = @_;
201 193

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines