Import of Empire 4.2.12

This commit is contained in:
Markus Armbruster 2003-08-23 12:23:04 +00:00
commit d8b7fdfae1
817 changed files with 126589 additions and 0 deletions

41
scripts/README Normal file
View file

@ -0,0 +1,41 @@
The files in this directory are various utility scripts/programs
submitted by various people for doing routine maintainence on the
server, such as keeping it alive, making maps, posting to newsgroups,
starting blitzes, etc.
While we provide these files for your convenience, they are not an
"official" part of the server. Therefore, you can e-mail us with
problems with them, but we may or may not know the answers and/or how
to fix any problems. Some of the files have the author's e-mail in
them, and others are anonymous submissions, so you may want to try
to contact the authors if all else fails (but try us first, as we might
know.)
Wolfpack!
------
keepitup
Automatically reboots your Empire server if it crashes.
No configuration necessary. See the comments at the top of
the file for syntax. See crontab.config for an example of
what to add to your crontab.
saveass
Makes automatic backups of your game data. See crontab.config.
To configure, change two paths at the top of the file.
bigstart
Handy for blitzes. Fill start islands with sanctuaries and
fill the sanctuaries with civs. To configure, change the
value of "height" and "width" in teh BEGIN routine.
postresults
Useful for posting canned results to a newsgroup.
blitz/
Scripts for running an auto-resetting blitz.
mapper/
Scripts for making mpeg videos of your game. See mapper/README
for configuration details.

86
scripts/bigstart Normal file
View file

@ -0,0 +1,86 @@
#!/bin/awk -f
#
# IMPORTANT: You must change "height" and "width" by hand below.
#
# A deity tool to parse a dump file and generate edit commands
# to build larger start sanctuaries.
# dump * | bigstart >bigstart.out
# exec bigstart.out
# -Drake (dld@chem.psu.edu)
function sanctuary(x,y,o,nsect)
{
if (x>=width/2) x -= width;
if (y>=height/2) y -= height;
if (x<-width/2) x += width;
if (y<-height/2) y+= height;
nsect = x "," y;
if ((nsect in newown) && !(nsect in own)) {
printf("des %s s\n",nsect);
printf("give civ %s 550\n",nsect);
printf("setsector oldowner %s %d\n",nsect,o);
printf("setsector owner %s %d\n",nsect,o);
printf("setsector work %s 100\n",nsect);
own[nsect]=o;
delete newown[nsect];
added++;
}
}
BEGIN {
SUBSEP=",";
sects=0;
begin=0;
width=64;
height=32;
}
{
if (begin==1) {
for (i=1;i<=NF;i++) header[i]=$i;
nheader=NF;
begin=2;
break;
}
if (NF != nheader) {
begin=0;
}
if (begin==2) {
for (i=1;i<=nheader;i++) {
val[header[i]] = $i;
}
if (val["own"]==0 && val["des"]=="-") {
newown[val["x"],val["y"]]=0;
}
if (val["own"]>0) {
own[val["x"],val["y"]]=val["own"];
}
}
}
/ *DUMP SECTOR/ { begin=1; }
END {
do {
added=0;
for (sect in own) {
split(sect,a,",");
x=a[1];
y=a[2];
sanctuary(x+2,y,own[sect]);
sanctuary(x-2,y,own[sect]);
sanctuary(x+1,y+1,own[sect]);
sanctuary(x+1,y-1,own[sect]);
sanctuary(x-1,y+1,own[sect]);
sanctuary(x-1,y-1,own[sect]);
}
} while (added);
}

6
scripts/blitz/README Normal file
View file

@ -0,0 +1,6 @@
These are the scripts that we use to run the Cheetah and Vampire
blitzes. If you want to use them, then you should copy them to the
bin directory, change the pathnames where appropriate and install the
crontab.config using the crontab command.
Wolfpack! 1996

View file

@ -0,0 +1,3 @@
8,18,28,38,48,58 * * * * /empire/wolfpack/cheetah/bin/keepitup -check vampire /empire/wolfpack/cheetah 6667 Lurker password 1>>/empire/wolfpack/logs/keepitup 2>&1
00 6 * * * /empire/wolfpack/cheetah/bin/setup-blitz 1>>/empire/wolfpack/logs/setup-blitz 2>&1
25 6 * * * /empire/wolfpack/cheetah/bin/start-blitz 1>>/empire/wolfpack/logs/start-blitz 2>&1

18
scripts/blitz/motd Normal file
View file

@ -0,0 +1,18 @@
turn on
Welcome to the Wolfpack
Cheetah Blitz
Empire 4.0.0 (Wolfpack) code
New players should start by typing "info".
All players should check "info Empire4" and "info Infrastructure".
The Wolfpack home page is: http://www.wolfpackempire.com, and has
complete info pages on-line with cross-links.
The blitz resets at 6:00pm EDT every day. Updates start at 6:30pm EDT.
Please email all comments and bug reports to wolfpack@wolfpackempire.com
.

37
scripts/blitz/setup-blitz Normal file
View file

@ -0,0 +1,37 @@
#!/bin/csh
echo '================Setup begin================='
date
cd /empire/wolfpack/cheetah/bin
/empire/wolfpack/cheetah/bin/keepitup -kill cheetah
\rm -f /empire/wolfpack/cheetah/data/server.log
./files <<EOF
y
EOF
./fairland 10 30
/empire/wolfpack/cheetah/bin/keepitup -start cheetah /empire/wolfpack/cheetah
sleep 10
/empire/wolfpack/cheetah/bin/emp_client POGO peter < newcap_script
/empire/wolfpack/cheetah/bin/emp_client POGO peter << EOF
power new
disable
dump * | /empire/wolfpack/cheetah/scripts/bigstart > bigstart.out
bye
EOF
/empire/wolfpack/cheetah/bin/emp_client POGO peter < bigstart.out >> /dev/null
/empire/wolfpack/cheetah/bin/emp_client POGO peter < motd
/empire/wolfpack/cheetah/bin/emp_client POGO peter << EOF
change coun Wolf
change rep password
realm 0 0:-1,0:-1
add 13 Lurker password v i
add 14 Mapmaker password g i
bye
EOF
echo '================Setup end================='

14
scripts/blitz/start-blitz Normal file
View file

@ -0,0 +1,14 @@
#!/bin/csh
echo '================Start begin================='
date
/empire/wolfpack/cheetah/bin/keepitup -check cheetah /empire/wolfpack/cheetah 6667 Lurker password
cd /empire/wolfpack/cheetah/bin
/empire/wolfpack/cheetah/bin/emp_client Wolf password << EOF
enable
ann
Updates are enabled. Have a blast!
.
bye
EOF
echo '================Start end================='

2
scripts/crontab.config Normal file
View file

@ -0,0 +1,2 @@
2,12,22,32,42,52 * * * * /home/wolfpack/bin/keepitup -check howitzer /home/wolfpack/howitzer 7778 Lurker password 1>>/home/wolfpack/logs/keepitup 2>&1
01 18 * * * /home/wolfpack/emp4/scripts/saveass 1>>/home/wolfpack/logs/saveass 2>&1

156
scripts/keepitup Normal file
View file

@ -0,0 +1,156 @@
#!/bin/sh
#
# keepitup
# This is a hacked version of "isempireup" by Dave Nye
# Modified for use with the Empire2 server by Ken Stevens 1995
#
# Usage:
# keepitup -kill <game>
# keepitup -start <game> <dir>
# keepitup -check <game> <dir> <port> <coun> <rep>
#
# Portability:
# You may need to put a '-' in front of the ps flags below
_verbose=true
tbase=/tmp/empcheck.$$
trap 'rm -f $FNAMES ; exit' 0 1 2 3 15
putmsg() {
if [ "$_verbose" = "true" ]; then
echo "`date` $*"
fi
}
ERR0="Server EOF"
ERR1="connect: Connection refused"
ERR2="Expecting 2, got unix socket connect: No such file or directory"
MDOWN="The game is down"
FLAGS="-d"
killit() {
FK=${tbase}.kill
FNAMES="$FNAMES ${FK}.L ${FK}.P"
rm -f ${FK}.L ${FK}.P
ps auxw >${FK}.L
egrep "emp_server $FLAGS $1" ${FK}.L | egrep "$USER" >${FK}.P
SZ="`wc -l ${FK}.P | awk '{print $1}' -`"
if [ $SZ -gt 0 ]; then
PIDS=`awk '{rec = rec " " $2} END {print rec}' ${FK}.P`
putmsg "Found pids $PIDS to kill for emp_server $FLAGS"
kill $PIDS
fi
rm -f ${FK}.L ${FK}.P
}
kill9it() {
PROC=$1
FK=${tbase}.kill
FNAMES="$FNAMES ${FK}.L ${FK}.P"
rm -f ${FK}.L ${FK}.P
ps auxw >${FK}.L
egrep "$PROC" ${FK}.L | egrep "$USER" >${FK}.P
SZ="`wc -l ${FK}.P | awk '{print $1}' -`"
if [ $SZ -gt 0 ]; then
PIDS=`awk '{rec = rec " " $2} END {print rec}' ${FK}.P`
putmsg "Found pids " $PIDS " to kill for" $PROC
kill -9 $PIDS
fi
rm -f ${FK}.L ${FK}.P
}
restartgame() {
DIR=$1
UNIQ=$2
killit $UNIQ
sleep 1
cd $DIR/bin
./emp_server $FLAGS $UNIQ &
echo "restarted $UNIQ"
cd $HOME
}
checkgame() {
DIR=$1
PORT=$2
COUN=$3
PASS=$4
EMPIREHOST=`/bin/hostname`
EMPIREPORT=$PORT
COUNTRY=$COUN
PLAYER=$PASS
export EMPIREHOST EMPIREPORT COUNTRY PLAYER
FN=${tbase}.client
rm -f ${FN}.I ${FN}.1 ${FN}.2
FNAMES="$FNAMES ${FN}.I ${FN}.1 ${FN}.2"
echo "quit" >${FN}.I
echo "quit" >${FN}.I
kill9it emp_client
$DIR/bin/emp_client >${FN}.1 2>${FN}.2 <${FN}.I
STAT=$?
ER=`head -1 ${FN}.2`
NORM=`head -1 ${FN}.1`
if [ "$STAT" = "0" ]; then
ALLOK=true
# putmsg "All Ok"
elif [ "$ER" = "$ERR0" ]; then
ALLOK=true
# putmsg "All Ok, but bad return status"
elif [ "$ER" = "$ERR1" ]; then
ALLOK=false
putmsg "emp_server is down"
elif [ "$ER" = "$ERR2" ]; then
ALLOK=false
putmsg "emp_server is down"
else
ALLOK=false
putmsg "Something is wrong"
fi
rm -f ${FN}.I ${FN}.1 ${FN}.2
}
while [ $# -gt 0 ]; do
case "$1" in
# -kill game
"-kill") shift
if [ $# -lt 1 ]; then
echo "Expecting -kill <game>"
exit 1
fi
killit $1
shift ;;
# -start game dir
"-start") shift
if [ $# -lt 2 ]; then
echo "Expecting -start <game> <dir>"
exit 1
fi
restartgame $2 $1
shift ;shift;;
# -check game dir port country user
"-check") shift
if [ $# -lt 5 ]; then
echo "Expecting -check <game> <dir> <port> <tcoun> <tuser>"
exit 1
fi
checkgame $2 $3 $4 $5
if [ "$ALLOK" != "true" ]; then
restartgame $2 $1
fi
shift ; shift ; shift ; shift ; shift ;;
*) echo "Unknown parameter found in: $*."
echo "Aborting."
exit 1 ;;
esac
done

24
scripts/mapper/Makefile Normal file
View 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
View 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
View 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
View file

@ -0,0 +1,6 @@
#!/bin/sh
# add any paths necessary for eif, netpbm, and mpeg_encode.
cd /home/children/howitzer/map
make clean

View 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

View 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
View 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
View 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
View 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
View 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
View 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
View file

@ -0,0 +1,3 @@
P4
260 128
À`l

41
scripts/mapper/param.pl Normal file
View 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
View 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);
}
}
}

View 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
View file

@ -0,0 +1,3 @@
P4
24 9
<EFBFBD><01>F

1
scripts/mapper/text.size Normal file
View file

@ -0,0 +1 @@
text.pbm: PBM raw, 24 by 9

66
scripts/postresults Normal file
View file

@ -0,0 +1,66 @@
#!/bin/csh
#
# postresults - Steve McClure (ionica@empire.cx), 1998
# Do an automated post to rec.games.empire of a game's power chart
# and the last day's annoucements.
#
# To use, you need to create a visitor country in your game. For example,
# use "News" and "reporter" for the country name/rep of a special country
# used to get the power chart and annos.
#
# Also, this file references a "visitor" account. If you don't have one,
# you may want to take that line out.
#
# Note that this uses 'inews' to post. It's also very crude. But, it
# works great when used from a cronjob.
#
# You will also want to change the messages below to more accurately
# reflect your game.
#
# Note this is the same script I used to post results for the Winterfest
# '98 Tourney. I'm submitting it to wolfpack for inclusion with the
# server.
# Change the following variables depending on where your binaries/game
# is located
setenv INEWS /usr/local/news/inews
setenv TMPDIR /empire/ionica/Tourney
setenv TMPFILE rd3game1.txt
setenv CLIENT /usr/local/bin/empire
setenv EMPIREHOST 149.84.128.9
setenv EMPIREPORT 6641
setenv EMPCOUNTRY News
setenv EMPREP reporter
setenv EMPTITLE "Winterfest '98 Tourney Round 3, Game #1"
setenv DEITYMAIL ionica@empire.net
#
cd $TMPDIR
echo '' > $TMPFILE
echo "This is the daily power chart and announcements for the" >> $TMPFILE
echo $EMPTITLE >> $TMPFILE
echo '' >> $TMPFILE
echo "This is the Final Round of the Winterfest '98 Tourney\!" >> $TMPFILE
echo '' >> $TMPFILE
echo "This game has a visitor account (Country 'visitor' Representative 'visitor')" >> $TMPFILE
echo "and can be found at host '$EMPIREHOST' and port '$EMPIREPORT'." >> $TMPFILE
echo '' >> $TMPFILE
echo "For more questions about this game, send e-mail to '$DEITYMAIL'" >> $TMPFILE
echo '' >> $TMPFILE
echo '------' >> $TMPFILE
echo '' >> $TMPFILE
$CLIENT $EMPCOUNTRY $EMPREP << EOF
pow new >> $TMPFILE
EOF
echo '' >> $TMPFILE
echo '------' >> $TMPFILE
echo '' >> $TMPFILE
$CLIENT $EMPCOUNTRY $EMPREP << EOF
wire 1 >> $TMPFILE
EOF
echo '' >> $TMPFILE
echo '------' >> $TMPFILE
echo '' >> $TMPFILE
$INEWS -t "$EMPTITLE" -n "rec.games.empire" -r "$DEITYMAIL" "$TMPFILE"

42
scripts/saveass Normal file
View file

@ -0,0 +1,42 @@
#! /bin/sh
#! This is a script that will probably end up saving your ass more times
#! then you'll probably want to admit. I wrote this back when I was co-deity
#! of the first empire tourney in December of 1990. This is a basic script
#! run from cron usually 15 miniutes before the update and keeps three copies
#! of the binaries and empire data on hand in tared and compressed format.
#! If you run faster games increase the frequency of the calls from cron.
#! 45 7,15,23 * * * /home/evil/EMP/bin/saveass
#! Above is a sample cron entry that does the backup three times a day.
#! This script should run on most all UNIX computers with all you'll have
#! to do is change the $BACKUPSDIR variable at the top.
#!
#! Dave 'TheEvilOne' Nye, evil@bbn.com
#!
#! Change these to your site specific directories.
EMPIREDIR=/home/bughunt/navy
BACKUPSDIR=/home/bughunt/navy/backups
cd $BACKUPSDIR
rm -rf data.old.old
rm -rf bin.old.old
mv data.old data.old.old
mv bin.old bin.old.old
mv data.new data.old
mv bin.new bin.old
mkdir data.new
mkdir bin.new
#! Enough set up..let's do some work...
cd $EMPIREDIR
tar -cf data.tar data
tar -cf bin.tar bin
mv $EMPIREDIR/data.tar $BACKUPSDIR/data.new
mv $EMPIREDIR/bin.tar $BACKUPSDIR/bin.new
#! This will send you mail telling you that the backup went okay.
/usr/local/bin/gzip $BACKUPSDIR/data.new/data*
ls -l $BACKUPSDIR/data.new
/usr/local/bin/gzip $BACKUPSDIR/bin.new/bin*