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 by root, Fri Feb 3 07:13:04 2006 UTC vs.
Revision 1.6 by root, Thu Feb 8 03:09:32 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
65$attacktype{ 'lifestealing' } = ( 1 << 24 ); 65$attacktype{ 'lifestealing' } = ( 1 << 24 );
66$attacktype{ 'disease' } = ( 1 << 25 ); 66$attacktype{ 'disease' } = ( 1 << 25 );
67 67
68&info("writing ...$archetypes"); 68&info("writing ...$archetypes");
69open(ARCH,">".$archetypes) || &die("cannot open ".$archetypes); 69open(ARCH,">".$archetypes) || &die("cannot open ".$archetypes);
70&archsOut; 70&archsOut($root);
71close(ARCH); 71close(ARCH);
72 72
73 73
74if (!$archonly) { 74if (!$archonly) {
75 &info("$bmaps"); 75 &info("$bmaps");
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 }
217 } 217 }
218} 218}
219 219
220 220
221sub archsOut { 221sub archsOut {
222 local($dir) = shift;
223
222 foreach $arch (@archs) { 224 foreach $arch (@archs) {
225 # Assume the filename $arch begins with $dir. Assign all path name
226 # components after $dir to $pathto.
227 if($arch =~ /^\Q$dir\E\/(.*)\/[^\/]*[.]arc$/) {
228 $pathto = $1;
229 } else {
230 &warn("cannot determine editor_folder from arch '$arch'");
231 $pathto = "";
232 }
223 open(ARC,$arch) || &die("cannot open ".$arch); 233 open(ARC,$arch) || &die("cannot open ".$arch);
224 $pathto = $arch;
225 $pathto =~ s@[^/]*/@@;
226 $pathto =~ s@[a-z]*/(.*)/.*arc@$1@;
227line: while(<ARC>) { 234line: while(<ARC>) {
228 chop; 235 chop;
229 ($var,@values) = split; 236 if (/^\s*(?:#.*|)$/) {
230 if ($var eq "#") { 237 # comment, skip line
231 #developper comment, switch to next line
232 $commentNum++; 238 $commentNum++;
233 next line; 239 next line;
234 } 240 }
241 ($var, @values) = split;
235 if ($var eq "Object") { 242 if ($var =~ /^[Oo]bject$/) {
236 $lface[0] = ""; 243 $lface[0] = "";
237 $#lface = 0; 244 $#lface = 0;
238 $lfg = ""; 245 $lfg = "";
239 $lbg = ""; 246 $lbg = "";
240 $lvis = ""; 247 $lvis = "";
241 $mm = ""; 248 $mm = "";
242 $floor = ""; 249 $floor = "";
243 $walkon = 0; 250 $walkon = 0;
244 $nopick = 0; 251 $nopick = 0;
245 $arch = join "_", @values; 252 $arch = join "_", @values;
246 }
247 if ($var eq "end") { 253 } elsif ($var eq "end") {
248 if ($#lface !=0) { 254 if ($#lface !=0) {
249 $#lface--; 255 $#lface--;
250 foreach $face (@lface) { 256 foreach $face (@lface) {
251 &storeFaceInfo($face, $lfg, $lbg, $lvis,$mm,$floor); 257 &storeFaceInfo($face, $lfg, $lbg, $lvis,$mm,$floor);
252 } 258 }
253 } 259 }
254 if ($walkon && !$nopick) { 260 if ($walkon && !$nopick) {
255 &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");
256 } 262 }
257 }
258 # Process the color/face info now 263 # Process the color/face info now
259 if ($var eq "color_fg") { 264 } elsif ($var eq "color_fg") {
260 $lfg = $values[0]; 265 $lfg = $values[0];
261 next line; 266 next line;
262 }
263 if ($var eq "color_bg") { 267 } elsif ($var eq "color_bg") {
264 $lbg = $values[0]; 268 $lbg = $values[0];
265 next line; 269 next line;
266 }
267 if ($var eq "end") { 270 } elsif ($var eq "end") {
268 print ARCH "editor_folder $pathto\n"; 271 print ARCH "editor_folder $pathto\n" if $pathto ne "";
269 }
270 if ($var eq "visibility") { 272 } elsif ($var eq "visibility") {
271 $lvis = $values[0]; 273 $lvis = $values[0];
272 next line; 274 next line;
273 }
274 if ($var eq "magicmap") { 275 } elsif ($var eq "magicmap") {
275 $mm = $values[0]; 276 $mm = $values[0];
276 next line; 277 next line;
277 }
278 if ($var eq "attacktype") { 278 } elsif ($var eq "attacktype") {
279 $at = 0; 279 $at = 0;
280 foreach $t ( @values ) { 280 foreach $t ( @values ) {
281 if ( $t =~ /^\d+$/ ) { 281 if ( $t =~ /^\d+$/ ) {
282 $at |= $t; 282 $at |= $t;
283 } else { 283 } else {
287 &warn($arch . " has invalid attacktype " . $t); 287 &warn($arch . " has invalid attacktype " . $t);
288 } 288 }
289 } 289 }
290 } 290 }
291 $_ = $var . ' ' . $at; 291 $_ = $var . ' ' . $at;
292 }
293 if ($var eq "is_floor") { 292 } elsif ($var eq "is_floor") {
294 $floor = $values[0]; 293 $floor = $values[0];
295 # is_floor is also needed for archs, so let it pass 294 # is_floor is also needed for archs, so let it pass
296 # through 295 # through
297 }
298 elsif ($var eq "no_pick") { 296 } elsif ($var eq "no_pick") {
299 $nopick = $values[0]; 297 $nopick = $values[0];
300 } elsif ($var eq "walk_on") { 298 } elsif ($var eq "walk_on") {
301 $walkon = $values[0]; 299 $walkon = $values[0];
302 }
303 elsif ($var eq "face") { 300 } elsif ($var eq "face") {
304 $lface[$#lface++] = $values[0] 301 $lface[$#lface++] = $values[0]
305 }
306 elsif ($var eq "anim") { 302 } elsif ($var eq "anim") {
307 if ($anim{$arch}) { 303 if ($anim{$arch}) {
308 &warn("$arch is a duplicate animation name"); 304 &warn("$arch is a duplicate animation name");
309 $anim{$arch}=""; 305 $anim{$arch}="";
310 } 306 }
311 while (<ARC>) { 307 while (<ARC>) {
321 } 317 }
322 $anim{$arch} .= "$var\n"; 318 $anim{$arch} .= "$var\n";
323 } 319 }
324 print ARCH "animation $arch\n"; 320 print ARCH "animation $arch\n";
325 next line; # don't want the mina 321 next line; # don't want the mina
326 }
327 if ($var eq "face" && ! $faces{$values[0]}) { 322 } elsif ($var eq "face" && ! $faces{$values[0]}) {
328 &warn($arch." is missing face ".$values[0]) 323 &warn($arch." is missing face ".$values[0])
329 }
330 if ($var eq "smoothface") { 324 } elsif ($var eq "smoothface") {
331 if ($smoothing{$values[0]} && ($smoothing{$values[0]} ne $values[1])) { 325 if ($smoothing{$values[0]} && ($smoothing{$values[0]} ne $values[1])) {
332 &warn($arch." duplicate smoothface for ".$values[0].": ".$smoothing{$values[0]}." and ".$values[1]); 326 &warn($arch." duplicate smoothface for ".$values[0].": ".$smoothing{$values[0]}." and ".$values[1]);
333 } elsif ( ($values[0] eq "") || ($values[1] eq "")) { 327 } elsif ( ($values[0] eq "") || ($values[1] eq "")) {
334 &warn ($arch." incomplete smoothface entry found: ".$values[0]." ".$values[1]); 328 &warn ($arch." incomplete smoothface entry found: ".$values[0]." ".$values[1]);
335 } else { 329 } else {
358} 352}
359 353
360sub bmapsOut { 354sub bmapsOut {
361 &pheader; 355 &pheader;
362 $idx = 0; 356 $idx = 0;
363 &pline("bug.111"); 357 &pline("bug.x11");
364 foreach $face (sort(keys %faces)) { 358 foreach $face (sort(keys %faces)) {
365 &pline($face) if $face !~ /bug\.111/; 359 &pline($face) if $face !~ /bug\.x11/;
366 } 360 }
367} 361}
368 362
369sub pathsOut { 363sub pathsOut {
370 &pheader; 364 &pheader;
371 $idx = 0; 365 $idx = 0;
372 &opline($root."/system/bug.111"); 366 &opline($root."/system/bug.x11");
373 foreach $face (sort(keys %faces)) { 367 foreach $face (sort(keys %faces)) {
374 &opline($faces{$face}) if $faces{$face} !~ /bug\.111/; 368 &opline($faces{$face}) if $faces{$face} !~ /bug\.x11/;
375 } 369 }
376} 370}
377 371
378sub treasuresOut { 372sub treasuresOut {
379 foreach $treasure (@treasure_files) { 373 foreach $treasure (@treasure_files) {
472} 466}
473sub smoothOut { 467sub smoothOut {
474 local ($sm); 468 local ($sm);
475 print SMOOTHS "##########################################################\n"; 469 print SMOOTHS "##########################################################\n";
476 print SMOOTHS "# Do not touch this file. #\n"; 470 print SMOOTHS "# Do not touch this file. #\n";
477 print SMOOTHS "# It has been generated from the informations present #\n"; 471 print SMOOTHS "# It has been generated from the information present #\n";
478 print SMOOTHS "# in the archetype files. #\n"; 472 print SMOOTHS "# in the archetype files. #\n";
479 print SMOOTHS "# To add new entries, simply add #\n"; 473 print SMOOTHS "# To add new entries, simply add #\n";
480 print SMOOTHS "# smoothface xxx yyy #\n"; 474 print SMOOTHS "# smoothface xxx yyy #\n";
481 print SMOOTHS "# to an archetype and collect.pl will put below an entry #\n"; 475 print SMOOTHS "# to an archetype and collect.pl will put below an entry #\n";
482 print SMOOTHS "# xxx yyy #\n"; 476 print SMOOTHS "# xxx yyy #\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines