… | |
… | |
81 | |
81 | |
82 | { |
82 | { |
83 | our %PNG32; |
83 | our %PNG32; |
84 | our %FACEINFO; |
84 | our %FACEINFO; |
85 | our @ARC; |
85 | our @ARC; |
|
|
86 | our $TRS; |
86 | our $NFILE; |
87 | our $NFILE; |
87 | our %ANIM; |
88 | our %ANIM; |
|
|
89 | our $SMOOTH; |
88 | |
90 | |
89 | our (@png, @trs, @arc); # files we are interested in |
91 | our (@png, @trs, @arc); # files we are interested in |
90 | |
92 | |
91 | sub commit_png { |
93 | sub commit_png { |
92 | my ($name, $data) = @_; |
94 | my ($name, $data) = @_; |
… | |
… | |
202 | |
204 | |
203 | my $arc = read_arch "$dir/$file"; |
205 | my $arc = read_arch "$dir/$file"; |
204 | for my $o (values %$arc) { |
206 | for my $o (values %$arc) { |
205 | push @ARC, $o; |
207 | push @ARC, $o; |
206 | |
208 | |
|
|
209 | $o->{editor_folder} = $dir; |
|
|
210 | |
207 | my $visibility = delete $o->{visibility}; |
211 | my $visibility = delete $o->{visibility}; |
208 | my $magicmap = delete $o->{magicmap}; |
212 | my $magicmap = delete $o->{magicmap}; |
209 | |
213 | |
210 | # find upper left corner :/ |
214 | # find upper left corner :/ |
211 | # omg, this is sooo broken |
215 | # omg, this is sooo broken |
… | |
… | |
219 | my $x = $o->{x} - $dx; |
223 | my $x = $o->{x} - $dx; |
220 | my $y = $o->{y} - $dy; |
224 | my $y = $o->{y} - $dy; |
221 | |
225 | |
222 | my $ext = $x|$y ? "+$x+$y" : ""; |
226 | my $ext = $x|$y ? "+$x+$y" : ""; |
223 | |
227 | |
224 | $o->{face} .= $ext; |
228 | $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/; |
225 | |
229 | |
226 | my $visibility = delete $o->{visibility} if exists $o->{visibility}; |
230 | my $visibility = delete $o->{visibility} if exists $o->{visibility}; |
227 | my $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; |
231 | my $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; |
228 | |
232 | |
229 | my $anim = delete $o->{anim}; |
233 | my $anim = delete $o->{anim}; |
230 | |
234 | |
231 | if ($anim) { |
235 | if ($anim) { |
232 | $o->{animation} = "$o->{_name}$ext"; |
236 | $o->{animation} = "$o->{_name}"; |
233 | |
237 | |
234 | for (@$anim) { |
238 | for (@$anim) { |
235 | $_ .= $ext unless /^facings\s/; |
239 | $_ .= $ext unless /^facings\s|^blank.x11$|^empty.x11$/; |
236 | } |
240 | } |
237 | |
241 | |
238 | $ANIM{"$o->{_name}$ext"} = |
242 | $ANIM{"$o->{_name}$ext"} = |
239 | join "", map "$_\n", |
243 | join "", map "$_\n", |
240 | "anim $o->{_name}$ext", |
244 | "anim $o->{_name}", |
241 | @$anim, |
245 | @$anim, |
242 | "mina"; |
246 | "mina"; |
243 | } |
247 | } |
244 | |
248 | |
245 | for my $face ($o->{face} || (), @{$anim || []}) { |
249 | for my $face ($o->{face} || (), @{$anim || []}) { |
246 | next if /^facings\s/; |
250 | next if $face =~ /^facings\s|^blank.x11$|^empty.x11$/; |
247 | |
251 | |
248 | my $info = $FACEINFO{$face} ||= {}; |
252 | my $info = $FACEINFO{$face} ||= {}; |
249 | |
253 | |
250 | $info->{visibility} = $visibility if defined $visibility; |
254 | $info->{visibility} = $visibility if defined $visibility; |
251 | $info->{magicmap} = $magicmap if defined $magicmap; |
255 | $info->{magicmap} = $magicmap if defined $magicmap; |
|
|
256 | } |
|
|
257 | |
|
|
258 | if (my $smooth = delete $o->{smoothface}) { |
|
|
259 | $SMOOTH .= "$smooth\n"; |
252 | } |
260 | } |
253 | } |
261 | } |
254 | } |
262 | } |
255 | } |
263 | } |
256 | } |
264 | } |
257 | |
265 | |
258 | sub process_trs { |
266 | sub process_trs { |
259 | while (@trs) { |
267 | while (@trs) { |
260 | my ($dir, $file) = @{pop @trs}; |
268 | my ($dir, $file) = @{pop @trs}; |
|
|
269 | my $path = "$dir/$file"; |
|
|
270 | |
|
|
271 | my $trs; |
|
|
272 | if (0 > aio_load $path, $trs) { |
|
|
273 | warn "$path: $!, skipping.\n"; |
|
|
274 | next; |
|
|
275 | } |
|
|
276 | |
|
|
277 | $TRS .= $trs; |
261 | } |
278 | } |
262 | } |
279 | } |
263 | |
280 | |
264 | sub find_files; |
281 | sub find_files; |
265 | sub find_files { |
282 | sub find_files { |
… | |
… | |
312 | } |
329 | } |
313 | |
330 | |
314 | { |
331 | { |
315 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
332 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
316 | or die "$DATADIR/archetypes~: $!"; |
333 | or die "$DATADIR/archetypes~: $!"; |
|
|
334 | substr $_->{editor_folder}, 0, 1 + length $path, "" for @ARC; |
317 | print $fh Crossfire::archlist_to_string \@ARC; |
335 | print $fh Crossfire::archlist_to_string \@ARC; |
|
|
336 | } |
|
|
337 | |
|
|
338 | { |
|
|
339 | open my $fh, ">:utf8", "$DATADIR/smooth~" |
|
|
340 | or die "$DATADIR/smooth~: $!"; |
|
|
341 | print $fh $SMOOTH; |
|
|
342 | } |
|
|
343 | |
|
|
344 | { |
|
|
345 | open my $fh, ">:utf8", "$DATADIR/treasures~" |
|
|
346 | or die "$DATADIR/treasures~: $!"; |
|
|
347 | print $fh $TRS; |
318 | } |
348 | } |
319 | |
349 | |
320 | { |
350 | { |
321 | while (my ($k, $v) = each %FACEINFO) { |
351 | while (my ($k, $v) = each %FACEINFO) { |
322 | $v->{data32} ||= delete $PNG32{$k}; |
352 | $v->{data32} ||= delete $PNG32{$k}; |
323 | } |
353 | } |
324 | |
354 | |
325 | while (my ($k, $v) = each %FACEINFO) { |
355 | while (my ($k, $v) = each %FACEINFO) { |
326 | exists $v->{data32} or warn "$k: face has no png32. this will crash the server.\n"; |
356 | length $v->{data32} or warn "$k: face has no png32. this will not work (shoddy gcfclient will crash of course).\n"; |
327 | |
357 | |
328 | $v->{chksum32} = Digest::MD5::md5 $v->{data32}; |
358 | $v->{chksum32} = Digest::MD5::md5 $v->{data32}; |
329 | } |
359 | } |
330 | |
360 | |
331 | open my $fh, ">:perlio", "$DATADIR/faces~" |
361 | open my $fh, ">:perlio", "$DATADIR/faces~" |
332 | or die "$DATADIR/faces~: $!"; |
362 | or die "$DATADIR/faces~: $!"; |
333 | |
363 | |
334 | print $fh Storable::nfreeze \%FACEINFO; |
364 | print $fh Storable::nfreeze \%FACEINFO; |
335 | |
|
|
336 | #use PApp::Util; warn PApp::Util::dumpval \%FACEINFO; |
|
|
337 | } |
365 | } |
338 | |
366 | |
339 | for (qw(archetypes faces animations)) { |
367 | for (qw(archetypes faces animations treasures smooth)) { |
340 | chmod 0644, "$DATADIR/$_~"; |
368 | chmod 0644, "$DATADIR/$_~"; |
341 | rename "$DATADIR/$_~", "$DATADIR/$_"; |
369 | rename "$DATADIR/$_~", "$DATADIR/$_"; |
342 | } |
370 | } |
343 | |
|
|
344 | die "--install-arch not fully implemented\n"; |
|
|
345 | } |
371 | } |
346 | } |
372 | } |
347 | |
373 | |
348 | Getopt::Long::Configure ("bundling", "no_ignore_case"); |
374 | Getopt::Long::Configure ("bundling", "no_ignore_case"); |
349 | GetOptions ( |
375 | GetOptions ( |