Import of Empire 4.2.12
This commit is contained in:
commit
d8b7fdfae1
817 changed files with 126589 additions and 0 deletions
24
scripts/mapper/Makefile
Normal file
24
scripts/mapper/Makefile
Normal file
|
@ -0,0 +1,24 @@
|
|||
#
|
||||
# Riverworld Blitz mpeg makefile. Assumes the netpbm programs are
|
||||
# somewhere in the path. map.m2v is an mpeg2 file-- unfortunately
|
||||
# it's 15x the size of the mpeg1 (.mpg) file. If you modify map.par
|
||||
# to generate a smaller file, or find another mpeg2 encoder, let
|
||||
# me know.
|
||||
# -Drake (dld@chem.psu.edu)
|
||||
|
||||
|
||||
.SUFFIXES: .pgm .gif .ppm .pov .jpg
|
||||
|
||||
all: map.mpg final.gif
|
||||
|
||||
map.param: param.pl default.param frames
|
||||
param.pl default.param >map.param
|
||||
color.ppm: randppm.awk
|
||||
randppm.awk >$@
|
||||
map.mpg: map.param
|
||||
mpeg_encode map.param
|
||||
final.gif: frames color.ppm
|
||||
makeframe map-`cat frames`.gif | ppmtogif -interlace >final.gif
|
||||
|
||||
clean:
|
||||
rm -f map-*.gif overmap-*.gif frames census report version over.pbm power wire final.gif over.mask color.ppm map.mpg
|
66
scripts/mapper/README
Normal file
66
scripts/mapper/README
Normal file
|
@ -0,0 +1,66 @@
|
|||
To install mapper, edit makempeg and mapper and
|
||||
(1) fix paths
|
||||
(2) change names of countries to exclude
|
||||
(3) add a crontab similar to the one in the file crontab.config
|
||||
|
||||
When starting, type:
|
||||
make clean
|
||||
make color.ppm
|
||||
|
||||
-children
|
||||
|
||||
This directory contains a number of scripts which output PPM format
|
||||
files suitable for conversion to gif with the PBM utilities or MPEG
|
||||
with mpeg_encode. mpeg_encode is available from
|
||||
http://s2k-ftp.cs.berkeley.edu:8000/multimedia/mpeg/
|
||||
PBMPLUS is available from
|
||||
ftp://ftp.ee.lbl.gov/
|
||||
Some of the scripts (mapper in particular) depend on a country
|
||||
"mapper" being defined that can be logged into automatically using the
|
||||
Empire client eif. Modify to use the client and country name of your
|
||||
choice.
|
||||
|
||||
-harmless
|
||||
|
||||
|
||||
|
||||
pgmmap.awk
|
||||
A simple map making program. Reads a deity dump file and produces
|
||||
a grayscale .pgm file as output, with each color corresponding to a
|
||||
country number. To make a color coded map, scramble the colors.
|
||||
|
||||
pgmfallout.awk
|
||||
Convert a deity census file into a PGM file with fallout levels.
|
||||
|
||||
randppm.awk
|
||||
Generates random colors in a ppm file. Useful for remmapping colors
|
||||
from pgmmap.awk
|
||||
|
||||
over.awk
|
||||
Reads in a report file and generates a text overlay of country names.
|
||||
Requires pbmtext (part of netpbm) to work.
|
||||
|
||||
param.pl
|
||||
Modify an mpeg parameter file to use map-*.gif files as input.
|
||||
Reads the highest level file from the file 'frames' and skips over any
|
||||
file not 300-500 bytes long (in a 64x32 blitz, the .gif files should
|
||||
be ~400 bytes). Larger worlds may require different size limits.
|
||||
Disabling the size limits is not advised, as this is the only way
|
||||
corrupt frames are eliminated.
|
||||
|
||||
makempeg
|
||||
Log into the mapper country, capture new report files, and generate
|
||||
a new .mpg file. Also copies map.mpg and final.gif into the web space
|
||||
directories so others can view them. The web copy may be commented
|
||||
out or modified to meet your local needs.
|
||||
|
||||
mapper
|
||||
Log into mapper country and capture a map of the current owners of
|
||||
the world (.gif format). Games without fallout should comment out the
|
||||
fallmap producing line.
|
||||
|
||||
archive.pl
|
||||
Pushes the archived blitz records down the stack (in web space) and
|
||||
prints out a new .html index.
|
||||
|
||||
-Drake (dld@chem.psu.edu)
|
51
scripts/mapper/archive.pl
Normal file
51
scripts/mapper/archive.pl
Normal file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/local/bin/perl
|
||||
|
||||
|
||||
# Run by cron at 7:50 to archive (in web space) the current blitz mpeg
|
||||
# and to generate a new html index file. Outputs html.
|
||||
# -Drake (dld@chem.psu.edu)
|
||||
|
||||
require 'ctime.pl';
|
||||
|
||||
chdir '/home/children/html/howitzer';
|
||||
|
||||
@file = ("Blitz-0", "Blitz-1","Blitz-2","Blitz-3","Blitz-4", "Blitz-5","Blitz-6", "Blitz-7");
|
||||
unlink("$file[$#file].mpg","$file[$#file].gif","$file[$#file].txt","$file[$#file]Ann.txt");
|
||||
|
||||
|
||||
for ($i=$#file;$i>0;$i--) {
|
||||
rename($file[$i-1] . '.mpg',"$file[$i].mpg");
|
||||
rename($file[$i-1] . '.gif',"$file[$i].gif");
|
||||
rename($file[$i-1] . '.txt',"$file[$i].txt");
|
||||
rename($file[$i-1] . 'Ann.txt',"$file[$i]Ann.txt");
|
||||
}
|
||||
|
||||
if (-s 'Blitz.mpg') { system('cp -p Blitz.mpg Blitz-0.mpg'); }
|
||||
if (-s 'Blitz.gif') { system('cp -p Blitz.gif Blitz-0.gif'); }
|
||||
if (-s 'Blitz.txt') { system('cp -p Blitz.txt Blitz-0.txt'); }
|
||||
if (-s 'Blitz.txt') { system('cp -p BlitzAnn.txt Blitz-0Ann.txt'); }
|
||||
|
||||
print "<html> <head>\n";
|
||||
print "<title>Howitzer Blitz Archive</title>\n";
|
||||
print "</head>\n<body>\n";
|
||||
print "<h1>Archived Blitzes</h1>\n";
|
||||
print "<ul>\n";
|
||||
|
||||
foreach $base (@file) {
|
||||
$file = $base . '.mpg';
|
||||
|
||||
if (-s $file) {
|
||||
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
|
||||
$atime,$mtime,$ctime,$blksize,$blocks)
|
||||
= stat($file);
|
||||
chop($m=&ctime($mtime));
|
||||
print "<li> $m <ul>\n";
|
||||
print "<li> <a href=\"$file\"> <img alt=\"MPEG\" src=\"$base.gif\"><br>($size bytes)</a>\n";
|
||||
print "<li> <a href=\"$base.gif\">Final Map</a>\n";
|
||||
print "<li> <a href=\"$base.txt\">Reports</a>\n\n";
|
||||
print "<li> <a href=\"$base" . "Ann.txt\">Announcements</a>\n</ul>\n";
|
||||
}
|
||||
}
|
||||
|
||||
print "</ul>\n";
|
||||
print "</body> </html>\n";
|
6
scripts/mapper/cleanup
Normal file
6
scripts/mapper/cleanup
Normal file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
# add any paths necessary for eif, netpbm, and mpeg_encode.
|
||||
|
||||
cd /home/children/howitzer/map
|
||||
make clean
|
4
scripts/mapper/crontab.config
Normal file
4
scripts/mapper/crontab.config
Normal file
|
@ -0,0 +1,4 @@
|
|||
4,14,24,34,44,54 * * * * /home/children/howitzer/map/mapper 1>>/dev/null 2>&1
|
||||
51 18 * * * /home/children/howitzer/map/makempeg 1>>/dev/null 2>&1
|
||||
58 18 * * * /home/children/howitzer/map/archive.pl > /home/children/html/howitzer/index.html
|
||||
27 19 * * * /home/children/howitzer/map/cleanup 1>>/home/children/logs/cleanup 2>&1
|
41
scripts/mapper/default.param
Normal file
41
scripts/mapper/default.param
Normal file
|
@ -0,0 +1,41 @@
|
|||
# default parameter file for encoding empire games. P frames are
|
||||
# very cheap since most pixels remain exactly the same color.
|
||||
# I frames (complete pictures) are expensive, so they are infrequent.
|
||||
# Inidividual maps are stored as gifs (a very compact storage format for
|
||||
# this sort of data) and enlarged and converted on the fly to ppm format
|
||||
# using various netpbm tools.
|
||||
# This file is modified by param.pl to generate the real .param file
|
||||
# with the correct input filenames.
|
||||
# -Drake (dld@chem.psu.edu)
|
||||
|
||||
PATTERN IPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
|
||||
OUTPUT map.mpg
|
||||
|
||||
BASE_FILE_FORMAT PPM
|
||||
GOP_SIZE 60
|
||||
SLICES_PER_FRAME 1
|
||||
|
||||
PIXEL HALF
|
||||
RANGE 8
|
||||
PSEARCH_ALG LOGARITHMIC
|
||||
BSEARCH_ALG SIMPLE
|
||||
IQSCALE 8
|
||||
PQSCALE 10
|
||||
BQSCALE 25
|
||||
|
||||
REFERENCE_FRAME DECODED
|
||||
|
||||
#
|
||||
# This takes two files, fallmap*.gif and map*.gif. Both are converted to ppm
|
||||
# and enlarged by a factor of 4. fallmap*.gif is also smoothed. The two are
|
||||
# then added together (causing sectors with high fallout to be brighter).
|
||||
# Finally, the country names in over.mask and over.pbm are overlaid.
|
||||
#
|
||||
|
||||
INPUT_CONVERT makeframe `basename *`
|
||||
|
||||
INPUT_DIR .
|
||||
|
||||
# This files actual are substituted here by param.pl
|
||||
INPUT
|
||||
END_INPUT
|
7
scripts/mapper/makeframe
Normal file
7
scripts/mapper/makeframe
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
# giftopnm fall$* | pnmgamma 2 | pnmscale 2 | pnmsmooth | pnmscale 2 | pnmsmooth | pnmdepth 255 >fall.ppm
|
||||
giftopnm over$* >over.pbm
|
||||
pbmmask -expand over.pbm >over.mask
|
||||
giftopnm $* | pgmtoppm -map color.ppm | pnmscale 4 | pnmcomp -invert -alpha over.mask over.pbm
|
||||
|
27
scripts/mapper/makempeg
Normal file
27
scripts/mapper/makempeg
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
|
||||
# add any paths necessary for eif, netpbm, and mpeg_encode.
|
||||
PATH=/home/children/bin/netpbm:${PATH}:/usr/local/bin:${HOME}/bin:.
|
||||
export PATH
|
||||
|
||||
cd /home/children/howitzer/map
|
||||
touch version power wire census
|
||||
eif mapper <<EOF
|
||||
version >!version
|
||||
census * >!census
|
||||
report * | egrep -v '(Frey|pea|Lurker|Mapmaker|Visitor|visitor)' >report
|
||||
power new >!power
|
||||
wire Mapmaker y >!wire
|
||||
exit
|
||||
EOF
|
||||
|
||||
cat power report >>/home/children/html/howitzer/Blitz.txt
|
||||
cat wire >>/home/children/html/howitzer/BlitzAnn.txt
|
||||
echo >>/home/children/html/howitzer/Blitz.txt
|
||||
echo >>/home/children/html/howitzer/Blitz.txt
|
||||
|
||||
make final.gif map.mpg
|
||||
|
||||
cp map.mpg /home/children/html/howitzer/Blitz.mpg
|
||||
cp final.gif /home/children/html/howitzer/Blitz.gif
|
||||
|
180
scripts/mapper/map.param
Normal file
180
scripts/mapper/map.param
Normal file
|
@ -0,0 +1,180 @@
|
|||
# default parameter file for encoding empire games. P frames are
|
||||
# very cheap since most pixels remain exactly the same color.
|
||||
# I frames (complete pictures) are expensive, so they are infrequent.
|
||||
# Inidividual maps are stored as gifs (a very compact storage format for
|
||||
# this sort of data) and enlarged and converted on the fly to ppm format
|
||||
# using various netpbm tools.
|
||||
# This file is modified by param.pl to generate the real .param file
|
||||
# with the correct input filenames.
|
||||
# -Drake (dld@chem.psu.edu)
|
||||
|
||||
PATTERN IPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
|
||||
OUTPUT map.mpg
|
||||
|
||||
BASE_FILE_FORMAT PPM
|
||||
GOP_SIZE 60
|
||||
SLICES_PER_FRAME 1
|
||||
|
||||
PIXEL HALF
|
||||
RANGE 8
|
||||
PSEARCH_ALG LOGARITHMIC
|
||||
BSEARCH_ALG SIMPLE
|
||||
IQSCALE 8
|
||||
PQSCALE 10
|
||||
BQSCALE 25
|
||||
|
||||
REFERENCE_FRAME DECODED
|
||||
|
||||
#
|
||||
# This takes two files, fallmap*.gif and map*.gif. Both are converted to ppm
|
||||
# and enlarged by a factor of 4. fallmap*.gif is also smoothed. The two are
|
||||
# then added together (causing sectors with high fallout to be brighter).
|
||||
# Finally, the country names in over.mask and over.pbm are overlaid.
|
||||
#
|
||||
|
||||
INPUT_CONVERT makeframe `basename *`
|
||||
|
||||
INPUT_DIR .
|
||||
|
||||
# This files actual are substituted here by param.pl
|
||||
INPUT
|
||||
map-0.gif
|
||||
map-1.gif
|
||||
map-2.gif
|
||||
map-3.gif
|
||||
map-4.gif
|
||||
map-5.gif
|
||||
map-6.gif
|
||||
map-7.gif
|
||||
map-8.gif
|
||||
map-9.gif
|
||||
map-10.gif
|
||||
map-11.gif
|
||||
map-12.gif
|
||||
map-13.gif
|
||||
map-14.gif
|
||||
map-15.gif
|
||||
map-16.gif
|
||||
map-17.gif
|
||||
map-18.gif
|
||||
map-19.gif
|
||||
map-20.gif
|
||||
map-21.gif
|
||||
map-22.gif
|
||||
map-23.gif
|
||||
map-24.gif
|
||||
map-25.gif
|
||||
map-26.gif
|
||||
map-27.gif
|
||||
map-28.gif
|
||||
map-29.gif
|
||||
map-30.gif
|
||||
map-31.gif
|
||||
map-32.gif
|
||||
map-33.gif
|
||||
map-34.gif
|
||||
map-35.gif
|
||||
map-36.gif
|
||||
map-37.gif
|
||||
map-38.gif
|
||||
map-39.gif
|
||||
map-40.gif
|
||||
map-41.gif
|
||||
map-42.gif
|
||||
map-43.gif
|
||||
map-44.gif
|
||||
map-45.gif
|
||||
map-46.gif
|
||||
map-47.gif
|
||||
map-48.gif
|
||||
map-49.gif
|
||||
map-50.gif
|
||||
map-51.gif
|
||||
map-52.gif
|
||||
map-53.gif
|
||||
map-54.gif
|
||||
map-55.gif
|
||||
map-56.gif
|
||||
map-57.gif
|
||||
map-58.gif
|
||||
map-59.gif
|
||||
map-60.gif
|
||||
map-61.gif
|
||||
map-62.gif
|
||||
map-63.gif
|
||||
map-64.gif
|
||||
map-65.gif
|
||||
map-66.gif
|
||||
map-67.gif
|
||||
map-68.gif
|
||||
map-69.gif
|
||||
map-70.gif
|
||||
map-71.gif
|
||||
map-72.gif
|
||||
map-73.gif
|
||||
map-74.gif
|
||||
map-75.gif
|
||||
map-76.gif
|
||||
map-77.gif
|
||||
map-78.gif
|
||||
map-79.gif
|
||||
map-80.gif
|
||||
map-81.gif
|
||||
map-82.gif
|
||||
map-83.gif
|
||||
map-84.gif
|
||||
map-85.gif
|
||||
map-86.gif
|
||||
map-87.gif
|
||||
map-88.gif
|
||||
map-89.gif
|
||||
map-90.gif
|
||||
map-91.gif
|
||||
map-92.gif
|
||||
map-93.gif
|
||||
map-94.gif
|
||||
map-95.gif
|
||||
map-96.gif
|
||||
map-97.gif
|
||||
map-98.gif
|
||||
map-99.gif
|
||||
map-100.gif
|
||||
map-101.gif
|
||||
map-102.gif
|
||||
map-103.gif
|
||||
map-104.gif
|
||||
map-105.gif
|
||||
map-106.gif
|
||||
map-107.gif
|
||||
map-108.gif
|
||||
map-109.gif
|
||||
map-110.gif
|
||||
map-111.gif
|
||||
map-112.gif
|
||||
map-113.gif
|
||||
map-114.gif
|
||||
map-115.gif
|
||||
map-116.gif
|
||||
map-117.gif
|
||||
map-118.gif
|
||||
map-119.gif
|
||||
map-120.gif
|
||||
map-121.gif
|
||||
map-122.gif
|
||||
map-123.gif
|
||||
map-124.gif
|
||||
map-125.gif
|
||||
map-126.gif
|
||||
map-127.gif
|
||||
map-128.gif
|
||||
map-129.gif
|
||||
map-130.gif
|
||||
map-131.gif
|
||||
map-132.gif
|
||||
map-133.gif
|
||||
map-134.gif
|
||||
map-135.gif
|
||||
map-136.gif
|
||||
map-137.gif
|
||||
map-138.gif
|
||||
END_INPUT
|
41
scripts/mapper/mapper
Normal file
41
scripts/mapper/mapper
Normal file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/sh
|
||||
|
||||
# This script may be run from cron before each update make
|
||||
# a map of the world. It increments the number in the file "frames"
|
||||
# each time it is run, and uses this number to determine the map
|
||||
# file names. Creates a country map and an overlay with country names.
|
||||
# -harmless
|
||||
|
||||
|
||||
# edit these to the location of the map files and the utilities
|
||||
cd /home/children/howitzer/map
|
||||
PATH=/home/children/bin/netpbm:${PATH}:/usr/local/bin:${HOME}/bin:.
|
||||
export PATH
|
||||
|
||||
if test ! -s frames
|
||||
then
|
||||
echo 0 >frames.new
|
||||
else
|
||||
awk '{ print $1 + 1; }' frames > frames.new
|
||||
fi
|
||||
|
||||
|
||||
FILE=map-`cat frames.new`.gif
|
||||
OVERMAP=overmap-`cat frames.new`.gif
|
||||
touch census report version
|
||||
eif mapper <<EOF
|
||||
dump * | ./pgmmap.awk | /home/children/bin/netpbm/ppmtogif >${FILE}
|
||||
report * | egrep -v '(Frey|Lurker|pea|Mapmaker|Visitor|visitor|report)' >report
|
||||
census * >! census
|
||||
version >!version
|
||||
exit
|
||||
EOF
|
||||
|
||||
./over.awk scale=4 version report census
|
||||
/home/children/bin/netpbm/ppmtogif over.pbm >${OVERMAP}
|
||||
|
||||
if test -s "$FILE"
|
||||
then
|
||||
cp frames.new frames
|
||||
rm frames.new
|
||||
fi
|
85
scripts/mapper/over.awk
Normal file
85
scripts/mapper/over.awk
Normal file
|
@ -0,0 +1,85 @@
|
|||
#!/bin/awk -f
|
||||
|
||||
# Parse report and generate pbmtext commands for each country
|
||||
# Now generates new positions as an average of all sectors.
|
||||
|
||||
BEGIN {
|
||||
if (scale=="") scale=1;
|
||||
FS="[ \t\n,]+";
|
||||
}
|
||||
|
||||
/^World size is [0-9]+ by [0-9]+./ {
|
||||
width = $4;
|
||||
height= $6;
|
||||
system("ppmmake white " (width+1)*scale " " height*scale " | ppmtopgm | pgmtopbm >over.pbm");
|
||||
}
|
||||
|
||||
/.*#.*name.*tech.*research.*education.*happiness.*cap-location/ {
|
||||
getline;
|
||||
while (NF>4) {
|
||||
if ($2>0 && $2<90) {
|
||||
name[$2]=substr($0,8,15);
|
||||
capx[$2]= $(NF-1);
|
||||
capy[$2]= $NF;
|
||||
}
|
||||
getline;
|
||||
}
|
||||
}
|
||||
|
||||
/own +sect/ {
|
||||
getline;
|
||||
while (NF>2) {
|
||||
if ($2 in name) {
|
||||
if (!count[$2]) {
|
||||
cx[$2] = $3;
|
||||
cy[$2] = $4;
|
||||
} else {
|
||||
dx = $3 - cx[$2];
|
||||
dy = $4 - cy[$2];
|
||||
if (dx>=width/2) dx -= width;
|
||||
if (dy>=height/2) dy -= height;
|
||||
if (dx<-width/2) dx += width;
|
||||
if (dy<-height/2) dy += height;
|
||||
cx[$2] += dx/(1+count[$2]);
|
||||
cy[$2] += dy/(1+count[$2]);
|
||||
}
|
||||
count[$2]++;
|
||||
}
|
||||
getline;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
END {
|
||||
for (i in name) {
|
||||
if (count[i]) {
|
||||
system("pbmtext \"" name[i] "\" | pnmcrop >text.pbm");
|
||||
system("pnmfile text.pbm >text.size");
|
||||
getline < "text.size";
|
||||
close("text.size");
|
||||
h=$NF;
|
||||
w=$(NF-2);
|
||||
x = cx[i] + width/2;
|
||||
y = cy[i] + height/2;
|
||||
|
||||
while (x<0) x += width;
|
||||
while (y<0) y += height;
|
||||
while (x>=width) x -= width;
|
||||
while (y>=height) y -= height;
|
||||
|
||||
x = int(x*scale);
|
||||
y = int(y*scale);
|
||||
|
||||
x -= w/2;
|
||||
y -= h/2;
|
||||
if (x<0) x=0;
|
||||
if (y<0) y=0;
|
||||
if (x+w>=width*scale) x=width*scale-w-1;
|
||||
if (y+h>=height*scale) y=height*scale-h-1;
|
||||
|
||||
|
||||
system("pnmpaste text.pbm " x " " y " over.pbm > over2.pbm");
|
||||
system("cp over2.pbm over.pbm");
|
||||
}
|
||||
}
|
||||
}
|
3
scripts/mapper/over2.pbm
Normal file
3
scripts/mapper/over2.pbm
Normal file
|
@ -0,0 +1,3 @@
|
|||
P4
|
||||
260 128
|
||||
À`l
|
41
scripts/mapper/param.pl
Normal file
41
scripts/mapper/param.pl
Normal file
|
@ -0,0 +1,41 @@
|
|||
#!/usr/local/bin/perl
|
||||
|
||||
open(FRAMES_FH, 'frames') || die 'Cannot open file "frames".';
|
||||
|
||||
|
||||
# modify the INPUT stanza of a mpeg param file to reflect the actual input
|
||||
|
||||
$[ = 1; # set array base to 1
|
||||
$, = ' '; # set output field separator
|
||||
$\ = "\n"; # set output record separator
|
||||
|
||||
line: while (<>) {
|
||||
chop; # strip record separator
|
||||
@Fld = split(' ', $_, 9999);
|
||||
if (/^INPUT$/ .. /^END_INPUT$/) {
|
||||
next line;
|
||||
}
|
||||
|
||||
print $_;
|
||||
}
|
||||
|
||||
printf (("INPUT\n"));
|
||||
$_ = &Getline2('FRAMES_FH');
|
||||
$frames = $Fld[1];
|
||||
for ($i = 0; $i <= $frames; $i++) {
|
||||
$file = sprintf('map-%d.gif', $i);
|
||||
$size = -s $file;
|
||||
if ($size>300 && $size<10000) {
|
||||
printf "%s\n", $file;
|
||||
}
|
||||
}
|
||||
printf (("END_INPUT\n"));
|
||||
|
||||
sub Getline2 {
|
||||
($fh) = @_;
|
||||
if ($getline_ok = (($_ = <$fh>) ne '')) {
|
||||
chop; # strip record separator
|
||||
@Fld = split(' ', $_, 9999);
|
||||
}
|
||||
$_;
|
||||
}
|
66
scripts/mapper/pgmmap.awk
Normal file
66
scripts/mapper/pgmmap.awk
Normal file
|
@ -0,0 +1,66 @@
|
|||
#!/bin/awk -f
|
||||
|
||||
#
|
||||
# Convert a deity dump file into a Portable GreyMap of country numbers
|
||||
#
|
||||
|
||||
function abs(x) {
|
||||
if (x>0) return x;
|
||||
return -x;
|
||||
}
|
||||
|
||||
/own +sect/ {
|
||||
getline;
|
||||
while (NF>2) {
|
||||
own[$2]=$1;
|
||||
des[$2]=substr($3,0,1);
|
||||
if ($1>max) max=$1;
|
||||
getline;
|
||||
}
|
||||
}
|
||||
|
||||
/own x y des/ {
|
||||
getline;
|
||||
while (NF>2) {
|
||||
own[$2,$3]=$1;
|
||||
des[$2,$3]=$4;
|
||||
if ($1>max) max=$1;
|
||||
if ($2 < left) left=$2;
|
||||
if ($2 > right) right=$2;
|
||||
if ($3 < top) top=$3;
|
||||
if ($3 > bottom) bottom=$3;
|
||||
getline;
|
||||
}
|
||||
}
|
||||
|
||||
/^World size is [0-9]+ by [0-9]+./ {
|
||||
width = $4;
|
||||
height= $6 + 0;
|
||||
left=-width/2;
|
||||
right=width/2-1;
|
||||
top= -height/2;
|
||||
bottom = height/2-1;
|
||||
}
|
||||
|
||||
END {
|
||||
printf("P2\n%d %d\n255\n",right-left+2,bottom-top+1);
|
||||
for (y=top;y<=bottom;y++) {
|
||||
printf("\n");
|
||||
if (y%2) {
|
||||
color=own[right,y];
|
||||
if (color==0 && des[right,y]!=".") color=254;
|
||||
printf("%d\n",color);
|
||||
}
|
||||
for (x=left + abs(y%2);x<=right;x+=2) {
|
||||
color=own[x,y];
|
||||
if (color==0 && des[x,y]!=".") color=254;
|
||||
printf("%d %d\n",color,color);
|
||||
}
|
||||
if (!(y%2)) {
|
||||
color=own[left,y];
|
||||
if (color==0 && des[left,y]!=".") color=254;
|
||||
printf("%d\n",color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
15
scripts/mapper/randppm.awk
Normal file
15
scripts/mapper/randppm.awk
Normal file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/awk -f
|
||||
|
||||
# Create random colors for colormap files
|
||||
|
||||
BEGIN {
|
||||
printf("P3\n16 16\n255\n");
|
||||
srand();
|
||||
printf("0 192 255\n");
|
||||
for (i=1;i<253;i++) {
|
||||
printf("%d %d %d\n",32*int(rand()*6)+32,32*int(rand()*6)+32,32*int(rand()*6)+32);
|
||||
}
|
||||
printf("255 255 255\n");
|
||||
printf("128 128 128\n");
|
||||
printf("0 0 0\n");
|
||||
}
|
3
scripts/mapper/text.pbm
Normal file
3
scripts/mapper/text.pbm
Normal file
|
@ -0,0 +1,3 @@
|
|||
P4
|
||||
24 9
|
||||
<EFBFBD><01>F
|
1
scripts/mapper/text.size
Normal file
1
scripts/mapper/text.size
Normal file
|
@ -0,0 +1 @@
|
|||
text.pbm: PBM raw, 24 by 9
|
Loading…
Add table
Add a link
Reference in a new issue