ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/utils/cfutil.in
(Generate patch)

Comparing deliantra/server/utils/cfutil.in (file contents):
Revision 1.8 by root, Sun Mar 11 21:26:06 2007 UTC vs.
Revision 1.13 by root, Mon Mar 12 17:33:12 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines