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.6 by root, Sun Mar 11 02:12:45 2007 UTC vs.
Revision 1.16 by root, Wed Mar 14 15:47:21 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 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
154 (map { 158 (map {
155 ( 159 (
156 "(", 160 "(",
157 "+clone", 161 "+clone",
158 -crop => (sprintf "%dx%d+%d+%d", $T, $T, $_->[0] * $T, $_->[1] * $T), 162 -crop => (sprintf "%dx%d+%d+%d", $T, $T, $_->[0] * $T, $_->[1] * $T),
163 "+repage",
159 -write => "png:$_->[2]~", 164 -write => "png:$_->[2]~",
160 "+delete", 165 "+delete",
161 ")", 166 ")",
162 ) 167 )
163 } @todo), 168 } @todo),
201 206
202 my $arc = read_arch "$dir/$file"; 207 my $arc = read_arch "$dir/$file";
203 for my $o (values %$arc) { 208 for my $o (values %$arc) {
204 push @ARC, $o; 209 push @ARC, $o;
205 210
211 $o->{editor_folder} = $dir;
212
206 my $visibility = delete $o->{visibility}; 213 my $visibility = delete $o->{visibility};
207 my $magicmap = delete $o->{magicmap}; 214 my $magicmap = delete $o->{magicmap};
208 215
209 # find upper left corner :/ 216 # find upper left corner :/
210 # omg, this is sooo broken 217 # omg, this is sooo broken
218 my $x = $o->{x} - $dx; 225 my $x = $o->{x} - $dx;
219 my $y = $o->{y} - $dy; 226 my $y = $o->{y} - $dy;
220 227
221 my $ext = $x|$y ? "+$x+$y" : ""; 228 my $ext = $x|$y ? "+$x+$y" : "";
222 229
223 $o->{face} .= $ext; 230 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/;
224 231
225 my $visibility = delete $o->{visibility} if exists $o->{visibility}; 232 my $visibility = delete $o->{visibility} if exists $o->{visibility};
226 my $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; 233 my $magicmap = delete $o->{magicmap} if exists $o->{magicmap};
227 234
228 my $anim = delete $o->{anim}; 235 my $anim = delete $o->{anim};
229 236
230 if ($anim) { 237 if ($anim) {
231 $o->{animation} = "$o->{_name}$ext"; 238 $o->{animation} = "$o->{_name}";
232 239
233 for (@$anim) { 240 for (@$anim) {
234 $_ .= $ext unless /^facings\s/; 241 $_ .= $ext unless /^facings\s|^blank.x11$|^empty.x11$/;
235 } 242 }
236 243
237 $ANIM{"$o->{_name}$ext"} = 244 $ANIM{"$o->{_name}$ext"} =
238 join "", map "$_\n", 245 join "", map "$_\n",
239 "anim $o->{_name}$ext", 246 "anim $o->{_name}",
240 @$anim, 247 @$anim,
241 "mina"; 248 "mina";
242 } 249 }
243 250
244 for my $face ($o->{face} || (), @{$anim || []}) { 251 for my $face ($o->{face} || (), @{$anim || []}) {
245 next if /^facings\s/; 252 next if $face =~ /^facings\s|^blank.x11$|^empty.x11$/;
246 253
247 my $info = $FACEINFO{$face} ||= {}; 254 my $info = $FACEINFO{$face} ||= {};
248 255
249 $info->{visibility} = $visibility if defined $visibility; 256 $info->{visibility} = $visibility if defined $visibility;
250 $info->{magicmap} = $magicmap if defined $magicmap; 257 $info->{magicmap} = $magicmap if defined $magicmap;
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 }
251 } 267 }
252 } 268 }
253 } 269 }
254 } 270 }
255 } 271 }
256 272
257 sub process_trs { 273 sub process_trs {
258 while (@trs) { 274 while (@trs) {
259 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;
260 } 285 }
261 } 286 }
262 287
263 sub find_files; 288 sub find_files;
264 sub find_files { 289 sub find_files {
286 } 311 }
287 312
288 sub inst_arch($) { 313 sub inst_arch($) {
289 my (undef, $path) = @_; 314 my (undef, $path) = @_;
290 315
291 print "installing '$path' to '$DATADIR'\n\n"; 316 print "installing '$path' to '$DATADIR'\n";
292 317
293 if (!-d "$path/treasures") { 318 if (!-d "$path/treasures") {
294 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";
295 exit 1 unless $FORCE; 320 exit 1 unless $FORCE;
296 } 321 }
311 } 336 }
312 337
313 { 338 {
314 open my $fh, ">:utf8", "$DATADIR/archetypes~" 339 open my $fh, ">:utf8", "$DATADIR/archetypes~"
315 or die "$DATADIR/archetypes~: $!"; 340 or die "$DATADIR/archetypes~: $!";
341 substr $_->{editor_folder}, 0, 1 + length $path, "" for @ARC;
316 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;
317 } 349 }
318 350
319 { 351 {
320 while (my ($k, $v) = each %FACEINFO) { 352 while (my ($k, $v) = each %FACEINFO) {
321 $v->{data32} ||= delete $PNG32{$k}; 353 $v->{data32} ||= delete $PNG32{$k};
322 } 354 }
323 355
324 while (my ($k, $v) = each %FACEINFO) { 356 while (my ($k, $v) = each %FACEINFO) {
325 exists $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";
326 358
327 $v->{chksum32} = Digest::MD5::md5 $v->{data32}; 359 $v->{chksum32} = Digest::MD5::md5 $v->{data32};
328 } 360 }
329 361
330 open my $fh, ">:perlio", "$DATADIR/faces~" 362 open my $fh, ">:perlio", "$DATADIR/faces~"
331 or die "$DATADIR/faces~: $!"; 363 or die "$DATADIR/faces~: $!";
332 364
365 $FACEINFO{""} = { version => 1};
333 print $fh Storable::nfreeze \%FACEINFO; 366 print $fh Storable::nfreeze \%FACEINFO;
334
335 #use PApp::Util; warn PApp::Util::dumpval \%FACEINFO;
336 } 367 }
337 368
338 for (qw(archetypes faces animations)) { 369 for (qw(archetypes faces animations treasures)) {
339 chmod 0644, "$DATADIR/$_~"; 370 chmod 0644, "$DATADIR/$_~";
340 rename "$DATADIR/$_~", "$DATADIR/$_"; 371 rename "$DATADIR/$_~", "$DATADIR/$_"
372 or die "$DATADIR/$_: $!";
341 } 373 }
342 374
343 die "--install-arch not fully implemented\n"; 375 print "archetype data installed successfully.\n";
344 } 376 }
345} 377}
346 378
347Getopt::Long::Configure ("bundling", "no_ignore_case"); 379Getopt::Long::Configure ("bundling", "no_ignore_case");
348GetOptions ( 380GetOptions (

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines