[comp.sources.games] v06i096: conquer4 - middle earth multi-player game

billr@saab.CNA.TEK.COM (Bill Randle) (06/24/89)

Submitted-by: adb@bu-it.bu.edu (Adam Bryant)
Posting-number: Volume 6, Issue 96
Archive-name: conquer4/Part14
Superseeds: conquer3; Volume 4, Issue 42-49



#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 14 (of 14)."
# Contents:  Makefile cexecute.c man.pag sort.c txt3
# Wrapped by billr@saab on Thu Jun 15 15:20:24 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(7763 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X#	conquer: Copyright (c) 1988 by Edward M Barlow
X#
X#	BY CHANGING THIS FILE, YOU AGREE TO ABIDE BY THE LIMITATIONS STATED IN
X#	THE LIMITED USE CONTRACT CONTAINED IN THE FILE "header.h"
X#
XMAKE	= /bin/make
XCC	= /bin/cc
XRM	= /bin/rm -f
X
X#	LN must be "ln -s" if source, data, and default span disks
XLN	= ln
XCP	= cp
XNULL	= 2>/dev/null
X
X#	This should be installed by whomever you want to own the game.
X#	I recommend "games" or "root".
X
X#if the final link does not compile change to the line below
X#LIBRARIES = -lcurses -ltermcap
XLIBRARIES = -lcurses
X
X#	this is the name of the user executable
X#	the user executable contains commands for the games players
XGAME = conquer
X#	this is the name of the administrative executable
X#	the administrative executable contains commands for the game super user
XADMIN = conqrun
X
X#	This directory is where the executables will be stored
X#	This would be the equivalent of /usr/games
XEXEDIR = /c28/smile/game/runv
X
X#	GAME IDENTIFICATION
X#	GAMEID is the game identifier
X#	DATA is the directory where an individual Conquer game data will be
X#	stored.  It is the directory you use in the -d option of the game.
X#	"make new_game" will build a world in that directory.  The current
X#	game will be automatically executed upon login (no need for -d)
X#	but if other games are compiled, you need to use -d (ie. the
X#	game automatically looks at the DATA directory it was compiled with.
XGAMEID = 1
XDATA = $(EXEDIR)/lib$(GAMEID)
X
X#	The following CFLAGS should be set by a normal user
XCFLAGS  = -DDEFAULTDIR=\"$(DATA)\" -O -s -DEXEDIR=\"$(EXEDIR)\"
X#	The following CFLAGS should be used if you wish to debug the game
X#CFLAGS  = -DDEFAULTDIR=\"$(DATA)\" -DDEBUG -g -DEXEDIR=\"$(EXEDIR)\"
X
X# AFILS are files needed for game updating...
XAFILS = combat.c cexecute.c io.c admin.c makeworl.c  navy.c spew.c \
Xnewlogin.c update.c magic.c npc.c misc.c randeven.c data.c trade.c check.c
XAOBJS = combat.o cexecuteA.o ioA.o admin.o makeworl.o  navyA.o \
Xnewlogin.o update.o magicA.o npc.o miscA.o randeven.o dataA.o \
XtradeA.o check.o $(GETOPT) spew.o
X
X# GFILS are files needed to run a normal interactive game
XGFILS = commands.c cexecute.c forms.c io.c main.c move.c navy.c \
Xmagic.c misc.c reports.c data.c display.c extcmds.c trade.c check.c
XGOBJS = commands.o cexecute.o forms.o io.o main.o move.o navy.o \
Xmagic.o misc.o reports.o data.o display.o extcmds.o trade.o check.o $(GETOPT)
X
X#txt[0-5] are input help files.  help[0-5] are output
XHELP0=txt0
XHELP1=txt1
XHELP2=txt2
XHELP3=txt3
XHELP4=txt4
XHELP5=txt5
XHELPOUT=help
X
XHEADERS=header.h data.h newlogin.h patchlevel.h
XHELPFILES= $(HELP0) $(HELP1) $(HELP2) $(HELP3) $(HELP4) $(HELP5)
XALLFILS=$(HEADERS) $(AFILS) commands.c forms.c main.c move.c \
Xreports.c display.c extcmds.c $(HELPFILES) nations Makefile README \
Xrun man.pag notes.v4 rules sort.c newhelp.c
X
Xall:	$(ADMIN) $(GAME) helpfile conqsort
X	@echo YAY! make new_game to set up permissions, zero appropriate
X	@echo initial files, move $(GAME) and $(ADMIN) to
X	@echo $(EXEDIR), and set up the world.
X	@echo If a game is in progress, make install will just move $(GAME)
X	@echo and $(ADMIN) to $(EXEDIR).
X	@echo
X
X$(ADMIN):	$(AOBJS)
X	@echo phew...
X	@echo if the next command does not compile, you might also need -ltermcap
X	@echo === compiling administrative functions
X	$(CC) -p -o $(ADMIN) $(AOBJS) $(LIBRARIES)
X
X$(GAME):	$(GOBJS)
X	@echo phew...
X	@echo if the next command does not compile, you might also need -ltermcap
X	@echo === compiling user interface
X	$(CC) -O -o $(GAME) $(GOBJS) $(LIBRARIES)
X
Xconqsort:
X	$(CC) -O -oconqsort sort.c
X
Xclobber:
X	$(RM) *.o core newhelp sed.1 sed.2 lint* \
X		conquer.doc $(GAME) $(ADMIN) $(HELPOUT)[0-5] 2>/dev/null
X
Xclean:
X	$(RM) *.o core conquer.doc sed.1 sed.2 newhelp $(HELPOUT)[0-5] 2>/dev/null
X
Xinstall:  all
X	-$(LN) $(GAME) $(EXEDIR)/$(GAME) $(NULL)
X	-$(LN) $(ADMIN) $(EXEDIR)/$(ADMIN) $(NULL)
X	-$(LN) conqsort $(EXEDIR)/conqsort $(NULL)
X	chmod 4755 $(EXEDIR)/$(GAME)
X	chmod 4750 $(EXEDIR)/$(ADMIN)
X	$(CP) conqsort nations rules $(HELPOUT)? $(DATA) $(NULL)
X
Xnew_game:  all
X	@echo Installing new game in $(EXEDIR)
X	-mkdir $(EXEDIR) 2>/dev/null
X	chmod 755 $(EXEDIR)
X	-$(LN) $(GAME) $(EXEDIR)/$(GAME) $(NULL)
X	-$(LN) $(ADMIN) $(EXEDIR)/$(ADMIN) $(NULL)
X	chmod 4755 $(EXEDIR)/$(GAME)
X	chmod 4750 $(EXEDIR)/$(ADMIN)
X	chmod 0700 run
X	@echo Copying data to library $(DATA)
X	-mkdir $(DATA) 2>/dev/null
X	chmod 751 $(DATA)
X	chmod 0600 nations
X	$(CP) nations rules $(HELPOUT)? $(DATA) $(NULL)
X	@echo now making the world
X	$(EXEDIR)/$(ADMIN) -d$(DATA) -m
X	$(EXEDIR)/$(ADMIN) -d$(DATA) -a
X
Xhelpfile:	$(HELPOUT)0
X	@echo Helpfiles built
X
X$(HELPOUT)0:	newhelp $(HELPFILES)
X	@echo Building the help files
X	newhelp
X	cat $(HELP0) | sed -f sed.1 > $(HELPOUT)0
X	cat $(HELP1) | sed -f sed.1 | sed -f sed.2 > $(HELPOUT)1
X	cat $(HELP2) | sed -f sed.1 > $(HELPOUT)2
X	cat $(HELP3) | sed -f sed.1 | sed -f sed.2 > $(HELPOUT)3
X	cat $(HELP4) | sed -f sed.1 > $(HELPOUT)4
X	cat $(HELP5) | sed -f sed.1 > $(HELPOUT)5
X	chmod 0644 $(HELPOUT)[0-5]
X	-$(RM) sed.1 sed.2
X
Xlint:
X	lint -DDEFAULTDIR=\"$(DATA)\" -DEXEDIR=\"$(EXEDIR)\" -DCONQUER $(GFILS) $(LIBRARIES)> lintg
X	lint -DDEFAULTDIR=\"$(DATA)\" -DEXEDIR=\"$(EXEDIR)\" -DADMIN $(AFILS) $(LIBRARIES) > linta
X
Xdocs:	helpfile conquer.doc
X
Xconquer.doc:	$(HELPOUT)0 $(HELPOUT)1 $(HELPOUT)2 $(HELPOUT)3 $(HELPOUT)4 $(HELPOUT)5
X	cat $(HELPOUT)?|sed -e "s/^DONE//g"|sed -e "s/^END//g" > conquer.doc
X
Xshar:
X	echo " lines   words chars   FILENAME" > MANIFEST
X	wc $(ALLFILS) >> MANIFEST
X	$(HOME)/src/xshar/xshar -D -c -l64 -oshar -v $(ALLFILS)
X
Xcombat.o:	data.h header.h combat.c
X	$(CC) $(CFLAGS) -DADMIN -c combat.c
Xcexecute.o:	data.h header.h cexecute.c
X	$(CC) $(CFLAGS) -DCONQUER -c cexecute.c
Xio.o:	data.h header.h  io.c
X	$(CC) $(CFLAGS) -DCONQUER -c io.c
XcexecuteA.o:	data.h header.h cexecute.c
X	$(CC) $(CFLAGS) -DADMIN -c cexecute.c
X	mv cexecute.o cexecuteA.o
XioA.o:	data.h header.h  io.c
X	$(CC) $(CFLAGS) -DADMIN -c io.c
X	mv io.o ioA.o
Xadmin.o:	data.h header.h admin.c
X	$(CC) $(CFLAGS) -DADMIN -c admin.c
Xmakeworl.o:	data.h header.h makeworl.c
X	$(CC) $(CFLAGS) -DADMIN -c makeworl.c
Xnewlogin.o:	data.h header.h newlogin.h newlogin.c
X	$(CC) $(CFLAGS) -DADMIN -c newlogin.c
Xupdate.o:	data.h header.h update.c
X	$(CC) $(CFLAGS) -DADMIN -c update.c
Xmagic.o:	data.h header.h magic.c
X	$(CC) $(CFLAGS) -DCONQUER -c magic.c
XmagicA.o:	data.h header.h magic.c
X	$(CC) $(CFLAGS) -DADMIN -c magic.c
X	mv magic.o magicA.o
Xnpc.o:	data.h header.h npc.c
X	$(CC) $(CFLAGS) -DADMIN -c npc.c
Xmisc.o:	data.h header.h misc.c
X	$(CC) $(CFLAGS) -DCONQUER -c misc.c
XmiscA.o:	data.h header.h misc.c
X	$(CC) $(CFLAGS) -DADMIN -c misc.c
X	mv misc.o miscA.o
Xrandeven.o:	data.h header.h randeven.c
X	$(CC) $(CFLAGS) -DADMIN -c randeven.c
Xdata.o:	data.h header.h data.c
X	$(CC) $(CFLAGS) -DCONQUER -c data.c
XdataA.o:	data.h header.h data.c
X	$(CC) $(CFLAGS) -DADMIN -c data.c
X	mv data.o dataA.o
Xdisplay.o:	data.h header.h display.c
X	$(CC) $(CFLAGS) -DCONQUER -c display.c
Xreports.o:	data.h header.h reports.c
X	$(CC) $(CFLAGS) -DCONQUER -c reports.c
Xmove.o:	data.h header.h move.c
X	$(CC) $(CFLAGS) -DCONQUER -c move.c
Xmain.o:	data.h header.h main.c
X	$(CC) $(CFLAGS) -DCONQUER -c main.c
Xforms.o:	data.h header.h forms.c
X	$(CC) $(CFLAGS) -DCONQUER -c forms.c
Xcommands.o:	data.h header.h commands.c
X	$(CC) $(CFLAGS) -DCONQUER -c commands.c
Xcheck.o:	data.h header.h check.c
X	$(CC) $(CFLAGS) -c check.c
Xtrade.o:	data.h header.h trade.c
X	$(CC) $(CFLAGS) -DCONQUER -c trade.c
XtradeA.o:	data.h header.h trade.c
X	$(CC) $(CFLAGS) -DADMIN -c trade.c
X	mv trade.o tradeA.o
XnavyA.o:	data.h header.h navy.c
X	$(CC) $(CFLAGS) -DADMIN -c navy.c
X	mv navy.o navyA.o
Xnavy.o:	data.h header.h trade.c
X	$(CC) $(CFLAGS) -DCONQUER -c navy.c
Xnewhelp:	data.o header.h data.h newhelp.c
X	@echo Compiling the help program
X	$(CC) $(CFLAGS) newhelp.c data.o -o newhelp
END_OF_FILE
if test 7763 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'cexecute.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'cexecute.c'\"
else
echo shar: Extracting \"'cexecute.c'\" \(7679 characters\)
sed "s/^X//" >'cexecute.c' <<'END_OF_FILE'
X/*conquer : Copyright (c) 1988 by Ed Barlow.
X *  I spent a long time writing this code & I hope that you respect this.
X *  I give permission to alter the code, but not to copy or redistribute
X *  it without my explicit permission.  If you alter the code,
X *  please document changes and send me a copy, so all can have it.
X *  This code, to the best of my knowledge works well,  but it is my first
X *  'C' program and should be treated as such.  I disclaim any
X *  responsibility for the codes actions (use at your own risk).  I guess
X *  I am saying "Happy gaming", and am trying not to get sued in the process.
X *                                                Ed
X */
X
X/*EXECUTE THE PROGRAM*/
X#include "header.h"
X#include "data.h"
Xextern long startgold;
Xextern short country;
Xextern FILE *fexe;
Xextern char fison[];
X
X#ifdef CONQUER
Xextern int roads_this_turn;
Xextern int terror_adj;
X#endif
X
Xint
Xexecute(isupdate)
Xint	isupdate;	/* 0 if not update, 1 if update */
X{
X	FILE *fp, *fopen();
X	int cmd,savectry;
X	char comment[20];
X	char temp[10];
X	long longvar,long2var;
X	int armynum;
X	short int x,y;
X	int execed=0;
X	int done=FALSE;
X	char line[80];
X
X	/* initialize startgold */
X	if( isupdate==0) startgold = curntn->tgold;
X
X	/* initialize i_people */
X	for(x=0;x<MAPX;x++)
X		for(y=0;y<MAPY;y++)
X			if(( sct[x][y].owner == country)&&
X			((sct[x][y].designation == DTOWN)
X			||( sct[x][y].designation == DCAPITOL)
X			||( sct[x][y].designation == DCITY)))
X/* note: i_people is a short, so we must scale to allow for people >= 32K */
X				sct[x][y].i_people = sct[x][y].people/256;
X			else
X				sct[x][y].i_people = 0;
X
X	/*open exefile file*/
X	sprintf(line,"%s%d",exefile,country);
X	if ((fp=fopen(line,"r"))==NULL) {
X		/*THIS MEANS THAT THE NATION HAS NOT MOVED YET*/
X		return(0);
X	}
X	savectry=country;
X
X	/*read in file*/
X	if(fgets(line,80,fp)==NULL) done=TRUE;
X	while(done==FALSE) {
X		/*read and parse a new line*/
X		/*CODE IF YOU USE LONG VAR IS L_*/
X		if( line[0] == 'L' && line[1] == '_' ) {
X			sscanf(line,"%s %d %hd %ld %ld %hd %s",
X				temp,&cmd,&country,&longvar,&long2var,&y,comment);
X		} else {
X			sscanf(line,"%s %d %hd %d %hd %hd %s",
X				temp,&cmd,&country,&armynum,&x,&y,comment);
X		}
X		curntn = &ntn[country];
X
X		execed=1;
X		switch(cmd){
X		case XASTAT:		/*Aadjstat*/
X			if(x>0)  P_ASTAT=x;
X			break;
X		case XAMEN:	/*Aadjmen*/
X			armynum= (int) longvar;
X			P_ASOLD= (int) long2var;
X			P_ATYPE= y;
X			break;
X		case XBRIBE:	/* nation has been bribed */
X			if(!isupdate) break;	/* only work on update */
X			ntn[y].tgold += longvar;
X#ifdef DEBUG
X	fprintf(stderr,"DEBUG: BRIBE BY %s of %s\n",ntn[country].name,ntn[y].name);
X#endif DEBUG
X			/* x represents chance of successful bribe */
X			if(npctype(curntn->active)==npctype(ntn[y].active))
X				x = 50;
X			else if(isneutral(ntn[y].active)) x=30;
X			else if(npctype(ntn[y].active)==ISOLATIONIST) x=15;
X			else	x = 20;
X			if(curntn->race==ntn[y].race) x+= 20;
X			if( rand()%100 < x){
X#ifdef DEBUG
X	fprintf(stderr,"DEBUG: BRIBE IS SUCCESS\n");
X#endif DEBUG
X				ntn[y].dstatus[country]--;
X			}
X			break;
X		case XALOC:	/*Aadjloc*/
X			P_AXLOC=x;
X			P_AYLOC=y;
X			break;
X		case MSETA:	/*Aadjmerc*/
X#ifdef CONQUER
X			mercgot+=armynum;
X#endif
X#ifdef ADMIN
X			MERCMEN-=armynum;
X#endif
X			break;
X		case MSETB:	/*Aadjdisb*/
X			/* only allow raising of merc bonus */
X			if (x>MERCATT)
X			MERCATT=(MERCMEN*MERCATT+armynum*x)/(MERCMEN+armynum);
X			if (y>MERCDEF)
X			MERCDEF=(MERCMEN*MERCDEF+armynum*y)/(MERCMEN+armynum);
X			MERCMEN+=armynum;
X			break;
X		case XNLOC: /*nadjloc*/
X			curntn->nvy[armynum].xloc=x;
X			curntn->nvy[armynum].yloc=y;
X			break;
X		case XNACREW:
X			curntn->nvy[armynum].crew=x;
X			curntn->nvy[armynum].armynum=y;
X			break;
X		case XNAMER: /*nadjmer*/
X			curntn->nvy[armynum].merchant=x;
X			break;
X		case XNAWAR: /*nadjwar*/
X			curntn->nvy[armynum].warships=x;
X			break;
X		case XNAGAL: /*nadjgal*/
X			curntn->nvy[armynum].galleys=x;
X			break;
X		case XNAHOLD: /*nadjhld*/
X			curntn->nvy[armynum].people=(unsigned char)y;
X			curntn->nvy[armynum].armynum=(unsigned char)x;
X			break;
X		case XECNAME:	/*Nadjname*/
X			strcpy(curntn->name,comment);
X			break;
X		case XECPAS:	/*Nadjpas*/
X			strncpy(curntn->passwd,comment,PASSLTH);
X			break;
X		case NPOP:	/* set various nation attributes */
X#ifdef CONQUER
X			terror_adj++;
X#endif CONQUER
X			curntn->popularity = armynum;
X			curntn->terror = x;
X			curntn->reputation = y;
X			break;
X		case NTAX:	/* set nations tax rate */
X			curntn->tax_rate = armynum;
X			curntn->active = x;
X			curntn->charity = y;
X			break;
X		case EDSPL:	/*Edecspl*/
X			curntn->spellpts-=armynum;
X			break;
X		case XSADES:	/*Sadjdes*/
X			if((sct[x][y].owner!=country)&&(country!=0)) {
X				fprintf(stderr,"ERROR: <%s> redesignate sector %d,%d that is not owned\n",curntn->name,x,y);
X				break;
X			}
X
X			sct[x][y].designation=comment[0];
X			if(sct[x][y].designation==DCAPITOL){
X				curntn->capx=x;
X				curntn->capy=y;
X			}
X#ifdef CONQUER
X			if (sct[x][y].designation==DROAD)
X				roads_this_turn++;
X#endif
X			break;
X		case XSACIV:	/*Sadjciv*/
X			/* if for some reason you dont own it, put people
X			back into your capitol */
X			if((sct[x][y].owner!=country)&&(country!=0)) {
X				sct[curntn->capx][curntn->capy].people+=armynum;
X				fprintf(stderr,"ERROR: <%s> told to put %d civilians in sector %d,%d not owned - placed in capitol\n",curntn->name,armynum,x,y);
X				break;
X			}
X			sct[x][y].people=armynum;
X			break;
X		case XSIFORT:	/*Sincfort*/
X			sct[x][y].fortress++;
X			break;
X		case XNAGOLD:	/*Nadjgold:*/
X			curntn->tgold = longvar;
X			break;
X		case XAMOV:
X			P_AMOVE=x;
X			break;
X		case XNMOV:
X			curntn->nvy[armynum].smove=x;
X			break;
X		case XSAOWN:
X			/* if not own it, and if people there, problem */
X			if((sct[x][y].owner!=country)
X			&&( country!=0)
X			&&( sct[x][y].owner>0 )
X			&&( sct[x][y].people>0 )
X			&&( magic(country,SLAVER)==FALSE )
X			&&( ntn[sct[x][y].owner].race!=curntn->race)){
X				sct[ntn[sct[x][y].owner].capx][ntn[sct[x][y].owner].capy].people+= sct[x][y].people;
X				sct[x][y].people=0;
X				fprintf(stderr,"ERROR: <%s> taking sector %d %d but civilians exist of other race - puting them in their capitol\n",curntn->name,x,y);
X			}
X			if(curntn->popularity<MAXTGVAL) curntn->popularity++;
X			sct[x][y].owner=country;
X			break;
X		case EDADJ:
X			curntn->dstatus[armynum]=x;
X			break;
X		case XNARGOLD:
X			curntn->jewels = longvar;
X			break;
X		case XNAMETAL:
X			curntn->metals = longvar;
X			break;
X		case INCAPLUS:
X			curntn->aplus++;
X			break;
X		case INCDPLUS:
X			curntn->dplus++;
X			break;
X		case DESTRY:
X			sct[ntn[armynum].capx][ntn[armynum].capy].owner=savectry;
X			country=armynum;
X			destroy(country);
X			country=savectry;
X			break;
X		case CHG_MGK:
X			curntn->powers|=long2var;
X			if(curntn->powers!=longvar){
X			printf("\nERROR ON MAGIC READ country=%d %ld != %ld (or of %ld)",country,longvar,curntn->powers,long2var);
X			getchar();
X			}
X			exenewmgk(long2var);
X			long2var=0;
X			break;
X		}
X		if(fgets(line,80,fp)==NULL) done=TRUE;
X	}
X	fclose(fp);
X	/*return 1 if it did something*/
X	country=savectry;
X	curntn = &ntn[country];
X	if(execed==1) return(1);
X	else return(0);
X}
X#ifdef CONQUER
Xvoid
Xhangup()
X{
X	if(country==0) writedata();
X	else {
X		fprintf(fexe,"L_NGOLD\t%d \t%d \t%ld \t0 \t0 \t%s\n",
X		XNAGOLD ,country,curntn->tgold,"null");
X		fprintf(fexe,"L_NMETAL\t%d \t%d \t%ld \t0 \t0 \t%s\n",
X		XNAMETAL ,country,curntn->metals,"null");
X		fprintf(fexe,"L_NJWLS\t%d \t%d \t%ld \t0 \t0 \t%s\n",
X		XNARGOLD ,country,curntn->jewels,"null");
X	}
X	/*close file*/
X	fclose(fexe);
X	/*send a message to God*/
X	mailopen( 0 );
X	fprintf(fm,"WARNING: Nation %s hungup on me.\n",curntn->name);
X	mailclose();
X
X	/* remove the lock file */
X	unlink(fison);
X	/* exit program */
X	exit(FAIL);
X}
X#endif CONQUER
END_OF_FILE
if test 7679 -ne `wc -c <'cexecute.c'`; then
    echo shar: \"'cexecute.c'\" unpacked with wrong size!
fi
# end of 'cexecute.c'
fi
if test -f 'man.pag' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man.pag'\"
else
echo shar: Extracting \"'man.pag'\" \(5174 characters\)
sed "s/^X//" >'man.pag' <<'END_OF_FILE'
X.TH CONQUER 6
X.SH NAME
Xconquer \- multiuser game of strategy
X.SH SYNOPSIS
X.B conquer
X[-hs -nNAT -dDIR]
X.sp
X.B conqrun
X[-maxp -dDIR ]
X.SH DESCRIPTION
X.I CONQUER
Xis a multi player computer game designed to run under the UNIX
Xoperating system.  In
X.I CONQUER,
Xeach player is the leader of a nation,
Xcomposed of people (humans, orcs, elves, dwarves), recourses, and land.
XRulers customize their nation at creation by chosing their race and by giving
Xtheir nation special powers (magic, combat factor, location, speed...)
Xand resources (civilians, troops, metal, gold...).  Play involves building,
Xmoving, and controlling armies and navies, diplomacy with other players,
Xand adjusting economic activity, which is primarily geared to the production
Xof gold for your treasury.  Metal is needed, however to build ships & armies,
Xand food is needed to prevent revolts and keep people alive.
X.SH ON LINE HELP
XFor detailed information, run conquer with the -h option (see below).
X.SH GAME OPTIONS
X.B conquer
X[-hs -nNAT -dDIR]
X.IP \-h
Xprint this help text
X.IP "\-n NTN"
Xrun as nation NTN
X.IP "\-d DIR"
XRun on data in directory DIR.  Each game has its own data directory.  The
Xdefault is set up at compile time and should only be used if only one game
Xis run.
X.IP \-s
Xprint out scores
X.SH CONTROL OPTIONS
X.B conqrun
X[-maxp -dDIR ]
X.IP \-a     
Xadd new player	
X.IP \-m     
Xmake a world
X.IP \-p     
Xprint a map to standard output.	
X.IP \-x     
Xexecute program
X.IP "\-d DIR  "
Xrun on data in directory DIR
XIt is suggested that each player set up an alias for their game & nation.
XMy alias, for example, is
X.br
X.I conquer -nMordor -d/usr4/adb/games/conqlib2
X.SH CURSOR MOVEMENT
X.nf
Xh: move west
Xy: move north-west
Xk: move north
Xu: move north-east
Xl: move east
Xn: move south-east
Xj: move south
Xb: move south west
XJ: scroll south
XK: scroll north
XL: scroll east
XH: scroll west
X.fi
X.SH COMMANDS
X.TP 
X\'a\':
X.B army report:
XGives army details & permits changing army status, merging 2 armies,
Xsplitting armies, and disbanding armies.
X.TP 
X\'c\':
X.B administration:
XReport on nation status and then change name, password,
Xadd to combat bonus, or (if god) destroy a nation.
X.TP
X\'d\':
X.B change display:
XChange display mode.  Numbers in gold screens... are
Xrelative values of the materials.  People are displayed
Xby hundreds as arabic digits and by thousands with roman
Xnumerals.
X.TP
X\'f\':
X.B fleet report:
XReport on the status of your fleets.
X.TP
X\'g\':
X.B group report:
XGives army details on current sector & permits changing army status,
Xmerging 2 armies, splitting armies, and disbanding armies.
X.TP
X\'m\':
X.B move unit:
Xmove selected unit. The unit will stop when it runs out
Xof move points or runs into an army larger than it.
X.TP
X\'p\':
X.B pick item:
Xallows you to select the next army or navy in the
Xsector.  Other commands will operate on that unit.
X.TP
X\'r\':
X.B redesignate:
Xyou can change habitable sectors you own to other
Xdesignations.  Cities require 500+ people & Capitols
Xrequire cities.  God can redesignate anything.
X.TP
X\'s\':
X.B score:
Xprint out a screen showing the scores.
X.TP
X\'t\':
X.B transport:
Xunload or load a fleet with soldiers or civilians.
X.bp
X.TP
X\'w\':
X.B wizardry:
Xyou may cast spell to allow flight, increase battle
Xperformance or summon monsters if you have the ability.
X.TP
X\'?\':
X.B help screen:
Xprint out help text
X.TP
X\'B\':
X.B budget :
XESTIMATE your nations budget statistics
X.TP
X\'C\':
X.B construct:
XIf you have cash, you can build fortifications and
Xships in your cities.  Ships can only be built in cities
Xlocated on the water.
X.TP
X\'D\':
X.B draft:
XYou may draft a quarter of the population of your
Xcities (those with more than a certain percent of
Xyour population in it) if you have the gold.  You
Xneed 10 per man iron for this.
X.TP
X\'F\':
X.B next fleet:
XMove cursor to your next fleet
X.TP
X\'G\':
X.B next army:
XMove cursor to your next army
X.TP
X\'M\':
X.B magic:
XPrints your magic powers & offers you the option to
Xpurchase more (cost doubles each power). Monster Power
Xgives you the chance to take over NPC nations.
X.TP
X\'N\':
X.B newspaper:
XBriefs you on world happenings.  Note the News has 4 pages.
X.TP
X\'P\':
X.B production:
XESTIMATE your nations production statistics
X.TP
X\'S\':
X.B diplomacy:
XAlloy you to see and alter your diplomatic status.
X.TP
X\'Q\':
X.B quit:
XSave your move and quit the game.  Note there is no
Xmeans supported to quit without saving your moves.
X.TP
X\'R\':
X.B read mail:
XRead mail messages
X.TP
X\'W\':
X.B write mail:
XWrite mail messages
X.TP
X\'Z\':
X.B move people:
XCivilians can move between two of your sectors at a cost
Xof 50 per civilian.  Civilians move naturally in the update.
X.SH FILES
X/usr/games/lib/conquerdir/data	datafile for the running game
X.SH BUGS
XProbably lots, if you find any please mail them to adb@bucsf
X.sp
X1) Security is not as tight as it should be.  People might be able to alter
Xthe data of others nations... this is cheating and unacceptable.  
X.br
X2) Naval battles do not work properly.
X.br
X3) NPC nations can not build navies or move over water.  God should be
Xsure that all NPC nations have a minimum of 5 sectors to move to.
X.br
X4) No comments about the documentation...  It needs to be updated.
END_OF_FILE
if test 5174 -ne `wc -c <'man.pag'`; then
    echo shar: \"'man.pag'\" unpacked with wrong size!
fi
# end of 'man.pag'
fi
if test -f 'sort.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sort.c'\"
else
echo shar: Extracting \"'sort.c'\" \(7076 characters\)
sed "s/^X//" >'sort.c' <<'END_OF_FILE'
X/*
X * sort.c
X *
X * Written by Adam Bryant as a replacement for 'sort'
X * for use with the conquer program.  Note that it
X * is initially written with this program in mind and
X * will not have many features useful elsewhere.
X *
X * INITIAL FORMAT USES [YIELDS SAME RESULTS]:
X *
X *   standard in to standard out:
X *          'cat foo | conqsort > foonew'
X *   file input to standard output:
X *          'conqsort foo > foonew'
X *   file input to file output:
X *          'conqsort foo foonew'
X *
X * OR MAY EVEN OVERWRITE INITIAL FILE VIA:
X *
X *          'conqsort infoo infoo'
X *
X * Design Notes:
X *   - all of the file will have to be placed into memory;
X *   - to allow for any line length, space will be malloced()
X *      as it comes in.
X *
X * Initial Revision:		(adb@bucsf.bu.edu)
X *	Tuesday March 21th, 1989 - Began the program at 23:26 EST
X *      Wednesday March 22nd, 1989 - Finished the initial version 11:29 EST
X */
X
X#include <stdio.h>
X#include "header.h"
X#ifndef HPUX
X#include <sysexits.h>
X#endif HPUX
X#include <ctype.h>
X
X/* system definitions just in case */
X#ifndef FALSE
X#define FALSE (0)
X#define TRUE  (1)
X#endif
X
X/* check for system exit definitions */
X#ifndef EX_OK
X#define EX_OK             0   /* successful termination */
X#define EX_USAGE          64  /* invalid command line format */
X#define EX_NOINPUT        66  /* could not open input file */
X#define EX_SOFTWARE       70  /* software error; couldn't malloc */
X#define EX_CANTCREAT      73  /* could not create output file */
X#endif
X
X/* number of characters to compare by default */
X#define DEFAULT_COMP 2
X#define MAX_STR      200
X
X/* structure for holding a line of information */
Xtypedef struct holder {
X	char *line;
X	struct holder *next;
X} L_DATA, *L_PTR;
X
X/* pointer to head of list of lines */
XL_PTR head;
X
X/* usage string */
Xstatic char usage[]="Usage: %s [-num -h] [infile] [outfile]\n\
X	-h		display this screen\n\
X	-i		treat upper and lower case characters as equivalent\n\
X	-num		Sort on first num characters\n";
X
X/* number of characters for comparison */
Xint compnum=DEFAULT_COMP;
X
X/* flag for folding upper and lowercase characters */
Xint iflag=FALSE;
X
X/* file pointers to infile and outfile */
XFILE *infile=stdin, *outfile=stdout;
X
X/* macros */
X#define UPPER(x) ((islower(x))?(toupper(x)):(x))
X
Xint
Xmain(argc, argv)
X	int argc;
X	char *argv[];
X{
X	/* declare temporary variables and functions */
X	int i,j,num_args=0,l,innum=0,outnum=0;
X	FILE *fopen();
X	int get_line();
X	void place(), send_out();
X
X	/* input string */
X	char data[MAX_STR];
X
X	/* parse command line arguments */
X	for (i=1; i<argc; i++) {
X
X		/* process non-switch statements */
X		if (argv[i][0]!='-') {
X			num_args++;
X			switch(num_args) {
X			   case 1:
X				/* do not open unless arguments are valid */
X				innum=i;
X				break;
X			   case 2:
X				/* do not open unless arguments are valid */
X				outnum=i;
X				break;
X			   default:
X				fprintf(stderr,"%s: Too many parameters\n",argv[0]);
X				fprintf(stderr,usage,argv[0]);
X				exit(EX_USAGE);
X				break;
X			}
X			continue;
X		}
X
X		/* process switch statements */
X		l = strlen(argv[i]);
X		for (j=1; j<l; j++) {
X			switch(argv[i][j]) {
X			   case 'h':
X				fprintf(stderr,usage,argv[0]);
X				exit(EX_OK);
X				break;
X			   case 'i':
X				iflag=TRUE;
X				break;
X			   case '0':
X			   case '1':
X			   case '2':
X			   case '3':
X			   case '4':
X			   case '5':
X			   case '6':
X			   case '7':
X			   case '8':
X			   case '9':
X				/* assign new comparison number */
X				compnum=0;
X				for(;j<l && argv[i][j]>='0' && argv[i][j]<='9';j++)
X				{
X					compnum *= 10;
X					compnum += argv[i][j]-'0';
X				}
X				/* compensate for increment on exit */
X				j--;
X				break;
X			   default:
X				fprintf(stderr,"%s: invalid option '%c' in <%s>\n",
X					   argv[0],argv[i][j],argv[i]);
X				fprintf(stderr,usage,argv[0]);
X				exit(EX_USAGE);
X				break;
X			}
X		}
X	}
X
X	/* open input file now */
X	if(innum!=0) {
X		if((infile=fopen(argv[innum],"r"))==(FILE *)NULL) {
X			fprintf(stderr,"%s: can't open file <%s> for input\n",
X				   argv[0],argv[innum]);
X			exit(EX_NOINPUT);
X		}
X	}
X
X	/* ======= main processing loop ======== */
X
X	while(!feof(infile)) {
X
X		/* remove any lines less than sort characters */
X		if (get_line(data)>compnum) {
X			place(data);
X		}
X
X	}
X
X     /* ==== end of main processing loop ==== */
X
X	/* close input file if not stdin */
X	if (infile!=stdin) {
X		(void) fclose(infile);
X	}
X
X	/* open output file now */
X	if(outnum!=0) {
X		if ((outfile=fopen(argv[outnum],"w"))==(FILE *)NULL) {
X			fprintf(stderr,"%s: cannot open file <%s> for output\n",
X				   argv[0],argv[outnum]);
X			exit(EX_CANTCREAT);
X		}
X	}
X
X	send_out();
X
X	/* close output file if not stdout */
X	if (outfile!=stdout) {
X		(void) fclose(outfile);
X	}
X
X	exit(EX_OK);
X}
X
X/* routine to read all characters in until carriage returns */
Xint
Xget_line(data)
X	char data[];
X{
X	int in,ch;
X
X	/* discard exceptionally long lines */
X	for(in=0;!feof(infile)&&(in<MAX_STR-1)&&((ch=getc(infile))!='\n');)
X	{
X		/* copy valid input into data */
X		if((ch=='\t')||(ch==' ')||((ch>=' ')&&(ch<='~'))) {
X			data[in]=ch;
X			in++;
X		}
X	}
X	/* end string */
X	data[in]='\0';
X
X	return(in);
X}
X
X/* routine to output entire sorted file to outfile */
Xvoid
Xsend_out()
X{
X	L_PTR temp=head;
X
X	while (temp!=(L_PTR)NULL) {
X		fprintf(outfile,"%s\n",temp->line);
X		temp = temp->next;
X	}
X}
X
X/* routine to sort list as it comes in */
Xvoid
Xplace(data)
X	char data[];
X{
X	L_PTR temp, build_node();
X	int comp_line();
X
X	/* find location for placing input */
X	if(head==(L_PTR)NULL) {
X		/* begin list properly */
X		head = build_node(data,(L_PTR)NULL);
X	} else if (comp_line(head->line,data)==1) {
X		/* add to beginning of list */
X		head = build_node(data,head);
X	} else {
X		/* otherwise add in proper position */
X		temp=head;
X		while ((temp->next!=(L_PTR)NULL)
X		&&(comp_line(temp->next->line,data)!=1)) {
X			temp=temp->next;
X		}
X		temp->next = build_node(data,temp->next);
X	}
X}
X
X/* routine to compare two lines through N characters */
X/* where N is given by the variable compnum          */
X/*    returns:  0 on equal                           */
X/*             -1 on a preceding b                   */
X/*              1 on a following b                   */
Xint
Xcomp_line(a,b)
X	char *a,*b;
X{
X	int i;
X
X	for(i=0;i<compnum;i++) {
X		/* do checks */
X		if (iflag) {
X			if (UPPER(a[i])<UPPER(b[i])) return(-1);
X			if (UPPER(b[i])<UPPER(a[i])) return(1);
X		} else {
X			if (a[i]<b[i]) return(-1);
X			if (b[i]<a[i]) return(1);
X		}
X		if (a[i]=='\0') return(0);
X	}
X	return(0);
X}
X
X/* create L_DATA structure containing a line of data */
X/* and the next value set to the given location      */
XL_PTR
Xbuild_node(data, nptr)
X	char data[];
X	L_PTR nptr;
X{
X	L_PTR temp;
X	char *strcpy();
X
X	/* build the memory space */
X	if((temp=(L_PTR)malloc(sizeof(L_DATA)))==(L_PTR)NULL) {
X		fprintf(stderr,"Error in creating structure memory!\n");
X		exit(EX_SOFTWARE);
X	}
X	if((temp->line=(char *)malloc((strlen(data)+1)*sizeof(char)))==NULL) {
X		fprintf(stderr,"Error in creating data memory!\n");
X		exit(EX_SOFTWARE);
X	}
X
X	/* assign the values */
X	(void) strcpy(temp->line,data);
X	temp->next = nptr;
X	return(temp);
X}
X
END_OF_FILE
if test 7076 -ne `wc -c <'sort.c'`; then
    echo shar: \"'sort.c'\" unpacked with wrong size!
fi
# end of 'sort.c'
fi
if test -f 'txt3' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'txt3'\"
else
echo shar: Extracting \"'txt3'\" \(7500 characters\)
sed "s/^X//" >'txt3' <<'END_OF_FILE'
X                              MAGIC POWERS
X
XMagic powers differentiate your nation from all the other nations in the
Xworld.  There are three types of powers - truly MAGICAL powers, which
Xusually involve summoning or spell use, CIVILIAN powers, which are related
Xto civilization and trade, and MILITARY powers, which measure your ability
Xto make war.  
X
XAll nations start with at least one power (based on race or class) and can 
Xpurchase additional powers by expending jewels.  On the Magic Screen ('M'), 
Xif you have enough jewels, you will be asked if you wish to buy a magic
Xpower.
X 
XThe magic screen also permits you to see what powers you have, and to
Xtakeover ORC nations if you are an ORC nation with the appropriate powers.
XEND
X                            HOW TO GET MAGIC
X
XMagic powers cost jewels to obtain; the chance to obtain a power is based on 
Xyour nations magic ability.  The formulae for this is to take two to the 
Xpower of the sum of the number of powers you have from that type and half 
Xthe number of other powers times your base value:
X
Xjewel cost for civilian power = Base * 2**( #mgk/2 + #civ + #mil/2 )
X
X                             type of power desired
X         race         magical    civilian      military
X        elves -        XEMMAG        XECMAG          XEWMAG
X        dwarves -      XDMMAG        XDCMAG          XDWMAG
X        humans -       XHMMAG        XHCMAG          XHWMAG
X        orcs -         XOMMAG        XOCMAG          XOWMAG
X
Xfor example a human with 1 of each power wanting a magic power would pay
X                XHMMAG * 2**(1+1/2+1/2) = 4 *XHMMAG jewels
XEND
X                        COMBAT TYPE POWERS
X
XWARRIOR        +10% in combat. 1/2 Enlistment cost.
XCAPTAIN        +10% in combat. Can have PHALANX Units. Need WARRIOR power.
XWARLORD        +10% in combat. Can have LEGIONARY Units. Need CAPTAIN power.
XARCHER         Can get ARCHER units.
XCAVALRY        Can get LIGHT & HEAVY CAVALRY units.
XSAPPER         CATAPULT/SIEGE @ 1/2 price & 1/2 metal. 1/2 maint.
X               +10% against cities/forts/capitols.
XARMOR          With CAVALRY, can get KNIGHTS; Can Get ELITE Units,
X               -3 Move (4 Min), +20 Defense
XAVIAN          Use ROC and GRIFFON units.
X
XMONSTER POWERS The three powers below are monster powers for orc nations.
X               If using the Orc Takeover option, monster nations have a 
X               chance to takeover ORC NPCs for jewels.
XMINOR MONST    1 minor monster unit/spring. Can get ORCs. 1/2 spell point/turn
XAVERAGE MONST  1 avg monster unit/spring. Can get URUK HAI. 1 spell point/turn
XMAJOR MONST    1 major monster unit/spring. Can get TROLLs. 2 spell point/turn
XEND
X                        CIVILIAN TYPE POWERS
X
XDERVISH    Desert/ICE sectors => 1 move point, vegetation 6, +30% combat in
X           XDERVDESG redesignate desert/ice sectors.
XHIDDEN     Nobody can count troops in your armies on map.
XARCHITECT  Double strength forts, Double Town revenue.
XRELIGION   +2 repro to 10% limit.  excess adds +5% to defense. (Not ORCS).
XMINER      2x metal and jewel production.  Elves cant get.
XURBAN      +3% Birth Rate to 12% limit.  remainder gives + to move (roads)
XBREEDER    +3% Birth Rate (ORCS ONLY) (to 14% limit). -10% combat. (no urban)
X           remainder adds to movement.
XSTEEL      Additional 2x Metal Production for MINERS.
XNINJA      Can have Ninja units.  Spys show enemy troop/civilian strength
X           exactly (even voids).
XSAILOR     1/2 price naval units.  Can use marines.  Double ship speed.
X           sailor nations ships are immune to storms at sea.
XDEMOCRACY  +10% in combat (moralle) +1 Move +1 repro. +1 eatrate.  Also if you
X           don't watch your charity level, you will give too much to the poor.
XROADS      +4 to move if unit starts in your nation.
XSLAVER     you gain 25% of the populace of *any* sector you take over.
XEND
X                        MAGICAL TYPE POWERS
X
XTHE_VOID   Nobody can see your sectors/armies (they appear blank).
XKNOWALL    Know all troop strengths and see the whole map (except voids).
XDESTROYER  Vegetation in 3 sectors of Capitol = Desert.  Act as Dervish.
X           Note: you cant have both DESTROYER and DERVISH power.
XVAMPIRE    35% of troops killed become your zombies, -35% in all combat,
X           All infantry/militia become zombies.  Can't add to combat bonus.
X           Vampire Power causes all nations to go to jihad with you.
XSUMMON     gives 4 spell pts per turn... can summon monsters with them
X           Can also do spell casting.  100K Jewels and 1M gold gives
X           a 20% chance of gaining +1 spell point per turn.  Not Dwarves.
XWYZARD     Gives +3 spell points.  Must have SUMMON Power.
XSORCERER   Gives +3 spell points.  Must have SUMMON Power.
XEND
X                          SPELL CASTING
X
XIf a nation has magical spell points, that nation may cast a number of
Xuseful spells.
X
XThe current list of spells and their costs:
X
XSummon          -- must have SUMMON to cast this spell; cost is dependent
X                    on the monster summoned.  (see next page)
XFlight          -- give flight to a unit at a cost of 1 spell pt / 100 men
XEnhance Attack  -- 30% increase in attack at a cost of 1 spell pt / 300 men
XEnhance Defense -- 30% increase in defense at a cost of 1 spell pt / 300 men
X
X   All of the above spells except summoning have an effect area of one army
Xunit and a duration of one turn.  Flight and the Combat Enhancements each
Xcause the unit to lose one movement point due to the change in status.
XEND
X                        SUMMONED MONSTERS
X
XA monster unit represents one monster, but is the equivalent in combat of an
Xarmy of the given number of men.  When summoned, they appear in your Capitol,
Xand are yours to command until you disband them or can not afford to pay
Xtheir per/turn jewel cost *and* 5x that cost in gold.  Monsters may be
Xwounded in combat as can normal army units.  Wounded monsters have a percent
Xchance of dying based on the percent damage taken (a dragon (1000 men) taking
X200 equivalent men of damage has a 20% chance of dying).  Next turn, however
Xits strength will be fully restored (1000 men again).  A number of the
Xmonsters will also have the ability of flight.
X
XSpell points can accumulate from turn to turn, but there is a 25% chance
Xthat half your unused spell points disappear each turn... this gives you
Xsome incentive to use them.
XEND
X                        SUMMONED MONSTER TYPES
X
X           spell    combat                 jewels      power
X           points   bonus    move    men    turn       prerequisites
XSPIRIT        2       +0      x1      50     1000
XASSASSIN      2      +20      x1      50      400      NINJA
XEFREET        2      +10      x1.5    50      400      DERVISH
XGARGOYLE      2      +10      x1      75      450      MI_MONST
XWRAITH        2      +10      x1      75      450      VAMPIRE
XHERO          2       +0      x1     100      200      WARRIOR
XCENTAUR       2      +10      x1.5    50      200      CAVALRY
XGIANT         5       +0      x1     150     2100
XSUPERHERO     5      +15      x1     150      450      WARLORD
XMUMMY         5      +15      x1     150     1000      VAMPIRE
XELEMENTAL     5       +5      x1.5   175     1900      SORCERER
XMINOTAUR      5      +20      x1     150     2100      DESTROYER
XDEMON         10     +50      x1     500     6000      DESTROYER
XBALROG        10     +40      x1.5   500     6000      WIZARD & VAMPIRE
XDRAGON        15     +50      x2    1000    10000      MA_MONST & WIZARD
XEND
XDONE
END_OF_FILE
if test 7500 -ne `wc -c <'txt3'`; then
    echo shar: \"'txt3'\" unpacked with wrong size!
fi
# end of 'txt3'
fi
echo shar: End of archive 14 \(of 14\).
cp /dev/null ark14isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 14 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0