… | |
… | |
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 | or 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 | |
… | |
… | |
202 | |
206 | |
203 | my $arc = read_arch "$dir/$file"; |
207 | my $arc = read_arch "$dir/$file"; |
204 | for my $o (values %$arc) { |
208 | for my $o (values %$arc) { |
205 | push @ARC, $o; |
209 | push @ARC, $o; |
206 | |
210 | |
|
|
211 | $o->{editor_folder} = $dir; |
|
|
212 | |
207 | my $visibility = delete $o->{visibility}; |
213 | my $visibility = delete $o->{visibility}; |
208 | my $magicmap = delete $o->{magicmap}; |
214 | my $magicmap = delete $o->{magicmap}; |
209 | |
215 | |
210 | # find upper left corner :/ |
216 | # find upper left corner :/ |
211 | # omg, this is sooo broken |
217 | # omg, this is sooo broken |
… | |
… | |
248 | my $info = $FACEINFO{$face} ||= {}; |
254 | my $info = $FACEINFO{$face} ||= {}; |
249 | |
255 | |
250 | $info->{visibility} = $visibility if defined $visibility; |
256 | $info->{visibility} = $visibility if defined $visibility; |
251 | $info->{magicmap} = $magicmap if defined $magicmap; |
257 | $info->{magicmap} = $magicmap if defined $magicmap; |
252 | } |
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 | } |
253 | } |
268 | } |
254 | } |
269 | } |
255 | } |
270 | } |
256 | } |
271 | } |
257 | |
272 | |
258 | sub process_trs { |
273 | sub process_trs { |
259 | while (@trs) { |
274 | while (@trs) { |
260 | 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; |
261 | } |
285 | } |
262 | } |
286 | } |
263 | |
287 | |
264 | sub find_files; |
288 | sub find_files; |
265 | sub find_files { |
289 | sub find_files { |
… | |
… | |
287 | } |
311 | } |
288 | |
312 | |
289 | sub inst_arch($) { |
313 | sub inst_arch($) { |
290 | my (undef, $path) = @_; |
314 | my (undef, $path) = @_; |
291 | |
315 | |
292 | print "installing '$path' to '$DATADIR'\n\n"; |
316 | print "installing '$path' to '$DATADIR'\n"; |
293 | |
317 | |
294 | if (!-d "$path/treasures") { |
318 | if (!-d "$path/treasures") { |
295 | 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"; |
296 | exit 1 unless $FORCE; |
320 | exit 1 unless $FORCE; |
297 | } |
321 | } |
… | |
… | |
312 | } |
336 | } |
313 | |
337 | |
314 | { |
338 | { |
315 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
339 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
316 | or die "$DATADIR/archetypes~: $!"; |
340 | or die "$DATADIR/archetypes~: $!"; |
|
|
341 | substr $_->{editor_folder}, 0, 1 + length $path, "" for @ARC; |
317 | 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; |
318 | } |
349 | } |
319 | |
350 | |
320 | { |
351 | { |
321 | while (my ($k, $v) = each %FACEINFO) { |
352 | while (my ($k, $v) = each %FACEINFO) { |
322 | $v->{data32} ||= delete $PNG32{$k}; |
353 | $v->{data32} ||= delete $PNG32{$k}; |
323 | } |
354 | } |
324 | |
355 | |
325 | while (my ($k, $v) = each %FACEINFO) { |
356 | while (my ($k, $v) = each %FACEINFO) { |
326 | 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"; |
327 | |
358 | |
328 | $v->{chksum32} = Digest::MD5::md5 $v->{data32}; |
359 | $v->{chksum32} = Digest::MD5::md5 $v->{data32}; |
329 | } |
360 | } |
330 | |
361 | |
331 | open my $fh, ">:perlio", "$DATADIR/faces~" |
362 | open my $fh, ">:perlio", "$DATADIR/faces~" |
332 | or die "$DATADIR/faces~: $!"; |
363 | or die "$DATADIR/faces~: $!"; |
333 | |
364 | |
334 | print $fh Storable::nfreeze \%FACEINFO; |
365 | print $fh Storable::nfreeze \%FACEINFO; |
335 | |
|
|
336 | #use PApp::Util; warn PApp::Util::dumpval \%FACEINFO; |
|
|
337 | } |
366 | } |
338 | |
367 | |
339 | for (qw(archetypes faces animations)) { |
368 | for (qw(archetypes faces animations treasures)) { |
340 | chmod 0644, "$DATADIR/$_~"; |
369 | chmod 0644, "$DATADIR/$_~"; |
341 | rename "$DATADIR/$_~", "$DATADIR/$_"; |
370 | rename "$DATADIR/$_~", "$DATADIR/$_" |
|
|
371 | or die "$DATADIR/$_: $!"; |
342 | } |
372 | } |
343 | |
373 | |
344 | die "--install-arch not fully implemented\n"; |
374 | print "archetype data installed successfully.\n"; |
345 | } |
375 | } |
346 | } |
376 | } |
347 | |
377 | |
348 | Getopt::Long::Configure ("bundling", "no_ignore_case"); |
378 | Getopt::Long::Configure ("bundling", "no_ignore_case"); |
349 | GetOptions ( |
379 | GetOptions ( |