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

Comparing deliantra/server/lib/collect.pl.in (file contents):
Revision 1.1.1.3 by elmex, Wed Mar 15 14:04:57 2006 UTC vs.
Revision 1.8 by root, Sun May 27 02:26:20 2007 UTC

6 if ($ARGV[0] =~ m/^--?[hH](elp)?$/) { 6 if ($ARGV[0] =~ m/^--?[hH](elp)?$/) {
7 die ("\nUSAGE: perl collect.pl ARCHDIR\n". 7 die ("\nUSAGE: perl collect.pl ARCHDIR\n".
8 "\nWhere ARCHDIR is the directory where you stored the ". 8 "\nWhere ARCHDIR is the directory where you stored the ".
9 "raw archetypes.\n". 9 "raw archetypes.\n".
10 "This script will then create these files:\n". 10 "This script will then create these files:\n".
11 "archetypes,bmaps,bmaps.paths,faces,treasures.bld,animations.\n" 11 "archetypes,bmaps,bmaps.paths,faces,smooth,treasures.bld,animations.\n"
12 ) 12 )
13 } 13 }
14} 14}
15 15
16# archonly is used to only build the archetypes. I find this 16# archonly is used to only build the archetypes. I find this
30$faces = "faces"; 30$faces = "faces";
31$treasures = "treasures.bld"; 31$treasures = "treasures.bld";
32$animations = "animations"; 32$animations = "animations";
33$paths = $bmaps."."."paths"; 33$paths = $bmaps."."."paths";
34$faceExt = "\\.[a-zA-Z0-9][A-Z0-9][A-Z0-9]"; 34$faceExt = "\\.[a-zA-Z0-9][A-Z0-9][A-Z0-9]";
35$smooths = "smooth"; 35$smooth = "smooth";
36 36
37### main 37### main
38&info("looking ..."); 38&info("looking ...");
39&traverse($root); 39&traverse($root);
40 40
84 &info("$faces"); 84 &info("$faces");
85 open(FACES,">".$faces) || &die("cannot open ".$faces); 85 open(FACES,">".$faces) || &die("cannot open ".$faces);
86 &facesOut; 86 &facesOut;
87 close(FACES); 87 close(FACES);
88 88
89 &info("$smooths"); 89 &info("$smooth");
90 open(SMOOTHS,">".$smooths) || &die("cannot open ".$smooths); 90 open(SMOOTHS,">".$smooth) || &die("cannot open ".$smooth);
91 &smoothOut; 91 &smoothOut;
92 close(SMOOTHS); 92 close(SMOOTHS);
93 93
94 &info("$treasures"); 94 &info("$treasures");
95 # We still support the old consolidated treasure information 95 # We still support the old consolidated treasure information
170 170
171sub storeFaceInfo { 171sub storeFaceInfo {
172 local($lface,@values) = @_; 172 local($lface,@values) = @_;
173 173
174 if ($values[0] ne "") { 174 if ($values[0] ne "") {
175# blank.111 is a special case - 175# blank.x11 is a special case -
176# since no foreground pixels will actually be drawn, foreground colors is 176# since no foreground pixels will actually be drawn, foreground colors is
177# not relevant. Several monsters use blank.111 as part of their 177# not relevant. Several monsters use blank.x11 as part of their
178# animation to make them appear invisible, but have some other 178# animation to make them appear invisible, but have some other
179# foreground color set. 179# foreground color set.
180# Same applies to empty also. 180# Same applies to empty also.
181 if ($fg{$lface} && $fg{$lface} ne $values[0] && $lface ne "blank.111" 181 if ($fg{$lface} && $fg{$lface} ne $values[0] && $lface ne "blank.x11"
182 && $lface ne "empty.111") { 182 && $lface ne "empty.x11") {
183 &warn($arch." duplicate fg color ".$fg{$lface}."/".$values[0]." face ".$lface); 183 &warn($arch." duplicate fg color ".$fg{$lface}."/".$values[0]." face ".$lface);
184 } else { 184 } else {
185 $fg{$lface} = $values[0]; 185 $fg{$lface} = $values[0];
186 } 186 }
187 } 187 }
190 &warn($arch." duplicate bg color ".$bg{$lface}."/".$values[1]." face ".$lface); 190 &warn($arch." duplicate bg color ".$bg{$lface}."/".$values[1]." face ".$lface);
191 } else { 191 } else {
192 $bg{$lface} = $values[1]; 192 $bg{$lface} = $values[1];
193 } 193 }
194 } 194 }
195 if ($values[2] ne "" && $lface ne "blank.111" && $lface ne "empty.111") { 195 if ($values[2] ne "" && $lface ne "blank.x11" && $lface ne "empty.x11") {
196# blank.111 is a special case - see above explanation 196# blank.x11 is a special case - see above explanation
197# Its visibility is always 0. 197# Its visibility is always 0.
198 if ($visibility{$lface} && $visibility{$lface} ne $values[2]) { 198 if ($visibility{$lface} && $visibility{$lface} ne $values[2]) {
199 &warn($arch." duplicate visibilty ".$visibility{$lface}."/".$values[2]." face ".$lface); 199 &warn($arch." duplicate visibilty ".$visibility{$lface}."/".$values[2]." face ".$lface);
200 } else { 200 } else {
201 $visibility{$lface} = $values[2]; 201 $visibility{$lface} = $values[2];
202 } 202 }
203 } 203 }
204 if ($values[3] ne "" && lface ne "blank.111" && $lface ne "empty.111") { 204 if ($values[3] ne "" && lface ne "blank.x11" && $lface ne "empty.x11") {
205 if ($magicmap{$lface} && $magicmap{$lface} ne $values[3]) { 205 if ($magicmap{$lface} && $magicmap{$lface} ne $values[3]) {
206 &warn($arch." duplicate magicmap color ".$magicmap{$lface}."/".$values[3]." face ".$lface); 206 &warn($arch." duplicate magicmap color ".$magicmap{$lface}."/".$values[3]." face ".$lface);
207 } else { 207 } else {
208 $magicmap{$lface} = $values[3]; 208 $magicmap{$lface} = $values[3];
209 } 209 }
231 $pathto = ""; 231 $pathto = "";
232 } 232 }
233 open(ARC,$arch) || &die("cannot open ".$arch); 233 open(ARC,$arch) || &die("cannot open ".$arch);
234line: while(<ARC>) { 234line: while(<ARC>) {
235 chop; 235 chop;
236 ($var,@values) = split; 236 if (/^\s*(?:#.*|)$/) {
237 if ($var eq "#") { 237 # comment, skip line
238 #developper comment, switch to next line
239 $commentNum++; 238 $commentNum++;
240 next line; 239 next line;
241 } 240 }
241 ($var, @values) = split;
242 if ($var eq "Object") { 242 if ($var =~ /^[Oo]bject$/) {
243 $lface[0] = ""; 243 $lface[0] = "";
244 $#lface = 0; 244 $#lface = 0;
245 $lfg = ""; 245 $lfg = "";
246 $lbg = ""; 246 $lbg = "";
247 $lvis = ""; 247 $lvis = "";
248 $mm = ""; 248 $mm = "";
249 $floor = ""; 249 $floor = "";
250 $walkon = 0; 250 $walkon = 0;
251 $nopick = 0; 251 $nopick = 0;
252 $arch = join "_", @values; 252 $arch = join "_", @values;
253 }
254 if ($var eq "end") { 253 } elsif ($var eq "end") {
255 if ($#lface !=0) { 254 if ($#lface !=0) {
256 $#lface--; 255 $#lface--;
257 foreach $face (@lface) { 256 foreach $face (@lface) {
258 &storeFaceInfo($face, $lfg, $lbg, $lvis,$mm,$floor); 257 &storeFaceInfo($face, $lfg, $lbg, $lvis,$mm,$floor);
259 } 258 }
260 } 259 }
261 if ($walkon && !$nopick) { 260 if ($walkon && !$nopick) {
262 &warn("File $arch has an object with walk_on set which can be picked up\n"); 261 &warn("File $arch has an object with walk_on set which can be picked up\n");
263 } 262 }
264 } 263 print ARCH "editor_folder $pathto\n" if $pathto ne "";
265 # Process the color/face info now 264 # Process the color/face info now
266 if ($var eq "color_fg") { 265 } elsif ($var eq "color_fg") {
267 $lfg = $values[0]; 266 $lfg = $values[0];
268 next line; 267 next line;
269 }
270 if ($var eq "color_bg") { 268 } elsif ($var eq "color_bg") {
271 $lbg = $values[0]; 269 $lbg = $values[0];
272 next line; 270 next line;
273 }
274 if ($var eq "end") {
275 print ARCH "editor_folder $pathto\n" if $pathto ne "";
276 }
277 if ($var eq "visibility") { 271 } elsif ($var eq "visibility") {
278 $lvis = $values[0]; 272 $lvis = $values[0];
279 next line; 273 next line;
280 }
281 if ($var eq "magicmap") { 274 } elsif ($var eq "magicmap") {
282 $mm = $values[0]; 275 $mm = $values[0];
283 next line; 276 next line;
284 }
285 if ($var eq "attacktype") { 277 } elsif ($var eq "attacktype") {
286 $at = 0; 278 $at = 0;
287 foreach $t ( @values ) { 279 foreach $t ( @values ) {
288 if ( $t =~ /^\d+$/ ) { 280 if ( $t =~ /^\d+$/ ) {
289 $at |= $t; 281 $at |= $t;
290 } else { 282 } else {
294 &warn($arch . " has invalid attacktype " . $t); 286 &warn($arch . " has invalid attacktype " . $t);
295 } 287 }
296 } 288 }
297 } 289 }
298 $_ = $var . ' ' . $at; 290 $_ = $var . ' ' . $at;
299 }
300 if ($var eq "is_floor") { 291 } elsif ($var eq "is_floor") {
301 $floor = $values[0]; 292 $floor = $values[0];
302 # is_floor is also needed for archs, so let it pass 293 # is_floor is also needed for archs, so let it pass
303 # through 294 # through
304 }
305 elsif ($var eq "no_pick") { 295 } elsif ($var eq "no_pick") {
306 $nopick = $values[0]; 296 $nopick = $values[0];
307 } elsif ($var eq "walk_on") { 297 } elsif ($var eq "walk_on") {
308 $walkon = $values[0]; 298 $walkon = $values[0];
309 } 299 } elsif ($var eq "face" && ! $faces{$values[0]}) {
300 &warn($arch." is missing face ".$values[0])
310 elsif ($var eq "face") { 301 } elsif ($var eq "face") {
311 $lface[$#lface++] = $values[0] 302 $lface[$#lface++] = $values[0]
312 }
313 elsif ($var eq "anim") { 303 } elsif ($var eq "anim") {
314 if ($anim{$arch}) { 304 if ($anim{$arch}) {
315 &warn("$arch is a duplicate animation name"); 305 &warn("$arch is a duplicate animation name");
316 $anim{$arch}=""; 306 $anim{$arch}="";
317 } 307 }
318 while (<ARC>) { 308 while (<ARC>) {
328 } 318 }
329 $anim{$arch} .= "$var\n"; 319 $anim{$arch} .= "$var\n";
330 } 320 }
331 print ARCH "animation $arch\n"; 321 print ARCH "animation $arch\n";
332 next line; # don't want the mina 322 next line; # don't want the mina
333 }
334 if ($var eq "face" && ! $faces{$values[0]}) {
335 &warn($arch." is missing face ".$values[0])
336 }
337 if ($var eq "smoothface") { 323 } elsif ($var eq "smoothface") {
338 if ($smoothing{$values[0]} && ($smoothing{$values[0]} ne $values[1])) { 324 if ($smoothing{$values[0]} && ($smoothing{$values[0]} ne $values[1])) {
339 &warn($arch." duplicate smoothface for ".$values[0].": ".$smoothing{$values[0]}." and ".$values[1]); 325 &warn($arch." duplicate smoothface for ".$values[0].": ".$smoothing{$values[0]}." and ".$values[1]);
340 } elsif ( ($values[0] eq "") || ($values[1] eq "")) { 326 } elsif ( ($values[0] eq "") || ($values[1] eq "")) {
341 &warn ($arch." incomplete smoothface entry found: ".$values[0]." ".$values[1]); 327 &warn ($arch." incomplete smoothface entry found: ".$values[0]." ".$values[1]);
342 } else { 328 } else {
365} 351}
366 352
367sub bmapsOut { 353sub bmapsOut {
368 &pheader; 354 &pheader;
369 $idx = 0; 355 $idx = 0;
370 &pline("bug.111"); 356 &pline("bug.x11");
371 foreach $face (sort(keys %faces)) { 357 foreach $face (sort(keys %faces)) {
372 &pline($face) if $face !~ /bug\.111/; 358 &pline($face) if $face !~ /bug\.x11/;
373 } 359 }
374} 360}
375 361
376sub pathsOut { 362sub pathsOut {
377 &pheader; 363 &pheader;
378 $idx = 0; 364 $idx = 0;
379 &opline($root."/system/bug.111"); 365 &opline($root."/system/bug.x11");
380 foreach $face (sort(keys %faces)) { 366 foreach $face (sort(keys %faces)) {
381 &opline($faces{$face}) if $faces{$face} !~ /bug\.111/; 367 &opline($faces{$face}) if $faces{$face} !~ /bug\.x11/;
382 } 368 }
383} 369}
384 370
385sub treasuresOut { 371sub treasuresOut {
386 foreach $treasure (@treasure_files) { 372 foreach $treasure (@treasure_files) {
479} 465}
480sub smoothOut { 466sub smoothOut {
481 local ($sm); 467 local ($sm);
482 print SMOOTHS "##########################################################\n"; 468 print SMOOTHS "##########################################################\n";
483 print SMOOTHS "# Do not touch this file. #\n"; 469 print SMOOTHS "# Do not touch this file. #\n";
484 print SMOOTHS "# It has been generated from the informations present #\n"; 470 print SMOOTHS "# It has been generated from the information present #\n";
485 print SMOOTHS "# in the archetype files. #\n"; 471 print SMOOTHS "# in the archetype files. #\n";
486 print SMOOTHS "# To add new entries, simply add #\n"; 472 print SMOOTHS "# To add new entries, simply add #\n";
487 print SMOOTHS "# smoothface xxx yyy #\n"; 473 print SMOOTHS "# smoothface xxx yyy #\n";
488 print SMOOTHS "# to an archetype and collect.pl will put below an entry #\n"; 474 print SMOOTHS "# to an archetype and collect.pl will put below an entry #\n";
489 print SMOOTHS "# xxx yyy #\n"; 475 print SMOOTHS "# xxx yyy #\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines