[comp.sources.games] v06i091: 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 91
Archive-name: conquer4/Part09
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 9 (of 14)."
# Contents:  admin.c check.c makeworl.c newlogin.h
# Wrapped by billr@saab on Thu Jun 15 15:20:18 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'admin.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'admin.c'\"
else
echo shar: Extracting \"'admin.c'\" \(16157 characters\)
sed "s/^X//" >'admin.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#include "header.h"
X#include "data.h"
X#include <ctype.h>
X
X#include <signal.h>
X
X#include <fcntl.h>
X#include  <pwd.h>
X/*Declarations*/
Xchar	*getpass();
Xstruct	s_sector **sct;
Xstruct	s_nation ntn[NTOTAL];   /* player nation stats */
Xstruct	s_world	world;
X/*is sector occupied by an army?*/
Xchar	**occ;
Xshort	**movecost;
Xlong	startgold=0;
X
X/*offset of upper left hand corner*/
Xshort	xoffset=0,yoffset=0;
X/*current cursor postion (relative to 00 in upper corner)*/
X/*	position is 2*x,y*/
Xshort	xcurs=0,ycurs=0;
X/*display state*/
Xshort	dismode=2;
X/* nation id of owner*/
Xshort	country=0;
Xstruct	s_nation	*curntn;
X
XFILE *fexe, *fopen();
X
Xvoid
Xmain(argc,argv)
Xint argc;
Xchar **argv;
X{
X	int geteuid(), getuid(), setuid();
X	register int i;
X	char *name;
X	void srand();
X	int getopt();
X	long time();
X	/* mflag = makeworld, a=add player, x=execute, p=print */
X	/* rflag = make world from read in files */
X	int mflag, aflag, xflag, pflag, rflag;
X	char string[80];
X	extern char *optarg;
X	char defaultdir[256];
X	struct passwd *getpwnam();
X
X	mflag = aflag = xflag = pflag = rflag = 0;
X	srand((unsigned) time((long *) 0));
X	strcpy(defaultdir, DEFAULTDIR);
X	name = string;
X	*name = 0;
X
X	/* process the command line arguments */
X	while((i=getopt(argc,argv,"maxpr:d:"))!=EOF) switch(i){
X	/* process the command line arguments */
X	case 'm':  /* make a new world*/
X		mflag++;
X		break;
X	case 'a': /* anyone with password can add player*/
X		aflag++;
X		break;
X	case 'x': /* execute program*/
X		xflag++;
X		break;
X	case 'p': /* print the map*/
X		pflag++;
X		break;
X	case 'r': /* read map file */
X		rflag++;
X		if(strlen(optarg) > NAMELTH){
X			fprintf(stderr,"ERROR: MAPFILE STEM LONGER THAN %d\n",NAMELTH);
X			exit(FAIL);
X		}
X		strcpy(scenario, optarg);
X		break;
X	case 'd':
X		strcpy(defaultdir, optarg);
X		break;
X	case '?': /*  print out command line arguments */
X		printf("Command line format: %s [-maxp -dDIR -rSCENARIO]\n",argv[0]);
X		printf("\t-m          make a world\n");
X		printf("\t-a          add new player\n");
X		printf("\t-x          execute program\n");
X		printf("\t-d DIR      to use play different game\n");
X		printf("\t-p          print a map\n");
X		/* printf("\t-r SCENARIO read map while making a new world\n\t\t\tuses SCENARIO.ele, SCENARIO.veg, &  SCENARIO.nat\n"); */
X		exit(SUCCESS);
X	};
X
X#ifdef OGOD
X	if(((getuid())!=(getpwnam(LOGIN)->pw_uid))&&(!aflag))
X	{
X	     printf("Sorry -- you can not administrate conquer\n");
X	     printf("you need to be logged in as %s\n",LOGIN);
X	     exit(FAIL);
X	}
X	/* may now replace user identity */
X	(void) setuid (geteuid ()) ;
X#endif OGOD
X
X	/* now that we have parsed the args, we can got to the
X	 * dir where the files are kept and do some work.
X	 */
X	if (chdir(defaultdir)) {
X		printf("unable to change dir to %s\n",defaultdir);
X		exit(FAIL);
X	}
X	if((mflag)||(rflag)) {
X		makeworld(rflag);
X		sprintf(string,"%sup",isonfile);
X		unlink(string);
X		exit(SUCCESS);
X	}
X
X	/* read data*/
X	readdata();
X	verifydata( __FILE__, __LINE__ );
X
X	if (aflag) { /* a new player */
X		sprintf(string,"%sup",isonfile);
X		if(check_lock(string,FALSE)==TRUE) {
X			printf("Conquer is updating\n");
X			printf("Please try again later.\n");
X			exit(FAIL);
X		}
X
X		sprintf(string,"%s0",isonfile);
X		if(check_lock(string,FALSE)==TRUE) {
X			printf("God is currently logged in.\n");
X			printf("Please try again later.\n");
X			exit(FAIL);
X		}
X
X		printf("\n********************************************");
X		printf("\n*      PREPARING TO ADD NEW PLAYERS        *");
X		printf("\n********************************************\n");
X		if( TURN > 5 ){
X			printf("more than 5 turns have passed since game start!\n");
X			printf("permission of game administrator required\n");
X			if(strncmp(crypt(getpass("\nwhat is conquer super user password:"),SALT),ntn[0].passwd,PASSLTH)!=0)
X			{
X				printf("sorry...\n");
X				exit(FAIL);
X			}
X		}
X		/* prevent more than one addition */
X		sprintf(string,"%sadd",isonfile);
X		if(check_lock(string,TRUE)==TRUE) {
X			printf("Some else is adding\n");
X			printf("Please try again later.\n");
X			exit(FAIL);
X		}
X
X		/* disable interrupts */
X		signal(SIGINT,SIG_IGN);
X		signal(SIGQUIT,SIG_IGN);
X		newlogin();
X		unlink(string);
X		exit(SUCCESS);
X	} else if (pflag) {	/* print a map of the game */
X#ifdef OGOD
X		if(strncmp(crypt(getpass("\nwhat is conquer super user password:"),SALT),ntn[0].passwd,PASSLTH)!=0) {
X			printf("sorry, must be super user to get map\n");
X			exit(FAIL);
X		}
X#endif OGOD
X		printf("For Convienience, output is to stderr\n");
X		printf("what type of map\noptions are\n");
X		printf("\t1) altitudes\n\t2) vegetations\n");
X		printf("\t3) nations\n\n");
X		printf("\tINPUT:");
X		scanf("%hd",&dismode);
X		if(dismode==1) printele();
X		else if(dismode==2) printveg();
X		else pr_ntns();
X		exit(SUCCESS);
X	} else if (xflag) {	/* update the game */
X#ifndef OGOD
X		if ( getuid() != (getpwnam(LOGIN))->pw_uid ){
X			printf("sorry -- your uid is invalid for updating\n");
X			printf("you need to be logged in as %s\n",LOGIN);
X			exit(FAIL);
X		}
X#endif OGOD
X#ifdef RUNSTOP
X		/* check if any players are on */
X		for (i=0;i<NTOTAL;i++) {
X			sprintf(string,"%s%d",isonfile,i);
X			if(check_lock(string,FALSE)==TRUE) {
X				printf("Nation %d is still in the game.\n",i);
X				printf("Update aborted.\n");
X				exit(FAIL);
X			}
X		}
X#endif RUNSTOP
X		sprintf(string,"%sup",isonfile);
X		if(check_lock(string,TRUE)==TRUE) {
X			printf("Another update is still executing.\n");
X			printf("Update aborted.\n");
X			exit(FAIL);
X		}
X		update();
X		writedata();
X		unlink(string);
X		exit(SUCCESS);
X	}
X	printf("error: must specify an option\n");
X
X	/*  print out command line arguments */
X	printf("Command line format: %s [-maxp -dDIR]\n",argv[0]);
X	printf("\t-a       add new player\n");
X	printf("\t-d DIR   to use play different game\n");
X	printf("\t-m       make a world\n");
X	printf("\t-p       print a map\n");
X	printf("\t-x       execute program\n");
X	exit(SUCCESS);
X}
X
X/* if parameter == 0 do for all nations */
Xvoid
Xatt_setup(cntry)
Xint	cntry;
X{
X	int	nat;
X	for( nat= 0; nat<NTOTAL;nat++) if( isntn( ntn[nat].active ))
X	if( (cntry==0) || (nat==cntry) ){
X		ntn[nat].farm_ability = 10;
X		ntn[nat].poverty = 95;
X		ntn[nat].popularity=ntn[nat].reputation=ntn[nat].prestige = 50;
X		ntn[nat].eatrate = 25;
X		ntn[nat].tax_rate = 10;
X		if( magic(nat,MINER) )
X			ntn[nat].mine_ability = 25;
X		else	ntn[nat].mine_ability = 10;
X		ntn[nat].knowledge = 10;
X		ntn[nat].charity = 0;
X	}
X}
X
X/* calculates a nations base values in each of its attributes */
X/* includes bonuses for magic powers, but not trade goods */
Xvoid
Xatt_base()
X{
X	long	cityfolk,townfolk,scholars,foodpts,minepts,roads,clerics,ngrain;
X	long	blksmths;
X	long	mercs,armynum,ncities;
X	long	temp;
X	int	x,y;
X	char	d;
X
X	/* set to one so NEVER will have a divide by 0 */
X	WORLDJEWELS=1; WORLDGOLD=1; WORLDMETAL=1;
X	WORLDFOOD=1; WORLDSCORE=1; WORLDCIV=1; WORLDSCT=1;
X	WORLDMIL=1; WORLDNTN=0;
X	for(country=1;country<NTOTAL;country++) {
X		curntn= &ntn[country];
X		if( !isntn( curntn->active )) continue;
X		WORLDNTN++;
X		WORLDJEWELS+=curntn->jewels;
X		if(curntn->tgold>0) WORLDGOLD+=curntn->tgold;
X		WORLDMETAL+=curntn->metals;
X		WORLDFOOD+=curntn->tfood;
X		WORLDSCORE+=curntn->score;
X		WORLDCIV+=curntn->tciv;
X		WORLDSCT+=curntn->tsctrs;
X		WORLDMIL+=curntn->tmil;
X	}
X	if (WORLDGOLD==0) WORLDGOLD=1;
X	printf("calculating new national attributes:  sum of scores=%ld of mil=%ld\n",WORLDSCORE,WORLDMIL);
X
X	/* count the number of sectors */
X	for(country=1;country<NTOTAL;country++) {
X		if(!isntn(ntn[country].active)) continue;
X		curntn= &ntn[country];
X		cityfolk=townfolk=scholars=foodpts=minepts=roads=clerics=ngrain=ncities=blksmths=0;
X
X		for(x=0;x<MAPX;x++) for(y=0;y<MAPY;y++)
X		if(sct[x][y].owner == country) {
X			d = sct[x][y].designation;
X			if( d==DTOWN)		townfolk+=sct[x][y].people;
X			else if( d==DCITY ){
X				cityfolk+=sct[x][y].people;
X				ncities++;
X			} else if( d==DMINE )	{
X				if( tg_ok( country, &sct[x][y] ))
X					minepts+=sct[x][y].metal;
X			} else if( d==DFARM )
X				foodpts += sct[x][y].people * tofood( &sct[x][y],country);
X			else if( d==DCAPITOL ){
X				ncities+=3;
X				cityfolk+=sct[x][y].people;
X			} else if( d==DUNIVERSITY)scholars+=sct[x][y].people;
X			else if( d==DROAD )	roads++;
X			else if( d==DCHURCH )	clerics+=sct[x][y].people;
X			else if( d==DGRANARY )	ngrain++;
X			else if( d==DBLKSMITH )	blksmths+=sct[x][y].people;
X		}
X		cityfolk /= 167;
X		townfolk /= 167;
X		scholars /=167;
X		clerics /= 167;
X		blksmths /= 167;
X
X		/* use prior eatrate a weighting factor */
X		if (curntn->eatrate<25) curntn->eatrate=25;
X		if( TURN!= 1) {	/* remember eatrate is scaled by 25 */
X			switch(SEASON(TURN)) {
X			case WINTER:	/* 7 food/person for each eatrate */
X				temp = 180L * curntn->tfood/(curntn->eatrate+25L);
X				break;
X			case SPRING:	/* 6 food/person for each eatrate */
X				temp = 204L * curntn->tfood/(curntn->eatrate+25L);
X				break;
X			case SUMMER:	/* 5 food/person for each eatrate */
X				temp = 250L * curntn->tfood/(curntn->eatrate+25L);
X				break;
X			case FALL:	/* 4 food/person for each eatrate */
X				temp = 312L * curntn->tfood/(curntn->eatrate+25L);
X				break;
X			}
X			if(curntn->tciv>0) x = curntn->eatrate/2 + temp/curntn->tciv;
X			else x = 25;
X			if( x < MAXTGVAL ) curntn->eatrate = (char)x;
X			else curntn->eatrate=MAXTGVAL;
X			if ( curntn->eatrate < 25 ) curntn->eatrate=25;
X
X		} else {
X			cityfolk = 10;		/* Aproximate steady state */
X		}
X
X		if( 30 <= 1+ngrain+ncities ) curntn->spoilrate=1;
X		else curntn->spoilrate = 30-ngrain-ncities;
X		if( curntn->tfood > curntn->tciv * 10 )
X			curntn->spoilrate = 30;
X
X		/* get number of mercenaries */
X		mercs=0;
X		for(armynum=0;armynum<MAXARM;armynum++)
X			if(P_ATYPE==A_MERCENARY) mercs+=P_ASOLD;
X		if(curntn->tmil>0 && curntn->tciv>0) temp=(1000*curntn->tmil)/curntn->tciv+(1000*mercs)/curntn->tmil;
X		else temp=0;
X		curntn->terror = min( temp/5, MAXTGVAL );
X
X		temp = (5*townfolk/2+5*cityfolk) + roads*5;
X		curntn->communications = min( temp,2*MAXTGVAL );
X
X		temp=1000*curntn->score/WORLDSCORE + 1000*curntn->tmil/WORLDMIL;
X		curntn->power = min(temp/5,MAXTGVAL);
X
X		temp = curntn->tgold;
X		if(temp<0) temp=0;
X		temp = 1000*temp/WORLDGOLD + 1000*curntn->jewels/WORLDJEWELS + 1000*curntn->metals/WORLDMETAL + cityfolk*5/3 + townfolk*5/6;
X		curntn->wealth = min( temp/10,MAXTGVAL );
X
X		if( TURN!= 1) {
X		curntn->reputation += rand()%8-3;
X		curntn->reputation = min( curntn->reputation,MAXTGVAL );
X
X		temp = (curntn->prestige + curntn->power + curntn->wealth) / 3;
X		curntn->prestige = min( temp,MAXTGVAL );
X
X		if(curntn->tciv>0) temp = foodpts*10 / curntn->tciv;
X		else temp = 0;
X		curntn->farm_ability = min( temp,MAXTGVAL );
X		}
X		temp = (minepts/3 + cityfolk/2 + townfolk/2 + blksmths);
X		curntn->mine_ability = min( temp,MAXTGVAL );
X		if( magic(country,MINER) )
X			curntn->mine_ability += 15;
X		if( magic(country,STEEL) )
X			curntn->mine_ability += 15;
X
X		temp = cityfolk/2 + townfolk/6 + scholars/2;
X		curntn->knowledge = min( temp,MAXTGVAL );
X
X		temp = (curntn->wealth + 10*P_EATRATE + clerics + curntn->popularity)/2;
X		curntn->popularity = min( temp,MAXTGVAL );
X
X		/* poverty tends 10% to 100-wealth/4 */
X		curntn->poverty += (100-curntn->wealth/4-curntn->poverty+5)/10;
X
X		if(magic(country,SLAVER))	curntn->terror+=PWR_NA;
X		if(magic(country,RELIGION))	curntn->popularity+=PWR_NA;
X		if(magic(country,URBAN)) {
X			if(curntn->popularity > PWR_NA)
X				curntn->popularity-=PWR_NA;
X			else	curntn->popularity=0;
X		}
X		if(magic(country,DEMOCRACY)) {
X			curntn->eatrate += 25;
X			if(curntn->terror > PWR_NA)
X				curntn->terror-=PWR_NA;
X			else	curntn->terror=0;
X			curntn->charity+=2;	/* it creeps up */
X		}
X		if(magic(country,KNOWALL))	curntn->knowledge+=PWR_NA;
X		if(magic(country,ARCHITECT)){
X			if(curntn->spoilrate>=PWR_NA)
X				curntn->spoilrate-=PWR_NA;
X			else curntn->spoilrate=1;
X		}
X		if(magic(country,ROADS))	curntn->communications+=50;
X		if(magic(country,DESTROYER))	curntn->terror+=PWR_NA;
X		if(magic(country,ROADS))	curntn->terror+=PWR_NA;
X		if(magic(country,VAMPIRE))	curntn->terror+=PWR_NA;
X
X		switch(curntn->class){
X		case C_NPC:	curntn->popularity+=CLA_NA;
X				curntn->terror+=CLA_NA;		break;
X		case C_KING:	curntn->popularity+=CLA_NA;	break;
X		case C_TRADER:	curntn->wealth+=CLA_NA;
X				curntn->popularity+=CLA_NA;
X				curntn->prestige+=CLA_NA/3;	break;
X		case C_EMPEROR:	curntn->wealth+=CLA_NA;
X				curntn->popularity+=CLA_NA;
X				curntn->prestige+=CLA_NA/3;	break;
X		case C_WIZARD:	curntn->knowledge+=CLA_NA;	break;
X		case C_PRIEST:	curntn->popularity+=CLA_NA;	break;
X		case C_PIRATE:	curntn->terror+=CLA_NA;		break;
X			/* for warlord remember it is recursive */
X		case C_WARLORD:	curntn->prestige+=CLA_NA*2/3;	break;
X		case C_DEMON:	curntn->terror+=CLA_NA;		break;
X		case C_DRAGON:	curntn->terror+=CLA_NA;		break;
X		case C_SHADOW:	curntn->terror+=CLA_NA;		break;
X		}
X
X		curntn->prestige = min( curntn->prestige, MAXTGVAL );
X		curntn->popularity = min( curntn->popularity, MAXTGVAL );
X		curntn->power = min( curntn->power, MAXTGVAL );
X		curntn->communications = min( curntn->communications, 2*MAXTGVAL);
X		curntn->wealth = min( curntn->wealth, MAXTGVAL );
X		curntn->eatrate = min( curntn->eatrate, MAXTGVAL );
X		curntn->knowledge = min( curntn->knowledge, MAXTGVAL );
X		curntn->farm_ability = min( curntn->farm_ability, MAXTGVAL );
X		curntn->mine_ability = min( curntn->mine_ability, MAXTGVAL );
X		curntn->terror = min( curntn->terror, MAXTGVAL );
X		curntn->reputation = min( curntn->reputation, MAXTGVAL );
X	}
X}
X
X/* calculates a nations bonuses due to trade goods */
Xvoid
Xatt_bonus()
X{
X	short	x,y,nation,good;
X	struct	s_sector	*sptr;
X	printf("working on exotic trade goods\n");
X	for(x=0;x<MAPX;x++) for(y=0;y<MAPY;y++) {
X		if(!isntn(ntn[sct[x][y].owner].active)) continue;
X
X		sptr = &sct[x][y];
X		nation = sptr->owner;
X		curntn = &ntn[nation];
X
X		if( !tg_ok( nation, sptr) ) continue;
X
X		good = sptr->tradegood;
X
X		if(( *(tg_stype+good)== sptr->designation )
X		||(( *(tg_stype+good)== DTOWN )&&(sptr->designation==DCITY))
X		||(( *(tg_stype+good)== DTOWN )&&(sptr->designation==DCAPITOL))
X		||(( *(tg_stype+good)== DCITY )&&(sptr->designation==DCAPITOL))
X		||(( *(tg_stype+good)== DUNIVERSITY )&&(sptr->designation==DCITY))
X		||(( *(tg_stype+good)== DUNIVERSITY )&&(sptr->designation==DCAPITOL))
X		||( *(tg_stype+good)== 'x' ))
X		if( good <= END_POPULARITY ) {
X			curntn->popularity += ( *(tg_value+good) - '0');
X			curntn->popularity = min( MAXTGVAL, curntn->popularity );
X		} else if( good <= END_COMMUNICATION ) {
X			if(curntn->communications + (*(tg_value+good) - '0')<2*MAXTGVAL)
X				curntn->communications += (*(tg_value+good) - '0');
X			else curntn->communications = 2*MAXTGVAL;
X		} else if( good <= END_EATRATE ) { /* eatrate scaled already */
X			/* no tradegoods for eatrate */
X			curntn->eatrate = min( MAXTGVAL, curntn->eatrate );
X		} else if( good <= END_SPOILRATE ) {
X			if(curntn->spoilrate > (*(tg_value+good) - '0'))
X				curntn->spoilrate -= (*(tg_value+good)-'0');
X			else curntn->spoilrate = 1;
X		} else if( good <= END_KNOWLEDGE ) {
X			if(curntn->knowledge + (*(tg_value+good)-'0') < MAXTGVAL)
X				curntn->knowledge += (*(tg_value+good) - '0');
X			else curntn->knowledge = MAXTGVAL;
X		} else if( good <= END_FARM ) {
X			if(curntn->farm_ability + (*(tg_value+good) - '0') < MAXTGVAL)
X				curntn->farm_ability += (*(tg_value+good)-'0');
X			else curntn->farm_ability = MAXTGVAL;
X		} else if( good <= END_SPELL ) {
X			curntn->spellpts++;
X		} else if( good <= END_TERROR ) {
X			if(curntn->terror + (*(tg_value+good)-'0')< MAXTGVAL)
X				curntn->terror += (*(tg_value+good)-'0');
X			else curntn->terror = MAXTGVAL;
X		}
X	}
X}
END_OF_FILE
if test 16157 -ne `wc -c <'admin.c'`; then
    echo shar: \"'admin.c'\" unpacked with wrong size!
fi
# end of 'admin.c'
fi
if test -f 'check.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'check.c'\"
else
echo shar: Extracting \"'check.c'\" \(5133 characters\)
sed "s/^X//" >'check.c' <<'END_OF_FILE'
X/* Conquer: Copyright (c) 1988 by Edward M Barlow	*/
X/* check.c contains checking and debugging functions	*/
X
X#include	<ctype.h>
X#include	<stdio.h>
X#include	"header.h"
X#include	"data.h"
X
Xvoid
Xverify_ntn( __file__, __line__ )
Xchar	__file__[];
Xint	__line__;
X{
X	register struct s_nation	*nptr;
X	register int	i;
X	register int	country;
X	struct army	*a;
X
X	for( country = 0; country < NTOTAL; country++ ) {
X		nptr = &ntn[country];
X
X		if(nptr->active == 0) continue;
X		if( nptr->metals < 0.0 ) {
X			fprintf( stderr, "file %s: line %d: nation[%d] metal = %ld\n",
X				__file__, __line__, country, nptr->metals );
X			nptr->metals = 0.0;
X		}
X
X		if( nptr->jewels < 0 ) {
X			fprintf( stderr, "file %s: line %d: nation[%d] jewels = %ld\n",
X				__file__, __line__, country, nptr->jewels );
X			nptr->jewels = 0.0;
X		}
X
X		for( i = 0; i < MAXARM; i++ ) {
X			a = &nptr->arm[i];
X			if( a->sold < 0 ) {
X				fprintf( stderr, "file %s: line %d: nation[%d] army[%d] sold = %d\n",
X					__file__, __line__, country, i, a->sold );
X				a->sold = 0;
X			}
X			if( a->sold==0 ) continue;
X			if( a->xloc >= MAPX ) {
X				fprintf( stderr, "file %s: line %d: nation[%d] army[%d] xlocation = %d\n",
X					__file__, __line__, country, i, a->xloc );
X				a->xloc = 0;
X			}
X			if( a->yloc >= MAPY ) {
X				fprintf( stderr, "file %s: line %d: nation[%d] army[%d] ylocation = %d\n",
X					__file__, __line__, country, i, a->yloc );
X				a->yloc = 0;
X			}
X			if( sct[a->xloc][a->yloc].altitude==PEAK ) {
X				fprintf( stderr, "file %s: line %d: nation[%d] army[%d] loc=%d,%d (peak)\n",
X				__file__,__line__,country,i,a->xloc,a->yloc);
X				a->sold = 0;
X			}
X			if( sct[a->xloc][a->yloc].altitude==WATER ) {
X				fprintf( stderr, "file %s: line %d: nation[%d] army[%d] loc=%d,%d (water) men=%d\n",
X				__file__,__line__,country,i,a->xloc,a->yloc,a->sold);
X				a->sold = 0;
X			}
X		} /* for */
X
X		for( i = 0; i < NTOTAL; i++ ) {
X			if( nptr->dstatus[i] > JIHAD ) {
X				fprintf( stderr, "file %s: line %d: nation[%d] diplomatic status with %d = %d\n",
X					__file__, __line__, country, i, nptr->dstatus[i] );
X				nptr->dstatus[i] = WAR;
X			}
X		} /* for */
X	} /* for */
X} /* verify_ntn() */
X
Xvoid
Xverify_sct( __file__, __line__ )
Xchar	__file__[];
Xint	__line__;
X{
X	register struct s_sector	*sptr;
X	register int		x, y;
X
X	for( x = 0; x < MAPX; x++ ) {
X		for( y = 0; y < MAPY; y++ ) {
X			sptr = &sct[x][y];
X
X			if(sptr->tradegood>TG_none) {
X				fprintf( stderr, "file %s: line %d: sct[%d][%d].tradegood = %d (invalid)\n", __file__, __line__, x, y, sptr->tradegood );
X				sptr->tradegood=TG_none;
X			}
X			if(( sptr->metal != 0 )
X			&&(( sptr->tradegood>END_MINE)
X			  ||(sptr->tradegood<=END_NORMAL))) {
X				fprintf( stderr, "file %s: line %d: sct[%d][%d].metal = %d with no tradegood\n", __file__, __line__, x, y, sptr->metal );
X				sptr->metal = 0;
X			}
X
X			if(( sptr->jewels != 0 )
X			&&((sptr->tradegood>END_WEALTH)
X			  ||(sptr->tradegood<=END_MINE))) {
X				fprintf( stderr, "file %s: line %d: sct[%d][%d].jewels = %d with no tradegood\n", __file__, __line__, x, y, sptr->jewels );
X				sptr->jewels = 0;
X			}
X
X			if( sptr->people > ABSMAXPEOPLE )
X				sptr->people = ABSMAXPEOPLE;
X
X			if( sptr->people < 0 ) {
X				fprintf( stderr, "file %s: line %d: sct[%d][%d].people = %d\n", __file__, __line__, x, y, sptr->people );
X				if( sptr->people < -1*ABSMAXPEOPLE )
X					sptr->people = ABSMAXPEOPLE;
X				else sptr->people = 0;
X			}
X
X			if( sptr->owner != 0 && sptr->altitude == WATER ) {
X				fprintf( stderr, "file %s: line %d: sct[%d][%d].owner = %s (a water sector)\n",__file__,__line__, x, y, ntn[sptr->owner].name );
X				sptr->owner = 0;
X			}
X			if( sptr->fortress > 12 ){
X				fprintf( stderr, "file %s: line %d: sct[%d][%d].fortress = %d \n",__file__,__line__, x, y, sptr->fortress );
X				sptr->fortress = 12;
X			}
X		} /* for */
X	} /* for */
X} /* verify_sct() */
X
Xvoid
Xverifydata( __file__, __line__ )
Xchar	__file__[];
Xint	__line__;
X{
X	/* check for invalid values */
X	verify_ntn( __file__, __line__ );
X	verify_sct( __file__, __line__ );
X}/* verifydata() */
X
X#ifdef DEBUG
Xvoid
Xcheckout(file,line)
Xint	line;
Xchar	*file;
X{
X	/* fprintf(stderr,"file %s line %d\n",file,line);  */
X	/* verifydata(file,line); */
X}
X#endif DEBUG
X
X#include <fcntl.h>
X#ifdef FILELOCK
X#include <sys/file.h>
X#endif FILELOCK
X
X/*
X * check_lock() -- routine to check if a file is locked.
X *   - returns true if a lock is active false is not.
X *   - setting keeplock to true means leaves lock active
X *      if it is not already active.
X */
Xint
Xcheck_lock(filename,keeplock)
X	char *filename;
X	int keeplock;
X{
X	int hold=FALSE;
X#ifdef FILELOCK
X	int fd;
X
X	if ((fd=open(filename,O_CREAT,0600))!=(-1)) {
X		if(flock(fd, LOCK_EX|LOCK_NB)==(-1)) {
X			hold=TRUE;
X		}
X		/* remove lock after checking */
X		if(keeplock==FALSE && hold==FALSE) {
X			close(fd);
X			unlink(filename);
X		}
X	} else {
X		printf("error opening lock file <%s>\n",filename);
X		exit(FAIL);
X	}
X#else
X	if( access( filename, 00 ) == 0 ) {
X		hold=TRUE;
X	}
X	if (hold==FALSE && keeplock==TRUE) {
X		/* create lock file */
X		if(open(filename,O_CREAT,0600)==(-1)) {
X			printf("error opening lock file <%s>\n",filename);
X			exit(FAIL);
X		}
X	}
X#endif FILELOCK
X	return(hold);
X}
END_OF_FILE
if test 5133 -ne `wc -c <'check.c'`; then
    echo shar: \"'check.c'\" unpacked with wrong size!
fi
# end of 'check.c'
fi
if test -f 'makeworl.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'makeworl.c'\"
else
echo shar: Extracting \"'makeworl.c'\" \(30426 characters\)
sed "s/^X//" >'makeworl.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/*Create a world*/
X
X/*DEFINE TEMPORARY VARIABLES FROM MAKEFILE*/
X#include <ctype.h>
X#include <stdio.h>
X#include "header.h"
X#include "data.h"
X
X#define HALF 2
X#define LAND 3
X
Xint pwater;		/* percent water in world (0-100) */
Xextern short	country;
Xextern int	numleaders;
Xchar **area_map;			/*Value Map of Areas*/
Xchar **type;
X
X#define TOHILL(x,y) if( nmountains != 0 ) { \
Xsct[(x)][(y)].altitude=HILL; \
Xnmountains--; \
X}
X#define TOMT(x,y) if( nmountains != 0 ) { \
Xsct[(x)][(y)].altitude=MOUNTAIN; \
Xnmountains--; \
X}
X#define TOPEAK(x,y) if( nmountains != 0 ) { \
Xsct[(x)][(y)].altitude=PEAK; \
Xnmountains--; \
X}
X
Xvoid
Xmakeworld(rflag)
Xint	rflag;		/* TRUE if you wish to read in a map from mapfiles */
X{
X	char passwd[PASSLTH+1],*getpass();
X	char newstring[40];
X	FILE *fopen();
X
X	/*abort if datafile currently exists*/
X	if(access(datafile,00) == 0) {
X		printf("ABORTING: File %s exists\n",datafile);
X		printf("\tthis means that a game is in progress. To proceed, you must remove \n");
X		printf("\tthe existing data file. This will, of course, destroy that game.\n\n");
X		exit(FAIL);
X	}
Xprintf("\n************************** WELCOME TO CONQUER **************************");
Xprintf("\n*\tThe world will now be created...                               *");
Xprintf("\n*\t                                                               *");
Xprintf("\n*\tYour super user login will be 'god'.                           *");
Xprintf("\n*\t                                                               *");
Xprintf("\n*\tNon player countries will be read from the file 'nations'      *");
Xprintf("\n*\tand will have the same password as god (which you are about to *");
Xprintf("\n*\tenter). Add player nations with <conqrun -a>.  Have fun!!!     *");
Xprintf("\n*\t                                                               *");
Xprintf("\n*\tRemember to check the world out before playing to make sure    *");
Xprintf("\n*\tno nations are in bad positions (surrounded by water... )      *");
Xprintf("\n************************************************************************\n\n");
X
X	printf("First, we must zero extraneous files from prior games\n");
X	printf("\tignore any errors this causes\n");
X	sprintf(newstring,"rm -f %s* %s* %s* %s* %s 2> /dev/null",exefile,msgfile,newsfile,isonfile,tradefile);
X	printf("\t%s\n",newstring);
X	system(newstring);
X	printf("OK This has been done, Now to set up a new world\n\n");
X
X	while(TRUE) {			/* password routine */
X		strncpy(passwd,getpass("please enter new conquer super user password (remember this!):"),PASSLTH);
X		strncpy(ntn[0].passwd,getpass("please reenter conquer password:"),PASSLTH);
X		if((strlen(passwd)<2)
X		||(strncmp(ntn[0].passwd,passwd,PASSLTH)!=0)){
X			beep();
X			printf("\ninvalid super user password\n");
X		} else break;
X  	}
X
X	strncpy(ntn[0].passwd,crypt(passwd,SALT),PASSLTH);
X	while(TRUE) {
X		printf("\nplease enter the size of the world\n");
X
X		printf("values should be divisible by 8 & greater than 23\n");
X		printf("Enter number of X sectors: ");
X		gets( passwd );
X		world.mapx = atoi( passwd );
X		if(((world.mapx % 8) != 0 ) || (world.mapx<24)){
X			printf("ERROR: Invalid value entered\n");
X			continue;
X		}
X		printf("Enter number of Y sectors: ");
X		gets( passwd );
X		world.mapy = atoi( passwd );
X		if(((world.mapy % 8) != 0 ) || (world.mapy<24)){
X			printf("ERROR: Invalid value entered\n");
X			continue;
X		}
X		break;
X	}
X
X	getspace();	/* malloc space for this world */
X
X	/* get amount of water to have in the world */
X	while(TRUE) {
X		printf("\nEnter percent water to have in world (0-100): ");
X		gets( passwd );
X		pwater = (-1);
X		pwater = atoi( passwd );
X		if((pwater<0) || (pwater>100 )){
X			printf("ERROR: Invalid value entered\n");
X			continue;
X		}
X		break;
X	}
X
X	if( rflag==FALSE ) createworld();
X	else readmap();	/* read map in from mapfiles */
X	rawmaterials();
X	verifydata(__FILE__,__LINE__);
X	writedata();
X
X	/* initialize news file */
X	sprintf(newstring,"%s0",newsfile);
X	if( (fm=fopen(newstring,"w"))!=(FILE *)NULL ) {
X		fprintf(fm,"1\tIMPORTANT WORLD NEWS\n");
X		fprintf(fm,"5\tGLOBAL ANNOUNCEMENTS\n");
X		fclose(fm);
X	} else {
X		fprintf(stderr,"error opening news file <%s>\n",newstring);
X	}
X}
X
Xvoid
Xcreateworld()	/* create world */
X{
X	int	i,j;
X	register int x,y;
X	int	n;		/*count used in string searches*/
X	float	avvalue;	/*Average water tvalue of sectors*/
X	int	number[5];	/*Number of sectors with type=[0-4]*/
X	int	alloc = NUMAREAS * 2;	/*Value Allocated*/
X	char	**tplace;	/*Temp: to see if an area is placed*/
X	int	X, Y, chance;
X	int	X1,Y1;
X	int	X2,Y2;
X	int	valid;
X	int	rnd;
X	long	nmountains;
X
X	tplace = (char **) m2alloc(MAPX,MAPY,sizeof(char));
X	area_map = (char **) m2alloc(MAPX,MAPY,sizeof(char));
X	type = (char **) m2alloc(MAPX,MAPY,sizeof(char));
X
X	printf("\n\ncreating world\n");
X	printf("\tin the beginning, the world was a set of bits ordered in\n");
X	printf("\ta random way.  Then the conquer game administrator (hereafter\n");
X	printf("\tknown as god) decreed 'conqrun -m'!!!\n");
X	printf("\nday 1... and the variables were initialized\n\n");
X	/*initialize variables */
X	avvalue = (((float) (100-pwater)/25.0)); /*Average water tvalue of sectors*/
X	for(i=0;i<MAXX;i++) for(j=0;j<MAXY;j++)
X		tplace[i][j] = area_map[i][j] = 0;
X
X	for(i=0;i<MAPX;i++) for(j=0;j<MAPY;j++) sct[i][j].vegetation=NONE;
X
X	for(i=0;i<5;i++) number[i] = NUMAREAS/5;  /*areas with type=[i]*/
X	number[2]=NUMAREAS - 4*number[0]; /*correct for roundoff*/
X
X	/*determine # of area types to areas*/
X	for(i=0;i<250;i++) {
X		if((avvalue*NUMAREAS)>alloc) {
X			/*have not allocated high enough so Allocate more */
X			x = rand()%4;   /*0 to 3*/
X			if(number[x]>0) {
X				number[x] = number[x] - 1;
X				number[x+1] = number[x+1] + 1;
X				alloc = alloc + 1;
X			}
X		}
X		else	{
X			/*have allocated too much  Allocate less */
X			x = (rand()%4) +1; /*1 to 4*/
X			if(number[x]>0) {
X				number[x] = number[x] - 1;
X				number[x-1] = number[x-1] + 1;
X				alloc = alloc - 1;
X			}
X		}
X	}
X
X	i=0;
X	while((number[4]>0)&&(i<500)) {
X		i++;
X		/*place a full land sector anywhere but on edge*/
X		X = ((rand()%(MAXX-2))+1); /*1 to MAXX-2)*/
X		Y = ((rand()%(MAXY-2))+1); /*1 to MAXY-2)*/
X		if(tplace[X][Y] == 0) {
X			tplace[X][Y]=1;
X			area_map[X][Y]=4;
X			number[4]=number[4] - 1;
X			/*place surrounding sectors*/
X			if(tplace[X+1][Y] == 0) {
X				rnd = rand()%100 + 1; /*1 to 100*/
X				if((rnd<25) && (number[4]>0)) {
X					area_map[X+1][Y]=4;
X					number[4]=number[4]-1;
X					tplace[X+1][Y]=1;
X				}
X				if(rnd>25 && number[3]>0) {
X					area_map[X+1][Y]=3;
X					number[3]=number[3]-1;
X					tplace[X+1][Y]=1;
X				}
X			}
X			if(tplace[X-1][Y] == 0) {
X				rnd = rand()%100 + 1 ; /*(1 to 100)*/
X				if(rnd<25 && number[4]>0) {
X					area_map[X-1][Y]=4;
X					number[4]=number[4]-1;
X					tplace[X-1][Y]=1;
X				}
X				if(rnd>25 && number[3]>0) {
X					area_map[X-1][Y]=3;
X					number[3]=number[3]-1;
X					tplace[X-1][Y]=1;
X				}
X			}
X			if(tplace[X][Y+1] == 0) {
X				rnd = rand()%100 + 1 ; /*(1 to 100)*/
X				if(rnd<25 && number[4]>0) {
X					area_map[X][Y+1]=4;
X					number[4]=number[4]-1;
X					tplace[X][Y+1]=1;
X				}
X				if(rnd>25 && number[3]>0) {
X					area_map[X][Y+1]=3;
X					number[3]=number[3]-1;
X					tplace[X][Y+1]=1;
X				}
X			}
X			if(tplace[X][Y-1] == 0) {
X				rnd = rand()%100 + 1 ; /*(1 to 100)*/
X				if(rnd<25 && number[4]>0) {
X					area_map[X][Y-1]=4;
X					number[4]=number[4]-1;
X					tplace[X][Y-1]=1;
X				}
X				if(rnd>25 && number[3]>0) {
X					area_map[X][Y-1]=3;
X					number[3]=number[3]-1;
X					tplace[X][Y-1]=1;
X				}
X			}
X		}
X	}
X
X	/* place all other areas*/
X	for(X=0;X<MAXX;X++) for(Y=0;Y<MAXY;Y++) {
X		while(tplace[X][Y] == 0) {
X			rnd = rand()%5; /*(0 to 4)*/
X			if(number[rnd]>0) {
X				area_map[X][Y]=rnd;
X				number[rnd]=number[rnd]-1;
X				tplace[X][Y]=1;
X			}
X		}
X	}
X
X	/*ALL AREAS PLACED, NOW DETERMINE SECTOR TYPE
X *fill in each area with sectors
X *      1)   water
X *      2)   water with major islands (25% land)
X *      3)   50/50 water/land
X *      4)   land with major water (75% Land)
X *      5)   land
X */
X	for(Y=0;Y<MAXY;Y++) for(X=0;X<MAXX;X++) {
X		/*fill in edges*/
X		fill_edge(X,Y);
X		/*fill in center*/
X		for(i=1;i<7;i++) {
X			for(j=1;j<7;j++) switch(area_map[X][Y]){
X
X			case 0:
X				if((rand()%100) < 95) type[X*8+i][Y*8+j]=WATER;
X				else type[X*8+i][Y*8+j]=HALF;
X				break;
X			case 1:
X				if(rand()%2 == 0) type[X*8+i][Y*8+j]=WATER;
X				else type[X*8+i][Y*8+j]=HALF;
X				break;
X			case 2:
X				if (rand()%2 == 0) type[X*8+i][Y*8+j]=WATER;
X				else type[X*8+i][Y*8+j]=LAND;
X				break;
X			case 3:
X				if (rand()%2 == 0) type[X*8+i][Y*8+j]=LAND;
X				else type[X*8+i][Y*8+j]=HALF;
X				break;
X			case 4:
X				if ((rand()%100) < 95) type[X*8+i][Y*8+j]=LAND;
X				else type[X*8+i][Y*8+j]=HALF;
X				break;
X			default:
X				fprintf(stderr,"ERROR\n");
X				abrt();
X			}
X		}
X	}
X
X	/*calculate all 50% areas*/
X	for(X=0;X<MAPX;X++) for(Y=0;Y<MAPY;Y++) {
X		if(type[X][Y] == HALF)
X			if(rand()%100 >= (100-pwater)) {
X				type[X][Y] = LAND;
X			}
X			else type[X][Y] = WATER;
X	}
X
X	chance=0;
X	for(X=0;X<MAPX;X++) for(Y=0;Y<MAPY;Y++)
X		if(type[X][Y] == WATER) chance++;
X	printf("day 2... and god decreed that water should have %d / %d sectors\n",chance,NUMSECTS);
X
X	/*Newly added code to smooth the world out*/
X	for(X=1;X<MAPX-1;X++) for(Y=1;Y<MAPY-1;Y++) {
X		chance = 0;
X		/*count # of land and sea sides*/
X		for(i=X-1;i<=X+1;i++) for(j=Y-1;j<=Y+1;j++)
X			if(type[i][j] == LAND) chance++;
X		if(rand()%9 < chance) type[X][Y] = LAND;
X		else type[X][Y] = WATER;
X	}
X	chance=0;
X	for(X=0;X<MAPX;X++) for(Y=0;Y<MAPY;Y++)
X		if(type[X][Y] == WATER) chance++;
X	printf("\tbut god was not pleased and smoothed the oceans to %d / %d sectors\n\n",chance,NUMSECTS);
X
X	/*Adjust world given sectors as land or sea, place vegetation,
X	designation, and altitude */
X
X	for(i=0;i<MAPX;i++) for(j=0;j<MAPY;j++)
X		if(type[i][j]==LAND) sct[i][j].altitude = CLEAR;
X		else sct[i][j].altitude = WATER;
X
X	/* place  */
X	avvalue	= PMOUNT * (100-pwater);
X	avvalue	/= 10000;
X	nmountains	= NUMSECTS * avvalue;
X	printf("day 3... god created %ld mountains and hills\n",nmountains);
X
X	/* heuristic says that 5 is cutoff number to stop placing ranges */
X	/* and 1 third of mountains are placed as random hills		*/
X	while(nmountains>5 && nmountains> (NUMSECTS*avvalue)/3) {
X		X1 = rand()%(MAPX-8);	/* Place one endpoint of range */
X		Y1 = rand()%(MAPY-8);
X		X2 = (rand()%8) + X1;	/* Place second endpoint */
X		Y2 = (rand()%8) + Y1;
X
X		valid = FALSE;
X		for(x=X1;x<=X2;x++){
X			if(X1<X2)	y=((Y2-Y1)*(x-X1)/(X2-X1))+Y1;
X			else		y=Y1;
X			for(j=y-2;j<=y+2;j++) if(j>=0)
X			if( type[x][j] != LAND && rand()%2==0 ) {
X				valid = TRUE;
X				break;
X			}
X		}
X		if( valid==TRUE) continue;
X
X		/*fill in mountain range:
X			 	y-2	y-1	y	y+1	y+2
X			%peak	0	10	20	10	0
X			%mtn	10	40	80	40	10
X			%hill	40	30	0	30	40
X		*/
X		for(x=X1;x<=X2;x++) {
X			if(X1<X2)	y=((Y2-Y1)*(x-X1)/(X2-X1))+Y1;
X			else		y=Y1;
X
X			if(type[x][y] == LAND){
X				if(rand()%100>80) {	TOPEAK(x,y);
X				} else {		TOMT(x,y) 
X				}
X			}
X
X			if((y < MAPY - 1) && type[x][y+1] == LAND) {
X				rnd=rand()%100+1;
X				if(rnd>90) {		TOPEAK(x,y+1);
X				} else if(rnd>50) {	TOMT(x,y+1);
X				} else if(rnd>20) {	TOHILL(x,y+1);
X				}
X			}
X			if((y!=0) && type[x][y-1] == LAND ) {
X				rnd=rand()%100+1;
X				if(rnd>90) {		TOPEAK(x,y-1);
X				} else if(rnd>50) {	TOMT(x,y-1);
X				} else if(rnd>20) {	TOHILL(x,y-1);
X				}
X			}
X			if((y>=2)
X			&&(type[x][y-2] == LAND )) {
X				rnd=rand()%100+1;
X				if(rnd>90) { 		TOMT(x,y-2);
X				} else if(rnd>50){	TOHILL(x,y-2);
X				}
X			}
X			if((y < MAPY - 2)
X			&&(type[x][y+2] == LAND )) {
X				rnd=rand()%100+1;
X				if(rnd>90) {		TOMT(x,y+2);
X				} else if(rnd>50) {	TOHILL(x,y+2);
X				}
X			}
X		}
X	}
X
X	/*fill in random hills to work out,not to left of to water*/
X	while(nmountains>0) {
X		x = rand()%(MAPX-1);
X		y = rand()%(MAPY-1);
X		if((type[x][y]==LAND)&&(type[x+1][y]==LAND))
X			TOHILL(x,y);
X	}
X
X	/*make sure no peak or mountain is next to water*/
X	for(y=1;y<MAPY-1;y++) for(x=1;x<MAPX-1;x++)
X		if((sct[x][y].altitude==PEAK)
X		||(sct[x][y].altitude==MOUNTAIN))
X			for(i=0;i<=2;i++) for(j=0;j<=2;j++)
X				if(sct[x+i-1][y+j-1].altitude==WATER)
X					sct[x][y].altitude=HILL;
X
X	/*FIGURE OUT SECTOR VEGETATION TYPE
X *use sector.altitude, and sector to determine vegetation
X *from water is distance from nearest water
X */
X
X	for(x=0;x<MAPX;x++) for(y=0;y<MAPY;y++)
X		if(type[x][y]==LAND)
X		{
X			sct[x][y].vegetation=(*(veg+3+rand()%5));
X			/*if hill then decrement vegetation*/
X			if(sct[x][y].altitude==HILL) {
X				for(n=3;n<9;n++)
X					if(sct[x][y].vegetation==(*(veg+n)))
X						sct[x][y].vegetation=(*(veg+n-1));
X				if(area_map[x/8][y/8]<=1) sct[x][y].vegetation=VOLCANO;
X			}
X			else if(sct[x][y].altitude==MOUNTAIN)
X				if((rand()%6==4)&&((y>MAPY/2+8)||(y<MAPY/2-8)))
X					sct[x][y].vegetation=ICE;
X				else sct[x][y].vegetation=(*(veg+2+rand()%3));
X			else if(sct[x][y].altitude==PEAK)
X				if((rand()%3==0)&&((y>MAPY/2+8)||(y<MAPY/2-8)))
X					sct[x][y].vegetation=ICE;
X				else sct[x][y].vegetation=VOLCANO;
X		}
X
X	/*REWORK POLEAR/EQUATORIAL sector.vegetation*/
X	/*Determine which areas are North Pole and Equatorial*/
X	/*polar work*/
X	for(x=0;x<MAPX;x++)
X	{
X		for(y=0;y<6;y++) if(type[x][y]==LAND)
X		{
X			if(rand()%4 == 0) sct[x][y].vegetation = ICE;
X			else for(n=3;n<10;n++)
X				if(sct[x][y].vegetation==(*(veg+n)))
X					sct[x][y].vegetation=(*(veg+(n-1)));
X		}
X		for(y=MAPY-7;y<MAPY;y++) if(type[x][y]==LAND)
X		{
X			if(rand()%4 == 0) sct[x][y].vegetation = ICE;
X			else for(n=3;n<10;n++)
X				if(sct[x][y].vegetation==(*(veg+n)) )
X					sct[x][y].vegetation=(*(veg+(n-1)));
X		}
X	}
X
X	/*insert equator*/
X	for(y=(MAPY/2)-8;y<=(MAPY/2)+8;y++) for(x=0;x<MAPX;x++)
X		if(type[x][y]==LAND)
X			if(rand()%10 ==0) sct[x][y].vegetation=DESERT;
X			/*increment vegetation if between Waste and Jungle*/
X			else for(n=2;n<9;n++)
X				if((sct[x][y].vegetation==(*(veg+n)))
X				&&(sct[x][y].altitude==CLEAR)
X				&&(rand()%4==0))
X				sct[x][y].vegetation=(*(veg+(n+1)));
X
X	for(y=((MAPY/2)-2);y<=((MAPY/2)+2);y++) for(x=0;x<MAPX;x++)
X		if((type[x][y]==LAND)&&(sct[x][y].altitude==CLEAR))
X			if(rand()%10 == 0) sct[x][y].vegetation=DESERT;
X			else if(rand()%10 == 0) sct[x][y].vegetation=JUNGLE;
X			else if(rand()%10 == 0) sct[x][y].vegetation=SWAMP;
X			/*increment vegetation again, but only Waste to Light*/
X			else for(n=2;n<4;n++)
X				if(sct[x][y].vegetation==(*(veg+n)))
X					sct[x][y].vegetation=(*(veg+(n+1)));
X
X	/*expand swamps*/
X	for(y=2;y<MAPY;y++) for(x=2;x<MAPX;x++)
X		if(sct[x][y].vegetation==SWAMP)
X			for(i=0;i<2;i++) for(j=0;j<2;j++)
X				if((type[x-i][y-j]==LAND)&&((rand()%3)==0))
X					sct[x-i][y-j].vegetation=SWAMP;
X	/*expand deserts*/
X	for(y=2;y<MAPY;y++) for(x=2;x<MAPX;x++)
X		if(sct[x][y].vegetation==DESERT)
X			for(i=0;i<2;i++) for(j=0;j<2;j++)
X				if((type[x-i][y-j]==LAND)&&((rand()%3)==0))
X					sct[x-i][y-j].vegetation=DESERT;
X
X	/*change all volcanos to peaks */
X	for(y=1;y<MAPY;y++) for(x=1;x<MAPX;x++)
X		if(sct[x][y].vegetation==VOLCANO) sct[x][y].altitude=PEAK;
X
X	/*make sure no desert is next to water*/
X	for(y=1;y<MAPY-1;y++) for(x=1;x<MAPX-1;x++)
X		if(sct[x][y].vegetation==DESERT)
X			for(i=0;i<=2;i++) for(j=0;j<=2;j++)
X				if(sct[x+i-1][y+j-1].altitude==WATER)
X					sct[x][y].vegetation=LT_VEG;
X
X	free(tplace);
X	free(type);
X	free(area_map);
X}
X
Xvoid
Xrawmaterials() 		 /*PLACE EACH SECTOR'S RAW MATERIALS */
X{
X	int i,j;
X	register int x,y;
X	int X1,Y1;
X	int valid;
X	int nmountains;
X	struct	s_sector	*sptr;
X
X	TURN=1;
X
X	nmountains = 10 * (END_NORMAL+1);
X	for(i=0;i<=END_NORMAL;i++) nmountains -= ( *(tg_value+i) - '0');
X
X	printf("\nday 4... and god placed the worlds raw materials\n");
X	for(y=0;y<MAPY;y++) for(x=0;x<MAPX;x++) {
X
X		sptr = &sct[x][y];
X
X		/*default designations*/
X		sptr->designation=DNODESIG;
X		sptr->tradegood = TG_none;
X
X		/* default setup of sector */
X		sptr->owner = sptr->metal = sptr->jewels = sptr->fortress = 0;
X		sptr->people = 0l;
X
X		if( is_habitable(x,y)==FALSE ) continue;
X
X		/* exotic trade goods !!! */
X		if(rand()%100 < TRADEPCT) {
X			valid = FALSE;
X			if((rand()%100 < METALPCT )||sptr->altitude==MOUNTAIN){
X				getmetal( sptr );	/* metal */
X			} else if((rand()%(100-METALPCT))<JEWELPCT ) {
X				getjewel( sptr );	/* jewel */
X			} else while( valid == FALSE ) { /* random good */
X				j=rand()%nmountains;
X				for(i=0;i<=END_NORMAL;i++) {
X					j -= (10 - ( *(tg_value+i) - '0'));
X					if(j <= 0) break;
X				}	/* 'i' now random trade good type */
X
X				/* fish	- next to water */
X				if(i==TG_fish){
X				for(X1=x-1;X1<=x+1;X1++)for(Y1=y-1;Y1<=y+1;Y1++)
X				if((ONMAP(X1,Y1))
X				&&(sct[X1][Y1].altitude==WATER)){
X					valid=TRUE;
X					break;
X				}
X
X				if(valid==FALSE) continue;
X				}
X
X				/* corn,fruit - should be arable land */
X				if(((i==TG_corn)||(i==TG_fruit))
X				&&(tofood(sptr,0)<6)) continue;
X
X				/* timber,pine,oak - wood/forest */
X				if(((i==TG_timber)||(i==TG_pine)||(i==TG_oak))
X				&&(sptr->vegetation!=FOREST)
X				&&(sptr->vegetation!=WOOD)) continue;
X
X				valid = TRUE;
X				sptr->tradegood = i;
X			}
X			if(sptr->tradegood == TG_none)
X				printf("??? DEBUG -tradegood==NONE\n");
X		}
X	}
X
X	printf("\nday 5... and god decreed that world would be populated\n");
X	printf("\tby all manner of creatures; big ones; little one; fat ones;\n");
X	printf("\tskinny ones; orange ones; turquois ones; bright blue ones\n");
X	printf("\tWAIT!!! god has suddenly realized that smurfs were taking things\n");
X	printf("\ttoo far and stopped creating new ones to place everybody on the map...\n");
X	populate();
X	MERCMEN = ST_MMEN;
X	MERCATT = ST_MATT;
X	MERCDEF = ST_MDEF;
X	printf("\nday 6... and god, who believed in a two day weekend, took off to\n\tthe local pub to celebrate...\n\n");
X	printf("day 7... and god rested (to get rid of that stupid hangover)\n");
X	printf("\tand thought about logging in to see what the world looks like\n");
X	printf("\tand about telling players to add themselves to the game\n");
X	printf("\twith the 'conqrun -a' command.\n");
X}
X
X/*fill: subroutine to fill in a square edges with land or sea*/
Xvoid
Xfill_edge(AX,AY)
X{
X/*      1)   water
X *      2)   water with major islands (25% land)
X *      3)   50/50 water/land
X *      4)   land with major water (75% Land)
X *      5)   land
X */
X	register int i;
X	int edgearea, X0, Y0, X1, Y1, X2, Y2, X3, Y3, X4, Y4;
X	int area;
X
X	X0=AX;
X	Y0=AY;
X	X1=X0-1;
X	Y1=Y0;
X	X2=X0+1;
X	Y2=Y0;
X	X3=X0;
X	Y3=Y0-1;
X	X4=X0;
X	Y4=Y0+1;
X
X	/*NORMALIZE FOR EDGE OF WORLD*/
X	if( X1 < 0 ) X1 = MAXX - 1;
X	if( X2 >= MAXX ) X2 = 0;
X	if( Y3 < 0 ) Y3 = MAXY - 1;
X	if( Y4 >= MAXY ) Y4 = 0;
X
X	area=area_map[X0][Y0];
X	/*fill in south*/
X	edgearea=area_map[X4][Y4];
X	if(area + edgearea > 6) for(i=0;i<8;i++) type[X0*8+i][Y0*8+7] = LAND;
X	else if((area + edgearea)>3) {
X		for(i=0;i<8;i++)
X			if(rand()%2 == 0) type[(X0*8)+i][Y0*8+7] = LAND;
X			else type[(X0*8)+i][Y0*8+7] = WATER;
X	}
X	else for(i=0;i<8;i++) type[(X0*8)+i][Y0*8+7] = WATER;
X	/*fill in east*/
X	edgearea=area_map[X2][Y2];
X	if(area + edgearea > 6) for(i=0;i<8;i++) type[X0*8+7][Y0*8+i] = LAND;
X	else if((area + edgearea)>3) {
X		for(i=0;i<8;i++)
X			if(rand()%2==0) type[X0*8+7][Y0*8+i] = LAND;
X			else type[X0*8+7][Y0*8+i] = WATER;
X	}
X	else for(i=0;i<8;i++) type[X0*8+7][Y0*8+i] = WATER;
X	/*fill in west*/
X	edgearea=area_map[X1][Y1];
X	if(area + edgearea > 6) for(i=0;i<=7;i++) type[X0*8][Y0*8+i] = LAND;
X	else if((area + edgearea)>3) {
X		for(i=0;i<8 ;i++)
X			if(rand()%2==0) type[X0*8][Y0*8+i] = LAND;
X			else type[X0*8][Y0*8+i] = WATER;
X	}
X	else for(i=0;i<8 ;i++) type[X0*8][Y0*8+i] = WATER;
X	/*fill in north*/
X	edgearea=area_map[X3][Y3];
X	if(area + edgearea > 6) for(i=0;i<8 ;i++) type[X0*8+i][Y0*8] = LAND;
X	else if((area + edgearea)>3) {
X		for(i=0;i<8 ;i++)
X			if(rand()%2==0) type[(X0*8)+i][Y0*8] = LAND;
X			else type[(X0*8)+i][Y0*8] = WATER;
X	}
X	else for(i=0;i<8 ;i++) type[(X0*8)+i][Y0*8] = WATER;
X}
X
X/* ALLOCATE POPULATIONS OF THE WORLD*/
Xvoid
Xpopulate()
X{
X	int	i=0,x=0,y=0,j=0,xloc,yloc;
X	int	nvynum=0,armynum=0,points,shipsize,temp,cnum;
X	short	short1,short2;			/*temporary short variables */
X	short	class;
X
X	int	loopcnt=0;	
X	int	pirarmy=0,barbarmy=0,nomadarmy=0,lizarmy=0; 
X	short	npirates=0,nbarbarians=0,nnomads=0,nlizards=0;
X
X	FILE *fp, *fopen();
X	int done=FALSE;
X	char line[80],allign;
X	char fname[80];
X
X	/*set up god but dont place*/
X	curntn = &ntn[0];
X	strcpy(curntn->name,"unowned");
X	strcpy(curntn->leader,"god");
X	curntn->race=GOD;
X	curntn->location=GOD;
X	curntn->powers=KNOWALL;	/* so god can see the map */
X	curntn->powers|=NINJA;	/* so god can see exact unit numbers */
X	curntn->mark='-';
X
X	for( country=1; country<NTOTAL; country++ ) {
X		curntn = &ntn[country];
X		if( isactive( curntn->active )) {
X			printf("THIS SHOULDNT HAPPEN\n");
X			continue;
X		}
X		strcpy(curntn->passwd,ntn[0].passwd);
X		curntn->powers=0;
X		curntn->repro=0;
X		curntn->active=INACTIVE;
X		curntn->maxmove=0;
X		curntn->mark='-';
X	}
X
X	for( country=1; country<NTOTAL; country++ ) {
X		for(i=country+1;i<NTOTAL;i++) {
X			ntn[country].dstatus[i]=UNMET;
X			ntn[i].dstatus[country]=UNMET;
X		}
X	}
X
X#ifdef MONSTER
X	for( country=NTOTAL-1; country>=NTOTAL-4; country-- ) {
X		curntn = &ntn[country];
X		if( country==NTOTAL-1 ) {
X			strncpy(curntn->name,"lizard",10);
X			strncpy(curntn->leader,"dragon",10);
X			curntn->active=NPC_LIZARD;
X			curntn->race=LIZARD;
X		} else if( country==NTOTAL-2 ) {
X			strcpy(curntn->name,"savages");
X			strcpy(curntn->leader,"shaman");
X			curntn->active=NPC_BARBARIAN;
X			curntn->race=BARBARIAN;
X		} else if( country==NTOTAL-3 ) {
X			strcpy(curntn->name,"nomad");
X			strcpy(curntn->leader,"khan");
X			curntn->active=NPC_NOMAD;
X			curntn->race=NOMAD;
X		} else if( country==NTOTAL-4 ) {
X			strcpy(curntn->name,"pirate");
X			strcpy(curntn->leader,"captain");
X			curntn->active=NPC_PIRATE;
X			curntn->race=PIRATE;
X		}
X
X		curntn->aplus=0;
X		curntn->dplus=0;
X		curntn->powers=KNOWALL;
X		curntn->mark='*';
X		curntn->maxmove=12;
X		curntn->repro=5;
X
X		/* everybody hates monster nations */
X		if(ismonst(ntn[country].active)) 
X		for(i=1;i<NTOTAL;i++) {
X			ntn[country].dstatus[i]=WAR;
X			ntn[i].dstatus[country]=WAR;
X		}
X	}
X
X	/* create one inhabitant per MONSTER sectors */
X	temp = (NUMSECTS)/MONSTER;
X	while( temp-- >0 ) switch( rand()%4 ) {
X		case 0: if(npirates < MAXNAVY )		npirates++;
X			break;
X		case 1: if(nbarbarians < MAXARM )	nbarbarians++;
X			break;
X		case 2: if(nnomads < MAXARM )		nnomads++;
X			break;
X		case 3: if(rand()%3==0) {
X				if(nlizards < MAXARM/2 ) nlizards++;
X			} else	if(nnomads < MAXARM )	nnomads++;
X			break;
X	}
X	printf("placing %d lizards, %d pirates, %d barbarians, and %d nomads\n",
X		nlizards,npirates,nbarbarians,nnomads);
X
X	while((nlizards+npirates+nbarbarians+nnomads > 0 )&&(loopcnt++ <5000)) {
X		if( nlizards>0 ) {
X			for(country=1;country<NTOTAL;country++)
X				if( ntn[country].active == NPC_LIZARD ) break;
X			armynum=lizarmy;
X		} else	if( nbarbarians>0 ) {	
X			for(country=1;country<NTOTAL;country++)
X				if( ntn[country].active==NPC_BARBARIAN ) break;
X			armynum=barbarmy;
X		} else	if( nnomads>0 )	 {	
X			for(country=1;country<NTOTAL;country++)
X				if( ntn[country].active == NPC_NOMAD ) break;
X			armynum=nomadarmy;
X		} else	if( npirates>0 ) {
X			for(country=1;country<NTOTAL;country++)
X				if( ntn[country].active == NPC_PIRATE ) break;
X			armynum=pirarmy;
X		}
X
X		curntn = &ntn[country];
X
X		/*50% chance will be close to map edge, else anywhere*/
X		if((rand()%2==0)&&(curntn->active!=NPC_LIZARD)){
X			if(rand()%2==0) {
X				x=(rand()%20);
X			} else {
X				x=(MAPX-(rand()%20)-1);
X				y=(MAPY-(rand()%20)-1);
X			}
X			if(rand()%2==0) x = rand()%MAPX;
X			else y = rand()%MAPY;
X		} else {
X			x = rand()%MAPX;
X			y = rand()%MAPY;
X		}
X
X		if(sct[x][y].owner!=0)	continue;
X		if(!is_habitable(x,y))	continue;
X
X		sct[x][y].owner = country;
X
X		/* now place people*/
X		switch( curntn->active ) {
X		case NPC_LIZARD:
X			nlizards--;
X			sct[x][y].designation = DFORT;
X			sct[x][y].metal = 0;
X			sct[x][y].jewels = 8 + (i=rand()%20);
X			sct[x][y].tradegood = TG_platinum;
X			/* make fortificaton consistant with gold */
X			sct[x][y].fortress = 5+i/4;
X			for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++)
X				if((ONMAP(i,j))&&(sct[i][j].altitude!=WATER))
X					sct[i][j].owner = country;
X			P_AMOVE=0;
X			P_AXLOC=x;
X			P_AYLOC=y;
X			P_ASTAT=GARRISON;
X			P_ASOLD=750+100*(rand()%10);
X			P_ATYPE=defaultunit(country);
X			armynum++;
X			lizarmy++;
X			P_AMOVE=8;
X			P_AXLOC=x;
X			P_AYLOC=y;
X			P_ASTAT=ATTACK;
X			P_ASOLD=750+100*(rand()%10);
X			P_ATYPE=defaultunit(country);
X			lizarmy++;
X			break;
X		case NPC_PIRATE:
X			/* pirates must be on islands */
X			temp=TRUE;
X			for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++) 
X				if((ONMAP(i,j)) && ( x!=i || y!=j)
X				&&( sct[i][j].altitude!=WATER)) {
X					/* fifty percent chance of failure */
X					/* for every non-land sector       */
X					if (sct[i][j].owner!=0 || rand()%2==0)
X						temp=FALSE;
X				}
X
X			if(temp==FALSE) {
X				sct[x][y].owner = 0;
X				break;
X			}
X
X			/* build the island */
X			for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++)
X			if((ONMAP(i,j)) && ( x!=i || y!=j))
X			if( sct[i][j].altitude!=WATER ) {
X				sct[i][j].altitude=WATER;
X				sct[i][j].vegetation=WATER;
X				sct[i][j].tradegood=TG_none;
X				sct[i][j].jewels=0;
X				sct[i][j].metal=0;
X			}
X
X			npirates--;
X			sct[x][y].designation = DBASECAMP;
X			P_AMOVE=8;
X			P_AXLOC=x;
X			P_AYLOC=y;
X			P_ASTAT=ATTACK;
X			P_ASOLD=150+100*(rand()%3);
X			P_ATYPE=defaultunit(country);
X			pirarmy++;
X			P_NXLOC=x;
X			P_NYLOC=y;
X			P_NPEOP=0;
X			P_NARMY=MAXARM;
X			shipsize = N_LIGHT;
X			(void) NADD_WAR( rand()%5+2 );
X			shipsize = N_MEDIUM;
X			(void) NADD_WAR( rand()%3+1 );
X			shipsize = N_HEAVY;
X			(void) NADD_WAR( rand()%2 );
X			P_NCREW=SHIPCREW;
X			nvynum++;
X			break;
X		case NPC_NOMAD:
X			nnomads--;
X			P_AXLOC=x;
X			P_AYLOC=y;
X			P_ASTAT=ATTACK;
X			P_ASOLD=100+100*(rand()%8);
X			P_ATYPE=defaultunit(country);
X			nomadarmy++;
X			break;
X		case NPC_BARBARIAN:
X			nbarbarians--;
X			P_AXLOC=x;
X			P_AYLOC=y;
X			P_ASTAT=ATTACK;
X			P_ASOLD=100+100*(rand()%4);
X			P_ATYPE=defaultunit(country);
X			barbarmy++;
X			break;
X		}
X	}
X
X	/* put random monsters around the world */
X	for(country=1;country<NTOTAL;country++) {
X		if( ntn[country].active != NPC_BARBARIAN ) continue;
X		curntn = &ntn[country];
X		armynum=barbarmy;
X		if( country!=NTOTAL ) while(armynum<MAXARM) {
X			x = rand()%MAPX;
X			y = rand()%MAPY;
X			if (is_habitable(x,y)&&sct[x][y].owner==0) {
X				sct[x][y].owner = country;
X				if( sct[x][y].jewels==0 ) 
X					getjewel( &(sct[x][y]) );
X				P_AXLOC= x;
X				P_AYLOC= y;
X				P_ASTAT= ATTACK;
X				P_ATYPE= MINMONSTER + rand()%(MAXMONSTER-MINMONSTER+1);
X				P_ASOLD= *(unitminsth+(P_ATYPE%UTYPE));
X				P_AMOVE= 10;
X				armynum++;
X			}
X		}
X	}
X
X	printf("all random population and monsters placed\n");
X#endif MONSTER
X
X	for (i=0;i<MAXHELP;i++) {
X	sprintf(fname,"%s/%s%d",DEFAULTDIR,helpfile,i);
X	if ((fp=fopen(fname,"r"))==NULL) {
X		printf("\tcannot find helpfile <%s>\n",fname);
X		printf("\tplease move it to %s\n",DEFAULTDIR);
X	}
X	}
X
X#ifdef NPC
X	printf("\nDo you want NPC nations in this campaign?");
X	if( getchar()!='y' ) return;
X	if((fp=fopen(npcsfile,"r"))==NULL) {
X		printf("error on read of %s file\n",npcsfile);
X		printf("Do you wish to use default NPC nations file (y or n)?");
X		if(getchar()=='y'){
X		sprintf(line,"%s/%s",DEFAULTDIR,npcsfile);
X		if ((fp=fopen(line,"r"))==NULL) {
X			printf("\nsorry; error on read of %s file\n",line);
X			return;
X		} else printf("\nOK; default nations used\n");
X		} else {
X			printf("\nOK; no NPC nations used\n");
X			return;
X		}
X	}
X	printf("reading npc nation data from file: %s\n",npcsfile);
X	printf("and adding 1 nation per %d land sectors\n",MONSTER);
X
X	cnum=1;
X	while(fgets(line,80,fp)!=NULL) {
X		/*read and parse a new line*/
X		if(line[0]!='#') {
X			xloc = yloc = -1;
X			sscanf(line,"%s %s %c %c %c %hd %hd %hd %ld %ld %d %hd %c %d %d %hd",
X			ntn[cnum].name,ntn[cnum].leader,&ntn[cnum].race,
X			&ntn[cnum].mark,&ntn[cnum].location,&ntn[cnum].aplus,
X			&ntn[cnum].dplus,&short1,&ntn[cnum].tgold,
X			&ntn[cnum].tmil,&points,&short2,&allign,&xloc,&yloc,
X			&class);
X
X			country=cnum;
X			curntn = &ntn[country];
X			if( cnum > MAPX*MAPY/MONSTER*(100-pwater)/100 ) {
X				printf("world too small to add npc nation %d %s\n",cnum,curntn->name);
X				continue;
X			} 
X			if( isactive(ntn[cnum].active) ) {
X				printf("Too few nations permitted in world to add npc nation %d %s\n",cnum,curntn->name);
X				continue;
X			}
X			curntn->class = (short)class;
X			printf("adding npc nation %s (%s)\n",curntn->name,*(Class+curntn->class));
X			curntn->maxmove = short1;
X			curntn->repro = short2;
X			if( allign == 'G' )
X				curntn->active = PC_GOOD;
X			else if( allign == 'N' )
X				curntn->active = PC_NEUTRAL;
X			else if( allign == 'E' )
X				curntn->active = PC_EVIL;
X			else if( allign == 'g' )
X				curntn->active = GOOD_6FREE;
X			else if( allign == 'n' )
X				curntn->active = NEUTRAL_6FREE;
X			else if( allign == 'e' )
X				curntn->active = EVIL_6FREE;
X			else if( allign == 'i' )
X				curntn->active = ISOLATIONIST;
X			else {
X				printf("invalid nation allignment (%c) line is:\n\t%s\n",allign,line);
X				abrt();
X			}
X			strcpy(curntn->passwd,ntn[0].passwd);
X
X			points -= doclass( class, FALSE );
X			points -= startcost();
X			if(points < 10 ) {
X				printf("ERROR IN NATIONS FILE IN NATION %s\n",ntn[cnum].name);
X				printf("nation doesnt have enough points left for 10000 civilians\n");
X				abrt();
X			}
X			curntn->tciv = 1000L * points;
X
X			if(curntn->race==HUMAN){
X				curntn->powers|=WARRIOR;
X				exenewmgk(WARRIOR);
X			} else if(curntn->race==DWARF){
X				curntn->powers|=MINER;
X				exenewmgk(MINER);
X			} else if(curntn->race==ELF){
X				curntn->powers|=THE_VOID;
X				exenewmgk(THE_VOID);
X			} else if(curntn->race==ORC){
X				curntn->powers|=MI_MONST;
X				exenewmgk(MI_MONST);
X			} else {
X				curntn->powers|=WARRIOR;
X				exenewmgk(WARRIOR);
X			}
X			curntn->tfood= curntn->tciv * 3;
X			curntn->metals=10000L;
X			curntn->jewels=10000L;
X			cnum++;
X			place(xloc,yloc);
X			att_setup(country);	/* nation attributes */
X		}
X	}
X	att_base();	/* get nation attributes */
X	printf("all npc nations placed\n");
X#endif NPC
X}
END_OF_FILE
if test 30426 -ne `wc -c <'makeworl.c'`; then
    echo shar: \"'makeworl.c'\" unpacked with wrong size!
fi
# end of 'makeworl.c'
fi
if test -f 'newlogin.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'newlogin.h'\"
else
echo shar: Extracting \"'newlogin.h'\" \(1454 characters\)
sed "s/^X//" >'newlogin.h' <<'END_OF_FILE'
X/*conquer : Copyright (c) 1988 by Ed Barlow. */
X/* initial starting stats */
X
X/*dwarf*/
X#define	NLDGOLD		100000L
X#define	NLDFOOD		35000L
X#define	NLDJEWEL	15000L
X#define	NLDMETAL	15000L
X#define	NLDCIVIL	6000L
X#define	NLDMILIT	1000L
X#define	NLDREPRO	4
X#define	NLDMMOVE	6
X#define	NLDAPLUS	20
X#define	NLDDPLUS	20
X
X/*elf*/
X#define	NLEGOLD		100000L
X#define	NLEFOOD		35000L
X#define	NLEJEWEL	15000L
X#define	NLEMETAL	15000L
X#define	NLECIVIL	7000L
X#define	NLEMILIT	200L
X#define	NLEREPRO	5
X#define	NLEMMOVE	8
X#define	NLEAPLUS	10
X#define	NLEDPLUS	40
X
X/*orc*/
X#define	NLOGOLD		1000L
X#define	NLOFOOD		35000L
X#define	NLOJEWEL	15000L
X#define	NLOMETAL	15000L
X#define	NLOCIVIL	6000L
X#define	NLOMILIT	2000L
X#define	NLOREPRO	8
X#define	NLOMMOVE	6
X#define	NLOAPLUS	0
X#define	NLODPLUS	0
X
X/*human*/
X#define	NLHGOLD		1000L
X#define	NLHFOOD		35000L
X#define	NLHJEWEL	15000L
X#define	NLHMETAL	15000L
X#define	NLHCIVIL	6000L
X#define	NLHMILIT	1000L
X#define	NLHREPRO	5
X#define	NLHMMOVE	10
X#define	NLHAPLUS	15
X#define	NLHDPLUS	10
X
X/* the purchase definitions and/or costs */
X#define	NLPOP		1000L
X#define	NLGOLD		100000L
X#define	NLLOCCOST	1
X#define	NLSOLD		900L
X#define	NLATTACK	10
X#define	NLDEFENCE	10
X#define	NLREPRO_ORC	2	/* repro points per NLREPCOST for orcs */
X#define	NLREPRO		1	/* repro points per NLREPCOST for others */
X#define	NLREPCOST	3
X#define	NLMOVE		2
X#define	NLDBLCOST	1
X#define	NLMAGIC		3
X/* get NLEADER leaders for NLEADPT points */
X#define	NLEADER		3
X#define	NLEADPT		1
END_OF_FILE
if test 1454 -ne `wc -c <'newlogin.h'`; then
    echo shar: \"'newlogin.h'\" unpacked with wrong size!
fi
# end of 'newlogin.h'
fi
echo shar: End of archive 9 \(of 14\).
cp /dev/null ark9isdone
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