CONQUER MISSING FILES ENCLOSED

Edward Barlow smile at mhuxd.UUCP
Wed Jan 27 00:13:08 AEST 1988


As many of you know, the recently posted conquer v2 was missing several
files.  Enclosed are these files, in a very basic shar script. I still
do not have my new electronic mail address, but will post it as soon as
I find out what it is.  The enclosed files are:

	1) the man page (man.page)
	2) update.c
	3) header.h
	4) commands.c -> which is reposted because I received transmission
errors when I took it off the net, and saw a posting that somebody else
had the same difficulties.  Perhaps that is why the posting was screwed up.
NOTE THIS SCRIPT WILL REWRITE YOUR EXISTING COMMANDS.C, but will not
rewrite other files that exist.

The Ed

-----------------------
CUT HERE
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh to create the files
#       
# This archive is number 1
# This archive created: Tue Jan 26 09:02:18 EST 1988
echo shar: extracting "'man.page'" '(4972)'
if test -f 'man.page'
then
	echo shar: will not over-write existing file "'man.page'"
else
	cat << \SHAR_EOF > 'man.page'
.TH CONQUER 6
.SH NAME
conquer \- multiuser game of strategy
.SH SYNOPSIS
.B conquer
[-maxhps -nNAT -dDIR]
.SH DESCRIPTION
.I CONQUER
is a multi player computer game designed to run under the UNIX
operating system.  In
.I CONQUER
,  each player is the leader of a nation,
composed of people (humans, orcs, elves, dwarves), recourses, and land.
Rulers customize their nation at creation by chosing their race and by giving
their nation special powers (magic, combat factor, location, speed...)
and resources (civilians, troops, iron, gold...).  Play involves building,
moving, and controlling armies and navies, diplomacy with other players,
and adjusting economic activity, which is primarily geared to the production
of gold for your treasury.  Iron is needed, however to build ships & armies,
and food is needed to prevent revolts and keep people alive.
.SH ON LINE HELP
For detailed information, run conquer with the -h option (see below).
.SH OPTIONS
Command line format: conquer [-maxhps -nNAT -dDIR]
It is suggested that each player set up an alias for their game & nation.
My alias, for example, is
.I conquer -d/d7/c7913/smile/oldgame/lib -norcland
.
.IP \-m
make the world. This option is only for the superuser of game.
.IP \-a
Add new player to the game. Only by the superuser of the game.
.IP \-p
Print world map to standard out (the screen or a pipe). Only by the superuser of 
the game.
.IP \-h
Prints help to stdout.
.IP \-x
Execute program. Only by the superuser of the game.
.IP \-h
Print out help text.
.IP "\-n NTN"
Run as nation NTN.
.IP "\-d DIR"
Run on data in directory DIR.  Each game has its own data directory.  The
default is set up at compile time and should only be used if only one game
is run.
.IP \-s
Print out scores of all nations in the world.
.SH CURSOR MOVEMENT
h: move west
y: move north-west
k: move north
u: move north-east
l: move east
n: move south-east
j: move south
b: move south west
J: scroll south
K: scroll north
L: scroll east
H: scroll west
.SH COMMANDS
.TP 
\'a\':
.B army report:
Gives army details & permits changing army status, merging 2 armies,
splitting armies, and disbanding armies.
.TP 
\'c\':
.B administration:
Report on nation status and then change name, password,
add to combat bonus, or (if god) destroy a nation.
.TP
\'d\':
.B change display:
Change display mode.  Numbers in gold screens... are
relative values of the materials.
.TP
\'f\':
.B fleet report:
Report on the status of your fleets.
.TP
\'m\':
.B move unit:
move selected unit. The unit will stop when it runs out
of move points or runs into an army larger than it.
.TP
\'p\':
.B pick item:
allows you to select the next army or navy in the
sector.  Other commands will operate on that unit.
.TP
\'r\':
.B redesignate:
you can change habitable sectors you own to other
designations.  Cities require 500+ people & Capitals
require cities.  God can redesignate anything.
.TP
\'s\':
.B score:
print out a screen showing the scores
.TP
\'?\':
.B help screen:
print out help text
.TP
\'A\':
.B adjust army:
The quick way to adjust the status of your armies.
.TP
\'B\':
.B budget :
ESTIMATE your nations budget statistics
.TP
\'C\':
.B construct:
If you have cash, you can build fortifications and
ships in your cities.  Ships can only be built in cities
located on the water.
.TP
\'D\':
.B draft:
You may draft a quarter of the population of your
cities (those with more than a certain percent of
your population in it) if you have the gold.  You
need 10 per man iron for this.
.TP
\'F\':
.B next fleet:
Move cursor to your next fleet
.TP
\'G\':
.B next army:
Move cursor to your next army
.TP
\'M\':
.B magic:
Prints your magic powers & offers you the option to
purchase more (cost doubles each power). Monster Power
gives you the chance to take over NPC nations.
.TP
\'N\':
.B newspaper:
Briefs you on world happenings.  Note the News has 4 pages.
.TP
\'P\':
.B production:
ESTIMATE your nations production statistics
.TP
\'S\':
.B diplomacy:
Alloy you to see and alter your diplomatic status.
.TP
\'Q\':
.B quit:
Save your move and quit the game.  Note there is no
means supported to quit without saving your moves.
.TP
\'R\':
.B read mail:
Read mail messages
.TP
\'W\':
.B write mail:
Write mail messages
.TP
\'Z\':
.B move people:
Civilians can move between two of your sectors at a cost
of 50 per civilian.  Civilians move naturally in the update.
.SH FILES
/usr/local/games/src/conquer/data	datafile for the running game
.SH BUGS
Probably lots, if you find any please mail them to mhuxd!smile.
.sp
1) One known bug is that you sometimes have to type LINEFEED, instead
of RETURN.  
.br
2) Security is not as tight as it should be.  People might be able to alter 
the data of others nations... this is cheating and unacceptable.  
.br
3) Naval battles do not handle capturing merchant ships correctly.
.br
4) NPC nations can not build navies or move over water.  God should be
sure that all NPC nations have a minimum of 5 sectors to move to.
SHAR_EOF

newcount="`wc -c man.page | awk '{ print $1 }'`"
if test 4972 != $newcount
then
	echo "extracting $newcount characters"
	echo shar: error transmitting "'man.page'" '(should have been 4972 characters)' 
fi
fi
echo shar: extracting "'header.h'" '(5051)'
if test -f 'header.h'
then
	echo shar: will not over-write existing file "'header.h'"
else
	cat << \SHAR_EOF > 'header.h'
/*conquer is copyrighted 1986 by Ed Barlow.*/
/*  MODIFICATION OF THIS FILE IMPLIES THAT THE MODIFIER WILL ACCEPT
 	A LIMITED USE COPYRIGHT AS FOLLOWS:

	1) This software is copyrighted and protected by law.  The
		sole owner of this software, which hereafter is known as
		"conquer" is Edward M. Barlow, who hereby grants you a 
		personal, non-exclusive right to use this software.
 	2) conquer may not be redistributed in any form.  Any requests for 
		new software shall, for now, be the perogative of the author.
 	3) loss or damage caused by this software shall not be
		the responsibility of the author.
	4) Ed Barlow shall be notified of enhancements to this software via 
		electronic mail and, if there is no response, via US mail to:

			Ed Barlow
			562 Clubhouse Dr,
			Middletown NJ 07748

	5) you agree to use your best efforts to see that any user
		of conquer complies with the terms and conditions stated above.
	6) The above copyright notice will not be tampered with in any form.
*/

/* Special thanks to Brian Beuning and any others who helped me by
      making enhancements and bug reports */

/*--------------PLEASE MODIFY DATA FILE NAMES IN misc.c--------------------*/

/*-------MODIFICATION IS REQUIRED OF THE FOLLOWING 3 DEFINE STATEMENTS-----*/
#define OWNER	"Ed Barlow"	/*administrators name*/
#define LOGIN	"smile"		/*administrators login id !!!IMPORTANT!!!*/
                                /*only the administrative UID may update...*/
#define VERSION "version 2.0"     /*version number of the game*/

/* directory where default data files will be stored */
/* SO ONE GAME CAN EXIST IN DEFAULTDIR, OTHER GAMES IN OTHER DIRECTORIES */
#define DEFAULTDIR "/d7/c7913/smile/oldgame"

/*-------------------MODIFICATION IS OPTIONAL ON THE FOLLOWING-------------*/
#define SYSV 		/*comment this line out if on a BSD machine*/
#define PWATER 45 	/*percentage of water in the world*/
#define MAPX 48    	/*Number of X Sectors on Map (divisible by 8)*/
#define MAPY 48		/*Number of Y Sectors on Map (divisible by 8)*/
#define MAXNTN 28	/*number of nations (including player & npc ntns)*/
			/*but not including pirates...*/
#define MAXPTS    	30 	/*points to buy stuff in beginning with*/
#define MAXARM 		50	/*maximum number of armies per nation*/
#define MAXNAVY		16	/*maximum number of fleets per nation*/

/*THE FOLLOWING SHOULD BE COMMENTED OUT IF YOU DO NOT WANT THE FUNCTION*/
#define LZARD 		/*defined if lizard npc's exist at beginning*/
#define MONSTER 	/*defined if pirates/barbarians/nomads exist*/
#define NPC 		/*defined if non player country exists at beginning*/
#define CMOVE 		/*Defined if you wish the computer to move 
                          Player nations if they forget to move*/
#define BEEP		/*defined if you wish terminal to beep*/
#define HILIGHT		/*defined if your terminal supports inverse video*/
#define SYS5 		/*defined if SYS V. comment out if on a BSD system*/
/*#define SRANDOM*/	/*defined if srandom()/random() functions are
 			   resident on your system */
#define RANEVENT	/*defined if random events possible (not fully tested)*/
#define NORANDEVENTS 3  /*number of random events on average turn*/

/*---BELOW THIS POINT ARE PARAMETERS YOU MIGHT OPTIONALLY WISH TO CHANGE---*/

#define LANDSEE 2	/*how far you can see on land, by armies, by navies*/
#define NAVYSEE 1	/*making these numbers large takes CPU time*/
#define ARMYSEE 2

/*Below taxation rates are in thousand dollars (US 1985) per 100 humans per 
 *point of whatever -- ie 1 person in veg of 9 means produce $70x9=630K
 *thousand dollars */
#define TAXFOOD		100
#define TAXIRON		100
#define TAXGOLD		100
/*city and capital tax rates based on people only (no multipleier)*/
#define TAXCAP		1000
#define TAXCITY		750

#define SHIPMAINT 	1000	/*ship mainatinance cost*/
#define SOLDMAINT 	40	/*soldier mainatinance cost*/
#define DESCOST		300L	/*cost to redesignatie*/
				/*this is also the iron cost for cities*/
#define FORTCOST	1000	/*cost to build a fort point*/
#define ENLISTCOST 	90	/*cost to enlist one troop*/
#define WARSHPCOST 	10000	/*cost to build one warship*/
#define MERSHPCOST 	20000	/*cost to build one merchant*/
#define SHIPHOLD  	300	/*number of humans a merchant can hold*/
#define CITYLIMIT 	8	/*% of ntns people in sector before => city*/
#define MILRATIO 	5	/*ratio mil:civ for non player countries*/
#define MILINCAP  	5	/*ratio (mil in cap):mil for NPCs*/
#define JWL_MGK		100000L	/*jewels needed to use magic*/
#define BRIBE		100000L	/*amount of gold to bribe one level*/
#define IRONORE		7	/*iron per soldier needed for +1% weapons*/


/*--------------------DO NOT TO ALTER BELOW THIS LINE-----------------------*/

#define MAXX		(MAPX / 8)	/*Number of X areas on map*/
#define MAXY 		(MAPY / 8)	/*Number of Y areas on map*/ 
#define NUMAREAS	(MAXX * MAXY)	/*total # areas, MAXX*MAXY*/
#define NTOTAL		(MAXNTN +4) /*MAXNTN+4*/
#define NLIZARD		(MAXNTN )   /*MAXNTN+0*/
#define NNOMAD		(MAXNTN +1) /*MAXNTN+1*/
#define NBARBARIAN 	(MAXNTN +2) /*MAXNTN+2*/
#define NPIRATE		(MAXNTN +3) /*MAXNTN+3*/
SHAR_EOF

newcount="`wc -c header.h | awk '{ print $1 }'`"
if test 5051 != $newcount
then
	echo "extracting $newcount characters"
	echo shar: error transmitting "'header.h'" '(should have been 5051 characters)' 
fi
fi
echo shar: extracting "'update.c'" '(16597)'
if test -f 'update.c'
then
	echo shar: will not over-write existing file "'update.c'"
else
	cat << \SHAR_EOF > 'update.c'
/*conquer is copyrighted 1986 by Ed Barlow.
 *  I spent a long time writing this code & I hope that you respect this.  
 *  I give permission to alter the code, but not to copy or redistribute
 *  it without my explicit permission.  If you alter the code, 
 *  please document changes and send me a copy, so all can have it.  
 *  This code, to the best of my knowledge works well,  but it is my first
 *  'C' program and should be treated as such.  I disclaim any
 *  responsibility for the codes actions (use at your own risk).  I guess
 *  I am saying "Happy gaming", and am trying not to get sued in the process.
 *                                                Ed
 */

#include "header.h"
#include "data.h"
#include <ctype.h>

FILE *fnews, *fopen();

extern short country;
int attr[MAPX][MAPY];     /*sector attactiveness*/
extern short movecost[MAPX][MAPY];

/*update nation file*/
update()
{
	register struct s_sector	*sptr;
	register struct nation		*nptr;
	FILE *fpmsg;
	register int i, j;
	register int x,y;
	int moved,armynum,nvynum,done,finis=0, number=0;
	int food,iron;
	char command[80];
	int execed[MAXNTN];
	long	city_pop, cap_pop;

	if ((fnews=fopen(newsfile,"w"))==NULL) {
		printf("error opening news file\n");
		exit(1);
	}

	/*run each nation in a random order*/
	country=0;
	execute();
	for(i=0;i<MAXNTN;i++) execed[i]=0;
	system("date");
	while(finis==0){
		/*get random active nation*/
		country=(rand()%(MAXNTN-1))+1;
		if(ntn[country].active <= 0)
			continue;

		done=0;
		number=0;
		/*Find the next unupdated nation*/
		while(done==0){
			if((ntn[country].active>0)&&(execed[country]==0)) {
				done=1;
				execed[country]=1;
			}
			else {
				country++;
				number++;
				if(number>MAXNTN) {
					finis=1;
					done=1;
				}
				else if(country>=MAXNTN) country=1;
			}
		}

		if(finis==1)
			continue;

		printf("updating nation number %d -> %s\n",country,ntn[country].name);

		/*if execute is 0 and PC nation then they did not move*/
		if((execute()==0)&&(ntn[country].active==1)){
			printf("\tnation %s did not move\n",ntn[country].name);
#ifdef CMOVE
			printf("\tthe computer will move for %s\n",ntn[country].name);
			fprintf(fnews,"1.\tthe computer will move for %s\n",ntn[country].name);
			nationrun();
#endif
		}
#ifdef NPC
		/*run npc nations*/
		if(ntn[country].active>=2) {
			nationrun();
			/*do magic*/
			if(magic(country,MA_MONST)==1) {
				if(x=takeover(5,0)==1)
				printf("SUCCESSFUL TAKEOVER OF %d",x);
			} else if(magic(country,AV_MONST)==1) {
				if(x=takeover(3,0)==1)
				printf("SUCCESSFUL TAKEOVER OF %d",x);
			} else if(magic(country,MI_MONST)==1){
				if(x=takeover(1,0)==1)
				printf("SUCCESSFUL TAKEOVER OF %d",x);
			}
		}
#endif

		/*update movement array*/
		updmove( ntn[country].race );

		/*THIS IS WHERE YOU ZERO THE ATTR MATRIX*/
		/*calculate sector attractiveness*/
		for(x=0;x<MAPX;x++) for(y=0;y<MAPY;y++) {
			sptr = &sct[x][y];
			if((sptr->owner==country)
			&&(isdigit(sptr->vegetation)!=0)){
				attr[x][y]=attract(x,y,ntn[country].race);
			}
			else if(((magic(country,DERVISH)==1)
			||(magic(country,DESTROYER)==1))
			&&((sptr->vegetation==ICE)
			||(sptr->vegetation==DESERT))) {
				attr[x][y]=36;
			}
			else attr[x][y]=0;
		}

		/*if near capital add to attr*/
		for(x=ntn[country].capx-2;x<=ntn[country].capx+2;x++)
			for(y=ntn[country].capy-2;y<=ntn[country].capy+2;y++)
				if(attr[x][y]>0) attr[x][y]+=20;

/*MOVE CIVILIANS based on the ratio of attractivenesses
	 *
	 * EQUILIBRIUM(1) = A1/(A1+A2) * (P1+P2)
	 * EQUILIBRIUM(2) = A2/(A1+A2) * (P1+P2)
	 * MOVE 1/5 of way to equilibrium each turn
	 * DELTA(1) = (EQUILIBRIUM(1)-P1)/5 = (A1P2-P1A2)/5(A1+A2)
	 * DELTA(2) = (EQUILIBRIUM(2)-P2)/5 = (A2P1-P2A1)/5(A1+A2) = -DELTA(1)
	 * ij is refered to as 1, xy as 2
	 * NOTE AM ADDING 1 to divisor to prevent floating exception errors
	 */
		for(x=0; x<MAPX; x++ ) {
			for(y=0; y<MAPY; y++) {
				sptr = &sct[x][y];
				if( sptr->owner != country )
					continue;
				if( sptr->people == 0 )
					continue;

				for(i=x-2;i<=x+2;i++) {
					if( i < 0 || i >= MAPX  )
						continue;

					for(j=y-2;j<=y+2;j++) {
						if( j < 0 || j >= MAPY )
							continue;
						if( sct[i][j].owner != country)
							continue;
					moved=(sptr->people*attr[i][j]-sct[i][j].people*attr[x][y])/(1+5*(attr[i][j]+attr[x][y]));
#if 0
if( country == 18 ) {
	printf( "moving %d people from (%d,%d) a = %d to (%d,%d) a = %d\n",
		moved, x, y, attr[x][y], i, j, attr[i][j] );
}
#endif
						if( moved <= 0 )
							continue;

						sct[i][j].people += moved;
						sptr->people -= moved;
					} /* for */
				} /* for */
			} /* for */
		} /* for */
	} /* while */

	/* run npc nations */
#ifdef LZARD
	puts("updating lizards\n ");
	country = NLIZARD;
	execute();
	armynum=0;
	/*move to lizard castle*/
	for(armynum=0;armynum<MAXARM;armynum++) if(ASTAT!=GARRISON){
		x = AXLOC;
		y = AYLOC;
		for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++){
			if((i>=0)&&(j>=0)&&(i<MAPX)&&(j<MAPY)
			&&(sct[i][j].designation==DCASTLE)){
				x = i;
				y = j;
				break;
			}
		}
		for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++){
			if((i>=0)&&(j>=0)&&(i<MAPX)&&(j<MAPY)
			&&(sct[i][j].altitude!=WATER) 
			&&(sct[i][j].altitude!=PEAK) 
			&&(sct[i][j].owner != NLIZARD) 
			&&(rand()%2==0)){
				x = i;
				y = j;
				break;
			}
		}
		AXLOC = x;
		AYLOC = y;
	}
#endif

#ifdef MONSTER
	monster();
#endif

	/*run random events */
#ifdef RANEVENT
	randomevent(); 
#endif
	/*run combat*/
	combat();

	fprintf(fnews,"3\tNEWS ON WHAT SECTORS HAVE BEEN CAPTURED");
	/*look for any areas where armies alone in sector*/
	prep();
	for(country=1;country<NTOTAL;country++) if(ntn[country].active!=0){
		for(armynum=0;armynum<MAXARM;armynum++) if(ASOLD>75){
			sptr = &sct[AXLOC][AYLOC];
			if(sptr->owner==0){
				sptr->owner=country;
			}
			else if((sptr->owner!=country)
			&&(ntn[country].dstatus[sptr->owner]>=WAR)
			&&(occ[AXLOC][AYLOC]==country)){

				if((sptr->owner!=0)
				&&(ntn[sptr->owner].race!=ntn[country].race)) 
					flee(AXLOC,AYLOC,1);
				fprintf(fnews,"\n3.\tarea %d,%d captured by %s from %s",AXLOC,AYLOC,ntn[country].name,ntn[sptr->owner].name);
				sptr->owner=country;
			}
		}
	}
	fprintf(fnews,"\n1\tIMPORTANT WORLD NEWS\n");

	for(country=1;country<MAXNTN;country++) 
		if((ntn[country].active>=2)
		&&((ntn[country].tciv==0)
		||(sct[ntn[country].capx][ntn[country].capy].owner!=country)))
			destroy();

	/*zero out all recalculated values*/
	for(i=0;i<MAXNTN;i++){
		ntn[i].tsctrs=0;
		ntn[i].tships=0;
		ntn[i].tciv=0;
		ntn[i].tmil=0;
	}

	/*for whole map, update one sector at a time, owned sectors only*/
	printf("\nupdating all sectors\n");
	for(x=0;x<MAPX;x++) for(y=0;y<MAPY;y++) {
		sptr = &sct[x][y];
		if(sptr->owner==0)
			continue;
		nptr = &ntn[ sptr->owner ];

		/*check all adjacent sectors and decide if met*/
		for(i=x-1;i<=x+1;i++) for(j=y-2;j<=y+2;j++) {
			if(i>=0&&i<MAPX&&j>=0&&j<MAPY&&(sct[i][j].owner!=0)) {
				if(sptr->owner!=sct[i][j].owner) {
					if(nptr->dstatus[sct[i][j].owner]==UNMET) newdip(sptr->owner,sct[i][j].owner);
					if(ntn[sct[i][j].owner].dstatus[sptr->owner]==UNMET) newdip(sct[i][j].owner,sptr->owner);
				}
			}
		}

		/*update nation file for owner*/
		nptr->tsctrs++;
		nptr->tciv += sptr->people;

		/*grow populations*/
		if(sptr->people<100) sptr->people+=sptr->people/10;
		else sptr->people+=(nptr->repro*sptr->people)/100;

		/*PRODUCE*/
		/*increase tmin based on mined stuff...*/
		if(sptr->designation==DMINE) {
			iron=sptr->iron*sptr->people;
			if(magic(sptr->owner,MINER)==1) iron*=2;
			if(magic(sptr->owner,STEEL)==1) iron*=2;
			nptr->tiron += iron;
			nptr->tgold += iron*TAXIRON/100;
		}
		/*harvest food*/
		else if(sptr->designation==DFARM) {
			food= todigit(sptr->vegetation)*sptr->people;
			nptr->tfood += food;
			nptr->tgold += food*TAXFOOD/100;
		}
		/*gold mines produce gold*/
		else if(sptr->designation==DGOLDMINE) {
			if(magic(sptr->owner,MINER)==1){
				nptr->tgold +=  2*sptr->gold * sptr->people * TAXGOLD/100;
				nptr->jewels += 2*sptr->gold * sptr->people;
			}
			else {
				nptr->tgold += sptr->gold * sptr->people * TAXGOLD/100;
				nptr->jewels += sptr->gold * sptr->people;
			}
		}
		else if(sptr->designation==DCAPITOL) {
			if((x!=nptr->capx)&&(y!=nptr->capy)) {
				cap_pop = 0;
				city_pop = 3 * sptr->people;
				sptr->designation = DCITY;
			} else {
				city_pop = 0;
				cap_pop = sptr->people;
			}

			if( magic(sptr->owner, ARCHITECT ) ) {
				city_pop *= 2;
				cap_pop *= 2;
			}

			nptr->tgold += (long) city_pop * TAXCITY / 100;
			nptr->tgold += (long) cap_pop * TAXCAP / 100;
		}
		else if(sptr->designation==DCITY) {
			city_pop = sptr->people;
			if( magic(sptr->owner, ARCHITECT ) )
				city_pop *= 2;
			nptr->tgold += (long) city_pop * TAXCITY / 100;
		}
		else if(((magic(country,DERVISH)==1)
		||(magic(country,DESTROYER)==1))
		&&((sptr->vegetation==ICE)
		||(sptr->vegetation==DESERT))
		&&(sptr->people>0)) {
			food=6*sptr->people;
			nptr->tfood += food;
			nptr->tgold += food*TAXFOOD/100;
		}
	}

	/*reset military stuff*/
	printf("updating armies and navies\n");
	for(country=1;country<NTOTAL;country++) if(ntn[country].active!=0){
		for(armynum=0;armynum<MAXARM;armynum++){
			if(ASOLD>0) {
				ntn[country].tmil+=ASOLD;
				if(magic(country,VAMPIRE)!=1)
					ntn[country].tgold-=ASOLD*SOLDMAINT;

				/*add movement to all armies */
				switch(ASTAT) {
				case MARCH:
					AMOVE=2*ntn[country].maxmove;
					break;
				case SCOUT:
				case ATTACK:
				case DEFEND:
					AMOVE=ntn[country].maxmove;
					break;
				case GARRISON:
					AMOVE=0;
					break;
				default:
					ASTAT=DEFEND;
					AMOVE=ntn[country].maxmove;
				}
			}
		}
		/*add to movement of fleets*/
		for(nvynum=0;nvynum<MAXNAVY;nvynum++) {
			/*update sea sectors*/
			if( NMER + NWAR > 0 ) {
				if(sct[NXLOC][NYLOC].altitude==WATER) {
#if 0
/*
 *	Storms should stay around and slowly move
 *	around the world.
 */
					/*all ships sunk on 0 (d12)*/
					/*pirates never are sunk (implicitly)*/
					if( country != NPIRATE && rand() % 12 == 0 ) {
						x = NXLOC;
						y = NYLOC;
						fprintf(fnews,"3.\tstorm in %d,%d\n",x,y);
						NWAR=0;
						NMER=0;
					}
#endif
				}
				NMOVE = 3 * ntn[country].maxmove;
				ntn[country].tships += NWAR + NMER;
				ntn[country].tgold -= (NWAR + NMER) * SHIPMAINT;
			} else {
				NWAR=0;
				NMER=0;
			}
		} /* for */
	}

	/*commodities: feed the people, too much gold?, validate iron*/
	fprintf(fnews,"2\tSTATUS OF THE WORLDS FOOD SUPPLY\n");
	for(country=1;country<MAXNTN;country++) if(ntn[country].active!=0){
		/*soldiers eat  2*/
		ntn[country].tfood-=ntn[country].tmil*2;
		/*civilians eat 1*/
		ntn[country].tfood-=ntn[country].tciv;

		/*starve people*/
		if(ntn[country].tfood<0) for(x=0;x<MAPX;x++) for(y=0;y<MAPY;y++) {
			sptr = &sct[x][y];
			if((sptr->owner==country)
			&&((sptr->designation==DCITY)
			||(sptr->designation==DCAPITOL))
			&&(ntn[country].tfood<0)){
				/*lose one person in city per three food*/
				/*maximum of 1/3 people in city lost*/
				if(sptr->people < ntn[country].tfood){
					sptr->people+=ntn[country].tfood/3;
					ntn[country].tfood=0;
				}
				else {
					ntn[country].tfood+=sptr->people;
					city_pop = sptr->people/3;
					sptr->people -= city_pop;
				}
				fprintf(fnews,"2.\tfamine hits city at %d,%d in %s.\n",x,y,ntn[country].name);
				sprintf(command,"%s%d",msgfile,country);
				if(ntn[country].active==1)
				if((fpmsg=fopen(command,"a+"))==NULL) {
				printf("error opening %s\n",command);
				} else {
				fprintf(fpmsg,"%s notice from program\n%s\n",ntn[country].name,ntn[country].name);
				fprintf(fpmsg,"%s famine hits city at %d,%d in %s.-> %d people reduced by %d\n%s\n",ntn[country].name,x,y,ntn[country].name,sptr->people,city_pop,ntn[country].name);
				fprintf(fpmsg,"END\n");
				fclose(fpmsg);
				}
			}
		}
		/*this state can occur if few people live in cities*/
		if(ntn[country].tfood<0) {
			ntn[country].tfood=0;
		}
		else if(ntn[country].tfood>FOODTHRESH*ntn[country].tciv) {
			ntn[country].tgold+=ntn[country].tfood-FOODTHRESH*ntn[country].tciv;
			ntn[country].tfood=FOODTHRESH*ntn[country].tciv;
		}

		if(ntn[country].tgold>GOLDTHRESH*ntn[country].jewels){
			x=ntn[country].tgold-GOLDTHRESH*ntn[country].jewels;
			ntn[country].jewels += x/GOLDTHRESH;
			ntn[country].tgold  -= x;
		}
		else if(ntn[country].tgold > JEWELTHRESH * ntn[country].jewels){
			fprintf(fnews,"3.\tTAX REVOLT IN NATION %s\n",ntn[country].name);
		}
	}

	fclose(fnews);
	score();

	sprintf(command,"rm %s*",exefile);
	printf("%s\n",command);
	system(command);

	sprintf( command, "sort -n -o %s %s", newsfile, newsfile );
	printf("%s\n",command);
	system(command);
  
}

attract(x,y,race)
{
	register struct s_sector	*sptr = &sct[x][y];
	int	Attr = 1;

	if((sptr->designation==DGOLDMINE)&&(sptr->gold>3)){
		if(ntn[sptr->owner].jewels<=ntn[sptr->owner].tgold*GOLDTHRESH) 
			Attr+=120;
		else if(sptr->gold>5) Attr+=120;
		else Attr+=75;
	}
	else if((sptr->designation==DFARM)&&(todigit(sptr->vegetation)>6)){
		if(ntn[sptr->owner].tfood<=ntn[sptr->owner].tciv*FOODTHRESH) 
			Attr+=300;
		else if(todigit(sptr->vegetation)==9) Attr+=100;
		else Attr+=40;
	}
	else if(sptr->designation==DCAPITOL) Attr+=200;
	else if(sptr->designation==DCITY) Attr+=125;
	else if((sptr->designation==DMINE)&&(sptr->iron>3)) {
		if(ntn[sptr->owner].tiron<=ntn[sptr->owner].tciv)
			Attr+=120;
		else if(sptr->iron>5) Attr+=100;
		else Attr+=50;
	}

	switch(race){
	case DWARF:
		if((sptr->designation==DGOLDMINE)&&(sptr->gold>=5))
			Attr+=100;
		else if((sptr->designation==DMINE)&&(sptr->iron>=5))
			Attr+=100;

		if(sptr->altitude==MOUNTAIN) Attr+=40;
		else if(sptr->altitude==HILL) Attr+=20;
		else if(sptr->altitude==CLEAR) Attr+=0;
		else Attr=0;
		break;
	case ELF:
		if(sptr->vegetation==JUNGLE) Attr+=40;
		else if(sptr->vegetation==WOOD) Attr+=90;
		else if(sptr->vegetation==FORREST) Attr+=70;

		if((sptr->designation==DGOLDMINE)&&(sptr->gold>=5))
			Attr+=75;

		if(sptr->altitude==MOUNTAIN) Attr-=20;
		else if(sptr->altitude==HILL) Attr-=10;
		else if(sptr->altitude==CLEAR) Attr+=0;
		else Attr=0;
		break;
	case HUMAN:
		Attr+=todigit(sptr->vegetation)*4;

		if((sptr->designation==DGOLDMINE)&&(sptr->gold>=5))
			Attr+=75;
		else if((sptr->designation==DMINE)&&(sptr->iron>=5))
			Attr+=75;
		else if((sptr->designation==DFARM)&&(todigit(sptr->vegetation)>=6))
			Attr+=55;
		else if(sptr->designation==DCAPITOL) Attr+=70;
		else if(sptr->designation==DCITY) Attr+=50;

		if(sptr->altitude==MOUNTAIN) Attr-=10;
		else if(sptr->altitude==HILL) Attr+=00;
		else if(sptr->altitude==CLEAR) Attr+=10;
		else Attr=0;
		break;
	case ORC:
		if(sptr->designation==DCAPITOL) Attr+=120;
		else if(sptr->designation==DCITY) Attr+=75;
		else if((sptr->designation==DGOLDMINE)&&(sptr->gold>=5))
			Attr+=75;
		else if((sptr->designation==DMINE)&&(sptr->iron>=5))
			Attr+=75;

		if(sptr->altitude==MOUNTAIN) Attr+=20;
		else if(sptr->altitude==HILL) Attr+=10;
		else if(sptr->altitude==CLEAR) Attr+=0;
		else Attr=0;
		break;
	default:
		break;
	}
	if((Attr<0)||(movecost[x][y]<0)) Attr=0;
	return(Attr);
}

todigit(character)
register int	character;
{
	if( character >= '0' && character <= '9' )
		return( character - '0' );

	return( 0 );
}

armymove(armynum)
{
	int		sum, place;
	register int	x, y;

	sum=0;
	for(x=AXLOC-2;x<=AXLOC+2;x++)
		for(y=AYLOC-2;y<=AYLOC+2;y++)
			if(ONMAP) sum+=attr[x][y];

	if(sum==0) {
		AXLOC=ntn[country].capx;
		AYLOC=ntn[country].capy;
	} else {
		place=rand()%sum;
		for(x=AXLOC-2;x<=AXLOC+2;x++) for(y=AYLOC-2;y<=AYLOC+2;y++) {
			if( x < 0 || x >= MAPX || y < 0 || y >= MAPY )
				continue;

			place -= attr[x][y];
			if( (place < 0 )
			&& movecost[x][y]>=1 
			&& movecost[x][y]<=AMOVE 
		        &&(land_reachp(AXLOC,AYLOC,x,y,AMOVE,country))){
				AXLOC=x;
				AYLOC=y;
				if(sct[x][y].owner==0)
					sct[x][y].owner=country;
				return;
			} /* if */
		} /* for for */

		/*do again - have this block if lots of bad terrain*/
		/*what could happen is that it won't find a move first time*/
		for(x=AXLOC-2;x<=AXLOC+2;x++) for(y=AYLOC-2;y<=AYLOC+2;y++) {
			if( x < 0 || x >= MAPX || y < 0 || y >= MAPY )
				continue;

			place -= attr[x][y];
			if( (place < 0 )
			&& movecost[x][y]>=1 
			&& movecost[x][y]<=AMOVE 
		        &&(land_reachp(AXLOC,AYLOC,x,y,AMOVE,country))){
				AXLOC=x;
				AYLOC=y;
				if(sct[x][y].owner==0)
					sct[x][y].owner=country;
				return;
			} /* if */
		} /* for for */
	} /* if */
}

score()
{
  	int x;
  	printf("\nupdating scores for all nations\n");
  	for(x=1;x<MAXNTN;x++) if(ntn[x].active!=0) ntn[x].score += score_one(x);
}
SHAR_EOF

newcount="`wc -c update.c | awk '{ print $1 }'`"
if test 16597 != $newcount
then
	echo "extracting $newcount characters"
	echo shar: error transmitting "'update.c'" '(should have been 16597 characters)' 
fi
fi
echo shar: extracting "'commands.c'" '(18869)'
if test -f 'commands.c'
then
	echo shar: will over-write existing file "'commands.c'"
fi
cat << \SHAR_EOF > 'commands.c'
/*conquer is copyrighted 1986 by Ed Barlow.
 *  I spent a long time writing this code & I hope that you respect this.  
 *  I give permission to alter the code, but not to copy or redistribute
 *  it without my explicit permission.  If you alter the code, 
 *  please document changes and send me a copy, so all can have it.  
 *  This code, to the best of my knowledge works well,  but it is my first
 *  'C' program and should be treated as such.  I disclaim any
 *  responsibility for the codes actions (use at your own risk).  I guess
 *  I am saying "Happy gaming", and am trying not to get sued in the process.
 *                                                Ed
 */

/*	commands.c		*/

/*include files*/
#include "header.h"
#include "data.h"
#include <ctype.h>

extern short xcurs,ycurs,xoffset,yoffset;
extern FILE *fexe;		/*execute file pointer*/
extern short country;
extern short selector;
extern short pager;
extern short xcurs,ycurs,xoffset,yoffset;

/*change current hex designation*/
redesignate()
{
	char newdes;
	short x,y;

	if(country==0){
		mvaddstr(LINES-1,0,"SUPER USER: CHANGE (v)egitation, (e)levation, (d)esig, (o)wner");
		refresh();
		switch(getch()){
		case 'e':
			/*simple contour map definitions*/
			mvprintw(LINES-2,7,"ELEVATIONS: change to %c, %c, %c, %c or %c?",WATER,PEAK,MOUNTAIN,HILL,CLEAR);
			refresh();
			newdes=getch();
			if(newdes!=WATER&&newdes!=PEAK&&newdes!=MOUNTAIN
			&&newdes!=HILL&&newdes!=CLEAR) return;
			sct[XREAL][YREAL].altitude=newdes;
			if((newdes==PEAK)||(newdes==WATER)) {
				sct[XREAL][YREAL].owner=0;
				sct[XREAL][YREAL].people=0;
				sct[XREAL][YREAL].fortress=0;
			}
			/*will fall through as must change vegetation*/
		case 'v':
			/*vegetation types*/
			mvprintw(LINES-2,7,"VEGITATIONS: change to %c, %c, %c, %c, %c, %c, %c, %c, %c, %c, %c or %c?",
			VOLCANO,DESERT,WASTE,BARREN,LT_VEG,
			GOOD,WOOD,FORREST,JUNGLE,SWAMP,ICE,NONE);
			refresh();
			newdes=getch();
			if(newdes!=VOLCANO
			&&newdes!=DESERT&&newdes!=WASTE
			&&newdes!=BARREN&&newdes!=LT_VEG
			&&newdes!=NONE&&newdes!=GOOD
			&&newdes!=WOOD&&newdes!=FORREST&&newdes!=JUNGLE
			&&newdes!=SWAMP&&newdes!=ICE) return;
			sct[XREAL][YREAL].vegetation=newdes;
			if(isdigit(sct[XREAL][YREAL].vegetation)==0) 
				sct[XREAL][YREAL].designation=newdes;
			return;
		case 'o':
			mvprintw(LINES-2,7,"what nation owner:");
			refresh();
			x = get_number();
			sct[XREAL][YREAL].owner=x;
			return;
		}
	}
	if((country!=0)&&(sct[XREAL][YREAL].owner!=country)) {
		mvprintw(LINES-1,0,"You do not own: hit any key");
		refresh();
		getch();
		return;
	}
	mvprintw(LINES-1,0,"hit space to not redesignate anything");
	clrtoeol();
	mvprintw(LINES-2,7,"$%d: redesignate to %c, %c, %c, %c or %c?",DESCOST,DMINE,DGOLDMINE,DFARM,DCITY,DCAPITOL);
	clrtoeol();
	refresh();
	/*read answer*/
	newdes=getch();

	if(newdes!=DMINE&&newdes!=DGOLDMINE&&newdes!=DFARM&&newdes!=DCITY&&newdes!=DCAPITOL) return;

	if((SOWN==country)||(country==0)) {
		if((isdigit(sct[XREAL][YREAL].vegetation)!=0)||(country==0)) {
			if(((newdes!=DCITY)&&(newdes!=DCAPITOL))||(country==0)) {
				/*decrement treasury*/
				sct[XREAL][YREAL].designation=newdes;
				if(country==0) {
					country=sct[XREAL][YREAL].owner;
					SADJDES;
					country=0;
				}
				else {
					SADJDES;
					ntn[country].tgold-=DESCOST;
				}
			}
			else if((newdes==DCAPITOL)
			&&(sct[XREAL][YREAL].designation==DCITY)){

				ntn[country].tgold-=5*DESCOST;
				ntn[country].tiron-=DESCOST;
				x=ntn[country].capx;
				y=ntn[country].capy;
				sct[x][y].designation=DCITY;
				if(country==0) {
					country=sct[x][y].owner;
					SADJDES2;
					country=0;
				}
				else SADJDES2;
				sct[XREAL][YREAL].designation=newdes;
				ntn[country].capx=XREAL;
				ntn[country].capy=YREAL;
				if(country==0) {
					country=sct[XREAL][YREAL].owner;
					SADJDES;
					country=0;
				}
				else SADJDES;
			}
			else if((newdes==DCAPITOL)
			&&(sct[XREAL][YREAL].designation!=DCITY)){
				mvprintw(LINES-1,0,"Sector must be a city: hit any key  ");
				refresh();
				getch();
			}
			else if((ntn[country].tiron>DESCOST)
			&&(newdes==DCITY)){
				if(sct[XREAL][YREAL].people>=500){
					ntn[country].tgold-=5*DESCOST;
					ntn[country].tiron-=DESCOST;
					sct[XREAL][YREAL].designation=newdes;
					if(country==0) {
						country=sct[XREAL][YREAL].owner;
						SADJDES;
						country=0;
					}
					else SADJDES;
				}
				else {
				mvprintw(LINES-1,0,"Need 500 people to build to city");
				refresh();
				getch();
				}
			}
			else {
			mvprintw(LINES-1,0,"Not enough iron: hit any key  ");
			refresh();
			getch();
			}
		}
		else {
		mvprintw(LINES-1,0,"vegetation unlivable: hit any key  ");
		refresh();
		getch();
		}
	}
	else {
	mvprintw(LINES-1,0,"Sorry, you don't own sector: hit any key ");
	refresh();
	getch();
	}
}

/*build fort or ship-type */
construct()
{
	int nearsea;
	long cost;
	int armbonus;
	int x,y;
	short nvynum=0;
	short mnumber,wnumber;
	short isgod=0;
	char type;

	if(country==0){
		isgod=1;
		country=sct[XREAL][YREAL].owner;
	}

	if(sct[XREAL][YREAL].owner!=country) {
		mvaddstr(LINES-1,0,"You do not own: hit any key");
		refresh();
		getch();
		if(isgod==1) country=0;
		return;
	}

	if((isgod == 0) && (ntn[country].tgold < 0 )) {
		mvaddstr(LINES-1,0,"You are broke: hit any key");
		refresh();
		getch();
		return;
	}

	if((sct[XREAL][YREAL].designation==DCITY)
	||(sct[XREAL][YREAL].designation==DCAPITOL)) {
		/*calculate cost for fort*/
		cost=FORTCOST;
		if(isgod==1) cost=0;
		else for(x=1;x<=sct[XREAL][YREAL].fortress;x++) 
			cost*=2;

		if(sct[XREAL][YREAL].designation==DCITY) armbonus=8;
		else if(sct[XREAL][YREAL].designation==DCAPITOL) armbonus=10;
		if(magic(country,ARCHITECT)==1) armbonus*=2;

		move(LINES-1,0);
		clrtoeol();
		mvprintw(LINES-2,0,"Construct <f>ortifications (+%d%% - %ld gold) or <s>hips?:",armbonus,cost);
		clrtoeol();
		refresh();
		type=getch();
	}
	else {
		mvprintw(LINES-2,0,"Must construct in city or capitol--hit any key");
		clrtoeol();
		refresh();
		getch();
		return;
	}

	/* construct ships*/
	if (type=='s') {
		/*check if next to sea*/
		nearsea=0;
		for(x=XREAL-1;x<=XREAL+1;x++)
			for(y=YREAL-1;y<=YREAL+1;y++)
				if(sct[x][y].altitude==WATER) nearsea=1;

		if (nearsea==0) {
			mvprintw(LINES-2,0,"not in a harbor: hit space");
			clrtoeol();
			refresh();
			getch();
			if(isgod==1) country=0;
			return;
		}

		mvprintw(LINES-2,0,"build how many merchant ships:");
		clrtoeol();
		refresh();
		mnumber = get_number();
		mvprintw(LINES-2,0,"build how many warships:");
		clrtoeol();
		refresh();
		wnumber = get_number();
		/*sanity checks*/
		if((wnumber>100)||(wnumber<0)) wnumber=0;
		if((mnumber>100)||(mnumber<0)) mnumber=0;
		mvprintw(LINES-2,0,"constructing %hd warships and %hd merchant",wnumber,mnumber);
		clrtoeol();

		if((nvynum=getselunit()-MAXARM)>=0){
			if(nvynum>=MAXNAVY){
				mvaddstr(LINES-1,0,"INVALID NAVY--hit any key");
				clrtoeol();
				refresh();
				getch();
				if(isgod==1) country=0;
				return;
			}
			mvaddstr(LINES-1,0,"Do you wish to raise a new fleet (y or n)");
			clrtoeol();
			refresh();
			if(getch()=='y') nvynum=(-1);
		}

		if(nvynum<0) {
			mvprintw(LINES-2,0,"raising a new fleet");
			clrtoeol();
			refresh();

			nvynum=0;
			x=(-1);
			while((x==(-1))&&(nvynum<MAXNAVY)) {
				if(NWAR+NMER<=0) {
					x=nvynum;
					NWAR=0;
					NMER=0;
					NADJSHP;
				}
				nvynum++;
			}
			nvynum=x;
		}

		if(nvynum==(-1)){
			mvaddstr(LINES-1,0,"NO FREE NAVIES--hit any key");
			clrtoeol();
			refresh();
			getch();
			if(isgod==1) country=0;
			return;
		}

		mvprintw(LINES-3,0,"Raising fleet %d",nvynum);
		if((nvynum>=0)&&(nvynum<MAXNAVY)) {
			NXLOC=XREAL;
			NYLOC=YREAL;
			NWAR+=wnumber;
			NMER+=mnumber;
			if(isgod==0) {
			ntn[country].tgold -= (long) wnumber*WARSHPCOST;
			ntn[country].tgold -= (long) mnumber*MERSHPCOST;
			}
			NMOVE=0;
			NADJSHP;
			NADJLOC;
			NADJMOV;
		}
		else mvprintw(LINES-2,0,"ERROR!!!!!!!!!!!!!");

		refresh();
		makebottom();
	}
	/* construct fortification points*/
	else if(type=='f'){
		if(sct[XREAL][YREAL].people>=500) {

			mvprintw(LINES-1,25,"you build %d%% fort points for %ld gold",armbonus,cost);
			ntn[country].tgold-=cost;
			sct[XREAL][YREAL].fortress++;
			INCFORT;
		}
		else mvprintw(LINES-1,25,"need 500 people");
	}
	else mvprintw(LINES-1,0,"error");

	if(isgod==1) country=0;
	refresh();
}

/*DRAFT IF IN A CITY*/
draft()
{
	short armynum;
	int men=0;
	short army=(-1);
	short isgod=0;
	if(country==0) {
		isgod=1;
		country=sct[XREAL][YREAL].owner;
	}
	else if(sct[XREAL][YREAL].owner!=country) {
		mvprintw(LINES-1,0,"You do not own: hit any key");
		refresh();
		getch();
		return;
	}

	if((sct[XREAL][YREAL].designation!=DCITY)
	&&(sct[XREAL][YREAL].designation!=DCAPITOL)) {
		mvprintw(LINES-1,0,"must raise in cities: hit any key");
		refresh();
		getch();
		if(isgod==1) country=0;
		return;
	}

	if((sct[XREAL][YREAL].designation==DCITY)
	&&(sct[XREAL][YREAL].people*(2*CITYLIMIT+(ntn[country].tsctrs/2))<ntn[country].tciv)){
		mvprintw(LINES-1,0,"need %d people in city: hit any key",ntn[country].tciv/(2*CITYLIMIT+(ntn[country].tsctrs/2)));
		refresh();
		getch();
		if(isgod==1) country=0;
		return;
	}

	if(ntn[country].tgold <= 0){
		mvprintw(LINES-1,0,"you dont have any gold: hit any key");
		refresh();
		getch();
		if(isgod==1) country=0;
		return;
	}

	/*raise an untrained army */
	mvprintw(LINES-3,0,"how many men do you wish to raise:");
	clrtoeol();
	refresh();
	men = get_number();
	if(men<=0) return;
	if(men > sct[XREAL][YREAL].people/4) {
		mvprintw(LINES-2,0,"can only raise %d soldiers",sct[XREAL][YREAL].people/4);
		clrtoeol();
		refresh();
		men = sct[XREAL][YREAL].people/4;
	}
	if(men >  (int) (ntn[country].tiron/10)) {
		mvprintw(LINES-2,0,"aborting--only enough iron for %d troops",ntn[country].tiron/10);
		clrtoeol();
		refresh();
		getch();
		if(isgod==1) country=0;
		return;
	}
	else {
		move(LINES-2,0);
		clrtoeol();
		ntn[country].tiron -= 10*men;
	}

	/*count is order of that army in sector*/
	/*armynum is number of that army*/
	if((armynum=getselunit())>=0){
		if(armynum>=MAXARM) {
			army = -1;
		} else {
			mvaddstr(LINES-1,0,"Do you wish to raise a new army:");
			clrtoeol();
			refresh();
			if(getch()!='y') army=armynum;
			else army= -1;
		}
	}
	if(army==(-1)) {
		mvprintw(LINES-2,0,"raising a new army");
		clrtoeol();
		refresh();
		armynum=0;
		while((army==(-1))&&(armynum<MAXARM)) {
			if(ASOLD<=0) {
				army=armynum;
				ASOLD=0;
				ASTAT=DEFEND; /* set new armies to DEFEND */
				AADJSTAT;
				AADJMEN;
			}
			armynum++;
		}
		if(army==(-1)){
			mvaddstr(LINES-1,0,"NO FREE ARMIES--hit any key");
			clrtoeol();
			refresh();
			getch();
			if(isgod==1) country=0;
			return;
		}
		armynum=army;
	}

	AYLOC=YREAL;
	AXLOC=XREAL;
	AADJLOC;
	AMOVE=0;
	AADJMOV;
	ASOLD+=men;
	AADJMEN;
	sct[XREAL][YREAL].people -= men;
	SADJCIV;
	makemap(); /* if display 'y' is set, this will show new army */
	if(isgod==0)
		/*magiced get 1/2 enlistment costs*/
		if((magic(country,WARRIOR)==1)
		||(magic(country,WARLORD)==1)
		||(magic(country,CAPTAIN)==1))
			ntn[country].tgold -= (long) men*ENLISTCOST/2;
		else ntn[country].tgold -= (long) men*ENLISTCOST;
	else country=0;
}

/*adjust picked army*/
adjarm()
{
	short status;
	short armynum=0;
	armynum=getselunit();
	if((armynum<0)||(armynum>=MAXARM)) {
		beep();
		mvprintw(LINES-1,0,"Sorry you have an Invalid army number (%d)",armynum);
		refresh();
		getch();
		return;
	}
	if(ASTAT==SCOUT) {
		beep();
		mvprintw(LINES-1,0,"Sorry can't change scouts");
		refresh();
		getch();
		return;
	}
	clear();
	mvprintw(0,10,"ADJUST ARMY %d OF NATION %s",armynum,ntn[country].name);
	mvaddstr(2,10,"1.  March ");
	mvaddstr(3,10,"2.  Scouting--will not engage enemy if possible");
	mvaddstr(4,10,"3.  Attack anybody (Hostile+) within 2 sectors");
	mvaddstr(5,10,"4.  Defend ");
	mvaddstr(6,10,"5.  Garrison--for a city or Capital");
	mvaddstr(12,10,"Enter your choice (return to continue):");
	refresh();
	status = get_number();
	if((status<1)||(status>5)) return;
	if((status==SCOUT)&&(ASOLD>25)){
		clear();
		mvaddstr(12,(COLS/2)-6,"MUST HAVE < 25 MEN TO SCOUT");
		mvaddstr(13,(COLS/2)-12,"HIT ANY KEY TO CONTINUE");
		refresh();
		getch();
		return;
	}
	ASTAT=status;
	AADJSTAT;
}

/*go through msgfile not rewriting to temp messages you discard*/
/* then move temp to msgfile*/
rmessage()
{
	FILE *mesgfp;
	FILE *fptemp;
	int i;
	int count;
	int contd;
	int done=0;
	char tempfile[ 30 ];
	char mesgfile[ 30 ];
	char line[80];
	char save[20][80];

	clear();
	/*open file*/
	sprintf(tempfile,"%s:temp",msgfile);
	if( (fptemp = fopen(tempfile,"w")) == NULL ) {
		mvprintw(0,0,"error on creating %s--hit return", tempfile);
		refresh();
		getch();
		return;
	}

	sprintf(mesgfile,"%s%d",msgfile,country);
	if ((mesgfp=fopen(mesgfile,"r"))==NULL) {
		mvprintw(0,0,"no messages in %s, hit return",mesgfile);
		refresh();
		getch();
		return;
	}

	/*read in file a line at at time*/
	if(fgets(line,80,mesgfp)==NULL) done=1;
	while(done==0) {
		contd=0;
		count=3;
		if(strncmp(line,ntn[country].name,strlen(ntn[country].name))==0) {
			clear();
			standout();
			/*print to end of message*/
			while(contd==0) {
				if(count<22) strcpy(save[count-3],line);
				mvprintw(count,0,"%s",line);
				standend();
				for(i=0;i<strlen(ntn[country].name);i++) 
					mvaddch(count,i,' ');
				count++;
				if(fgets(line,80,mesgfp)==NULL) contd=1;
				if(strncmp(line,"END",3)==0) contd=1;
			}
			standout();
			mvaddstr(LINES-3,(COLS/2)-22,"HIT RETURN TO SAVE MESSAGE");
			mvaddstr(LINES-2,(COLS/2)-22,"HIT ANY OTHER KEY TO CONTINUE");
			standend();
			refresh();
			if(getch()=='\n') {
				for(i=0;i<count-3;i++) fputs(save[i],fptemp);
				strcpy(line,"END\n");
				fputs(line,fptemp);
			}
		}
		else fputs(line,fptemp);
		if(fgets(line,80,mesgfp)==NULL) done=1;
	}
	fclose(mesgfp);
	fclose(fptemp);

	/*IMPLEMENT A MOVE BETWEEN TMP FILE AND REAL FILE HERE*/
	move_file( tempfile, mesgfile );
}

wmessage()
{
	FILE *fp, *fopen();
	int x,y;
	int done=0;
	char ch;
	char name[12];
	char realname[12];
	int temp=(-1);
	int linedone;
	char line[100];
	int nationid;

	/*what nation to send to*/
	clear();
	mvprintw(0,0,"to send a message to the administrator, send to 'god':");
	mvprintw(2,0,"What country name do you wish to send to:");
	refresh();
	echo();
	getstr(name);
	noecho();

	/*is name valid*/
	for(nationid=0;nationid<MAXNTN;nationid++) if(ntn[nationid].active!=0)
		if(strcmp(name,ntn[nationid].name)==0) temp=nationid;

	if(strcmp(name,"god")==0) {
		temp=0;
		strcpy(realname,"unowned");
	}
	else strcpy(realname,name);

	if (temp==(-1)) {
		mvprintw(2,0,"error--invalid name");
		refresh();
		getch();
		return;
	}

	sprintf(line,"%s%d",msgfile,temp);
	if ((fp=fopen(line,"a+"))==NULL) {
		mvprintw(4,0,"error opening %s",line);
		refresh();
		getch();
		return;
	}

	move(0,0);
	clrtoeol();
	move(2,0);
	clrtoeol();
	standout();
	mvprintw(3,(COLS-25)/2,"message to nation %s",name);
	mvprintw(LINES-2,(COLS-25)/2,"end with a return on a new line");
	mvprintw(LINES-1,(COLS-35)/2,"btw... This is my first editor, any comments?");
	standend();

	fprintf(fp,"%s Message to %s from %s\n",realname,name,ntn[country].name);
	fprintf(fp,"%s \n",realname);
	y=6;
	x=0;
	refresh();
	while(done==0) {
		linedone=0;
		ch=' ';
		/*read line*/
		while(linedone==0){
			if(ch=='\b'){
				if(x>0) x--;
				mvaddch(y,x,' ');
				move(y,x);
				line[x]=' ';
				refresh();
				ch=getch();
			}
			else if(ch=='\n') linedone=1;
			else{
				/*concatonate to end*/
				line[x]=ch;
				mvaddch(y,x,ch);
				if(x<99) x++;
				else linedone=1;
				refresh();
				ch=getch();
			}
		}
		line[x]='\0';
		if(x<=1) done=1;
		/*write to file*/
		fprintf(fp,"%s %s\n",realname,line);
		x=0;
		y++;
	}
	fputs("END\n",fp);
	mvprintw(20,0,"Done with messaging");
	fclose(fp);
}

/*strategic move of civilians...once only*/
moveciv()
{
	short people;
	short i,j;

	mvaddstr(LINES-1,0,"Moving civilians costs 50 per civilian");
	if(sct[XREAL][YREAL].owner!=country){
		mvprintw(LINES-2,0,"you do not own:  hit return");
		clrtoeol();
		refresh();
		getch();
		return;
	}
	else if(sct[XREAL][YREAL].people==0){
		mvaddstr(LINES-2,0,"nobody lives here!!!:  hit return");
		clrtoeol();
		refresh();
		getch();
		makebottom();
		return;
	}

	clear();
	mvaddstr(0,0,"Moving civilians costs 50 per civilian");
	mvprintw(1,0,"sector contains %d people",sct[XREAL][YREAL].people);
	mvaddstr(2,0,"how many people to move?");
	clrtoeol();
	refresh();
	people = get_number();
	if((people<0)
	||(people>sct[XREAL][YREAL].people)
	||(people*50>ntn[country].tgold)){
		mvaddstr(5,0,"Sorry...Input error or you do not have the gold");
		clrtoeol();
		refresh();
		getch();
		makebottom();
		return;
	}

	mvprintw(5,0,"sector location is x=%d, y=%d",XREAL,YREAL);
	mvaddstr(7,0,"what x location to move to?");
	refresh();
	i = get_number();

	if((i-(XREAL))>2||(i-(XREAL))<-2) {
		mvprintw(10,0,"can only move 2 sectors (you tried %hd)...--hit any key",i-(XREAL));
		refresh();
		getch();
		return;
	}

	mvaddstr(10,0,"what y location to move to?");
	clrtoeol();
	refresh();
	j = get_number();
	if((j-(YREAL)>2)||((YREAL)-j>2)) {
		mvprintw(10,0,"sorry, can only move 2 sectors (you tried %hd)...--hit any key",j-(XREAL));
		refresh();
		getch();
	}
	else if(sct[i][j].owner!=country){
		mvaddstr(12,0,"sorry, you dont own it...");
		clrtoeol();
		refresh();
		getch();
	}
	/*need to check move cost > 0 for sector*/
	else if(movecost[i][j]<0){
		mvaddstr(12,0,"you can't enter there...");
		clrtoeol();
		refresh();
		getch();
	}
	else {
		ntn[country].tgold-=50*people;
		sct[XREAL][YREAL].people-=people;
		SADJCIV;
		sct[i][j].people+=people;
		SADJCIV2;
	}
}

armygoto()
{
	short armynum=0,loop=0;
	armynum=getselunit();
	if((armynum<0)||(armynum>MAXARM)) armynum=0;
	else armynum++;
	/* move to next army with > 0 soldiers*/
	while ((armynum < MAXARM) && (ASOLD <= 0)) armynum++;
	if(armynum >= MAXARM)  {
		armynum=0;
		if(ASOLD <= 0) return(0);
	}
	/*move to correct location*/
	xcurs = AXLOC - xoffset;
	ycurs = AYLOC - yoffset;
	coffmap();

	/*select correct unit*/
	selector=0;
	pager=0;
	while((getselunit() != armynum) && (loop++ < 500)) {
		selector+=2;
		if(selector>=10) {
			selector=0;
			pager+=1;
		}
	}
	return(1);
}

navygoto()
{
	short nvynum=0,loop=0;
	nvynum=getselunit()-MAXARM;
	if((nvynum<0)||(nvynum>MAXNAVY)) nvynum=0;
	else nvynum++;
	/* move to next nvy with > 0 soldiers*/
	while ((nvynum < MAXNAVY) && (NMER+NWAR <= 0)) nvynum++;
	if(nvynum >= MAXNAVY) {
		nvynum=0;
		if(NMER+NWAR <= 0) return(0);
	}
	/*move to correct location*/
	xcurs = NXLOC - xoffset;
	ycurs = NYLOC - yoffset;
	coffmap();
	
	/*select correct unit*/
	selector=0;
	pager=0;
	while(((getselunit()-MAXARM) != nvynum) && (loop++ < 500)) {
		selector+=2;
		if(selector>=10) {
			selector=0;
			pager+=1;
		}
	}
	return(1);
}
SHAR_EOF

newcount="`wc -c commands.c | awk '{ print $1 }'`"
if test 18869 != $newcount
then
	echo "extracting $newcount characters"
	echo shar: error transmitting "'commands.c'" '(should have been 18869 characters)' 
fi



More information about the Comp.sources.bugs mailing list