Difference for lib/adm/collect_images.pl from version 1.2 to 1.3


version 1.2 version 1.3
Line 1
 
Line 1
 #!/usr/bin/perl  #!/usr/bin/perl
   #
   # this script goes through and collects the various image sets into crossfire-x.png
   # files, where x is the numbers from the image_info file.  This
   # collects all the images at once, whether or not they have
   # been changed or not.
   
   # Currently, there are no command line options for this script.
   
 if ($ARGV[0] eq "-xpm") {$mode ="xpm";}  use FileHandle;
 elsif ($ARGV[0] eq "-xbm") {$mode ="xbm";}  
 elsif ($ARGV[0] eq "-png") {$mode ="png";}  
 else {die("No option/invalid option specified\n");}  
   
 die("No arch directory - will not rebuild $mode image file") if (! -e "arch");  die("No arch directory - will not rebuild $mode image file") if (! -e "arch");
   
   open(IMAGEINFO,"image_info") || die("Can't open image_info file: $!\n");
   while (<IMAGEINFO>) {
       # Ignore lines that start with comments or just empty lines
       next if /^#/;
       next if /^\s*$/;
       ($setnum, $ext, @rest) = split /:/;
       # We don't actually need that data in this script, but may as well do sanity
       # checking.
       if ($#rest != 4) {
    print STDERR "image_info: line is corrupt:\n$_";
       }
       if ($extension[$setnum]) {
    print STDERR "Warning: set $setnum is duplicated in image_info file\n";
       }
       $extension[$setnum] = $ext;
   }
   close(IMAGEINFO);
   
   
   for ($count=0; $count<=$#extension; $count++) {
       $ESRV[$count] = new FileHandle;
       $fh = $ESRV[$count];
       open($fh, ">crossfire.$count") ||
    die("Can't open crossfire.$count for write: $!\n");
   }
   
 open(BMAPS,"bmaps.paths") || die("Can't open bmaps.paths: $!\n");  open(BMAPS,"bmaps.paths") || die("Can't open bmaps.paths: $!\n");
 open(ESRV,">crossfire.$mode") || die("Can't open crossfire.$mode for write: $!\n");  
 $_ = <BMAPS>;  $_ = <BMAPS>;
 while(<BMAPS>) {  while(<BMAPS>) {
     chop;      chop;
     die("Unknown line: '$_'\n") unless /^\\(\d{5})\s+(\S+)$/o;  
       # we need to insert the extension for the images between the name
       # and the number (.171 or whatever) extension, so split on that.
   
       die("Unknown line: '$_'\n") unless /^\\(\d{5})\s+(\S+)\.(\w\w\w)$/o;
     $num = $1;      $num = $1;
     $file = $2;      $file = $2;
       $file1 = $3;
   
     print "$num $file\n" if ($num % 50) == 0 ;      print "$num $file\n" if ($num % 50) == 0 ;
     if ($mode eq "xbm") {      # This probably isn't the most efficient way to do this if a
  # the bitmaps files are little special - we take the data and      # large number of images are added, as we try to open each
  # convert it to binary - saves space, is faster in the end      # instance.
  #       # OTOH, we are doing one directory
  print ESRV "IMAGE $num 72 $file\n";      # at a time, so we should be hitting the DNLC at a very high
  open(FILE,"<$file") || die("Unable to open $file for read: $!\n");      # rate.
  $len=0;  
  while (<FILE>) {      for ($count=0; $count<=$#extension; $count++) {
      if (/^\s*0x[0-9a-f][0-9a-f]/i) {   $filename = "$file.$extension[$count].$file1.png";
  @vals = split(/[,}]/);   $fh = $ESRV[$count];
  for ($i=0; $i<$#vals; $i++) {  
      $dest[$i]=oct($vals[$i]);   $length = -s "$filename";
  }   if (open(FILE,"$filename")) {
  $numel = $#vals;       print $fh "IMAGE $num $length $file.$file1\n";
  $dest = pack "C$numel", @dest;       print "Error reading file $filename" if (!read(FILE, $buf, $length));
  $len += $numel;       print $fh $buf;
  print ESRV $dest;  
      }  
  }  
  close(FILE);   close(FILE);
  if ($len != 72) {  
      die("Image $file datelen: $len != 72\n")   
  }  
     }      }
     else {   elsif ($count==0) {
  $length = -s "$file.$mode";       # set 0 should have all the sets
  open(FILE,"$file\.$mode") || print("Unable to open $file\.$mode for read: $!\n");       print "Error: Image $filename not found for set 0!\n";
         @name2 = split("/",$file);  
         $name3 = $name2[$#name2];  
         $name4 = "$name3\.$mode";  
 #        print "name4:", $name4, "\n";  
         if(open(FILE2,"./alternate_images/$name4") ) {  
              print "Alternate image found: ",$name4,"\n";  
              $length = -s "./alternate_images/$name4";  
              print ESRV "IMAGE $num $length $file\n";  
              while(<FILE2>) {  
                print ESRV $_;  
       }  
              close(FILE2);  
         } else {  
     print ESRV "IMAGE $num $length $file\n";  
     while(<FILE>) {  
         print ESRV $_;  
     }      }
     close(FILE);  
         }          }
     }      }
   for ($count=0; $count<=$#extension; $count++) {
       close($ESRV[$count]);
 }  }
 close(ESRV);  
 close(BMAPS);  close(BMAPS);


Legend:
line(s) removed in v.1.2 
line(s) changed
 line(s) added in v.1.3

File made using version 1.98 of cvs2html by leaf at 2011-07-21 19:05