… | |
… | |
67 | } |
67 | } |
68 | |
68 | |
69 | sub inst_maps($) { |
69 | sub inst_maps($) { |
70 | my (undef, $path) = @_; |
70 | my (undef, $path) = @_; |
71 | |
71 | |
72 | print "installing '$path' to '$DATADIR/maps'\n\n"; |
72 | print "installing '$path' to '$DATADIR/maps'\n"; |
73 | |
73 | |
74 | if (!-f "$path/regions") { |
74 | if (!-f "$path/regions") { |
75 | warn "'$path' does not look like a maps directory ('regions' file is missing).\n"; |
75 | warn "'$path' does not look like a maps directory ('regions' file is missing).\n"; |
76 | exit 1 unless $FORCE; |
76 | exit 1 unless $FORCE; |
77 | } |
77 | } |
78 | |
78 | |
79 | system $RSYNC, "-av", "$path/.", "$DATADIR/maps/.", "--delete", "--exclude", "CVS", "--delete-excluded"; |
79 | system $RSYNC, "-av", "$path/.", "$DATADIR/maps/.", "--delete", "--exclude", "CVS", "--delete-excluded" |
|
|
80 | and die "map installation failed.\n"; |
|
|
81 | |
|
|
82 | print "maps installed successfully.\n"; |
80 | } |
83 | } |
81 | |
84 | |
82 | { |
85 | { |
83 | our %PNG32; |
86 | our %PNG32; |
84 | our %FACEINFO; |
87 | our %FACEINFO; |
85 | our @ARC; |
88 | our @ARC; |
|
|
89 | our $TRS; |
86 | our $NFILE; |
90 | our $NFILE; |
87 | our %ANIM; |
91 | our %ANIM; |
88 | |
92 | |
89 | our (@png, @trs, @arc); # files we are interested in |
93 | our (@png, @trs, @arc); # files we are interested in |
90 | |
94 | |
… | |
… | |
250 | my $info = $FACEINFO{$face} ||= {}; |
254 | my $info = $FACEINFO{$face} ||= {}; |
251 | |
255 | |
252 | $info->{visibility} = $visibility if defined $visibility; |
256 | $info->{visibility} = $visibility if defined $visibility; |
253 | $info->{magicmap} = $magicmap if defined $magicmap; |
257 | $info->{magicmap} = $magicmap if defined $magicmap; |
254 | } |
258 | } |
|
|
259 | |
|
|
260 | if (my $smooth = delete $o->{smoothface}) { |
|
|
261 | my ($face, $smooth) = split /\s+/, $smooth; |
|
|
262 | # skip empty_S.x11, it seems to server no purpose whatsoever |
|
|
263 | # but increases bandwidth demands and worse. |
|
|
264 | unless ($smooth eq "empty_S.x11") { |
|
|
265 | $FACEINFO{$face}{smooth} = $smooth; |
|
|
266 | } |
|
|
267 | } |
255 | } |
268 | } |
256 | } |
269 | } |
257 | } |
270 | } |
258 | } |
271 | } |
259 | |
272 | |
260 | sub process_trs { |
273 | sub process_trs { |
261 | while (@trs) { |
274 | while (@trs) { |
262 | my ($dir, $file) = @{pop @trs}; |
275 | my ($dir, $file) = @{pop @trs}; |
|
|
276 | my $path = "$dir/$file"; |
|
|
277 | |
|
|
278 | my $trs; |
|
|
279 | if (0 > aio_load $path, $trs) { |
|
|
280 | warn "$path: $!, skipping.\n"; |
|
|
281 | next; |
|
|
282 | } |
|
|
283 | |
|
|
284 | $TRS .= $trs; |
263 | } |
285 | } |
264 | } |
286 | } |
265 | |
287 | |
266 | sub find_files; |
288 | sub find_files; |
267 | sub find_files { |
289 | sub find_files { |
… | |
… | |
289 | } |
311 | } |
290 | |
312 | |
291 | sub inst_arch($) { |
313 | sub inst_arch($) { |
292 | my (undef, $path) = @_; |
314 | my (undef, $path) = @_; |
293 | |
315 | |
294 | print "installing '$path' to '$DATADIR'\n\n"; |
316 | print "installing '$path' to '$DATADIR'\n"; |
295 | |
317 | |
296 | if (!-d "$path/treasures") { |
318 | if (!-d "$path/treasures") { |
297 | warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n"; |
319 | warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n"; |
298 | exit 1 unless $FORCE; |
320 | exit 1 unless $FORCE; |
299 | } |
321 | } |
… | |
… | |
314 | } |
336 | } |
315 | |
337 | |
316 | { |
338 | { |
317 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
339 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
318 | or die "$DATADIR/archetypes~: $!"; |
340 | or die "$DATADIR/archetypes~: $!"; |
319 | substr $_->{editor_folder}, 0, length $path, "" for @ARC; |
341 | substr $_->{editor_folder}, 0, 1 + length $path, "" for @ARC; |
320 | print $fh Crossfire::archlist_to_string \@ARC; |
342 | print $fh Crossfire::archlist_to_string \@ARC; |
|
|
343 | } |
|
|
344 | |
|
|
345 | { |
|
|
346 | open my $fh, ">:utf8", "$DATADIR/treasures~" |
|
|
347 | or die "$DATADIR/treasures~: $!"; |
|
|
348 | print $fh $TRS; |
321 | } |
349 | } |
322 | |
350 | |
323 | { |
351 | { |
324 | while (my ($k, $v) = each %FACEINFO) { |
352 | while (my ($k, $v) = each %FACEINFO) { |
325 | $v->{data32} ||= delete $PNG32{$k}; |
353 | $v->{data32} ||= delete $PNG32{$k}; |
326 | } |
354 | } |
327 | |
355 | |
328 | while (my ($k, $v) = each %FACEINFO) { |
356 | while (my ($k, $v) = each %FACEINFO) { |
329 | length $v->{data32} or warn "$k: face has no png32. this will crash the server.\n"; |
357 | length $v->{data32} or warn "$k: face has no png32. this will not work (shoddy gcfclient will crash of course).\n"; |
330 | |
358 | |
331 | $v->{chksum32} = Digest::MD5::md5 $v->{data32}; |
359 | $v->{chksum32} = Digest::MD5::md5 $v->{data32}; |
332 | } |
360 | } |
333 | |
361 | |
334 | open my $fh, ">:perlio", "$DATADIR/faces~" |
362 | open my $fh, ">:perlio", "$DATADIR/faces~" |
335 | or die "$DATADIR/faces~: $!"; |
363 | or die "$DATADIR/faces~: $!"; |
336 | |
364 | |
|
|
365 | $FACEINFO{""} = { version => 1}; |
337 | print $fh Storable::nfreeze \%FACEINFO; |
366 | print $fh Storable::nfreeze \%FACEINFO; |
338 | |
|
|
339 | #use PApp::Util; warn PApp::Util::dumpval \%FACEINFO; |
|
|
340 | } |
367 | } |
341 | |
368 | |
342 | for (qw(archetypes faces animations)) { |
369 | for (qw(archetypes faces animations treasures)) { |
343 | chmod 0644, "$DATADIR/$_~"; |
370 | chmod 0644, "$DATADIR/$_~"; |
344 | rename "$DATADIR/$_~", "$DATADIR/$_"; |
371 | rename "$DATADIR/$_~", "$DATADIR/$_" |
|
|
372 | or die "$DATADIR/$_: $!"; |
345 | } |
373 | } |
346 | |
374 | |
347 | die "--install-arch not fully implemented\n"; |
375 | print "archetype data installed successfully.\n"; |
348 | } |
376 | } |
349 | } |
377 | } |
350 | |
378 | |
351 | Getopt::Long::Configure ("bundling", "no_ignore_case"); |
379 | Getopt::Long::Configure ("bundling", "no_ignore_case"); |
352 | GetOptions ( |
380 | GetOptions ( |