version 1.1 | | version 1.2 |
---|
| | |
#! /usr/local/bin/perl | | #! /usr/bin/perl |
| | |
| | # this script takes a map (in new format, eg those that support |
| | # tiling and only save the head for multipart objects) and |
| | # expands it by some factor. Note that editing of the destination |
| | # file will certainly be necessary, but this may be useful instead |
| | # of having to re-do a scaled map by hand. |
| | |
$default_X_size = 16; | | $default_X_size = 16; |
$default_Y_size = 16; | | $default_Y_size = 16; |
| | |
# argv loop | | # argv loop |
foreach $i (0 .. $#ARGV) { | | foreach $i (0 .. $#ARGV) { |
if($ARGV[$i] =~ "-h") { $help = 1; } | | if($ARGV[$i] =~ "-h") { $help = 1; } |
if($ARGV[$i] =~ "-e") { $factor = $ARGV[++$i]; } | | if($ARGV[$i] =~ "-e") { $expand = $ARGV[++$i]; } |
} | | } |
| | |
# various help/runtime messages | | # various help/runtime messages |
| | |
} | | } |
| | |
#Read in input map | | #Read in input map |
open(FILE, $input_map) && (@mapdata=<FILE>) && close(FILE) | | open(FILE, $input_map) || die "FATAL: file $input_map not found!\n"; |
|| print "FATAL: file $input_map not found!\n"; | | # process the map object special. This is easier than trying |
| | # to handle the special values it has |
| | |
| | while (<FILE>) { |
| | |
| | if (/^width (\d+)$/) { |
| | printf "width %d\n", $1 * $expand; |
| | } elsif (/^height (\d+)$/) { |
| | printf "height %d\n", $1 * $expand; |
| | } elsif (/^enter_x (\d+)$/) { |
| | printf "enter_x %d\n", $1 * $expand; |
| | } elsif (/^enter_y (\d+)$/) { |
| | printf "enter_y %d\n", $1 * $expand; |
| | } |
| | else { print $_; } |
| | last if (/^end$/); |
| | } |
| | @mapdata=<FILE>; |
| | close(FILE); |
| | |
| | |
# convert map data into objects | | # convert map data into objects |
while ($i<=$#mapdata) { | | while ($i<=$#mapdata) { |
| | |
$i++; | | $i++; |
} | | } |
| | |
# Object 0 is the map header info, dont | | |
# expand it, so just print it out | | |
&expand_obj("0 1 0"); | | |
$bufline = $olines_in_obj[0]; | | |
| | |
#Expand the map objects 1 to $objnum | | #Expand the map objects 1 to $objnum |
while ($j++<$objnum) { | | for ($j=0; $j<$objnum; $j++) { |
&expand_obj("$j $expand $bufline"); | | &expand_obj("$j $expand $bufline"); |
$bufline += $olines_in_obj[$j]; | | $bufline += $olines_in_obj[$j]; |
} | | } |
| | |
if($name[$obj]) { printf("arch %s\n",$name[$obj]); } | | if($name[$obj]) { printf("arch %s\n",$name[$obj]); } |
else { return; } | | else { return; } |
| | |
if($obj==0) { | | printf("x %d\n",$start_x); |
if($x[0]) { printf("x %d\n",$x[0]*$expand); } | | printf("y %d\n",$start_y); |
else { printf("x %d\n",$default_X_size*$expand); } | | |
} elsif ($x[$obj]) { printf("x %d\n",$start_x); } | | |
| | |
if($obj==0) { | | |
if($y[0]) { printf("y %d\n",$y[0]*$expand); } | | |
else { printf("y %d\n",$default_Y_size*$expand); } | | |
} elsif ($y[$obj]) { printf("y %d\n",$start_y); } | | |
| | |
while ($start_buf<$end_buf) { | | while ($start_buf<$end_buf) { |
print "$otherline[$start_buf]"; | | print "$otherline[$start_buf]"; |