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

billr@saab.CNA.TEK.COM (Bill Randle) (12/22/89)

Submitted-by: Adam Bryant <adb@cs.bu.edu>
Posting-number: Volume 8, Issue 78
Archive-name: conquer4/Patch7c
Patch-To: conquer4: Volume 6, Issue 83-96


#!/bin/sh
# this is part 3 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file patchV4.7 continued
#
CurArch=3
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
     exit 1; fi
( read Scheck
  if test "$Scheck" != $CurArch
  then echo "Please unpack part $Scheck next!"
       exit 1;
  else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file patchV4.7"
sed 's/^X//' << 'SHAR_EOF' >> patchV4.7
X+ 	    {
X+ #ifdef DEBUG
X+ 	    printf("\t need %d monster troops\n",neededtroops);
X+ #endif 
X+ 	    if ( (rand()%8)<5 && nomad_space)
X+ 		{
X+ 		while(!is_habitable((x=(rand()%(MAPX-8))+4),
X+ 				    (y=(rand()%(MAPY-8))+4)))
X+ 		    ;
X+ 		for(i=0;i<MAXARM;i++)
X+ 		    if ( ntn[nomads].arm[i].sold <=0 )
X+ 			goto found_free_nomad_army;
X+ 
X+ #ifdef DEBUG
X+ 		printf("\t\t Out of nomad space\n");
X+ #endif
X+ 		nomad_space=0;
X+ 		continue;
X+ 		
X+ 	    found_free_nomad_army:
X+ 
X+ 		ntn[nomads].arm[i].xloc=x;
X+ 		ntn[nomads].arm[i].yloc=y;
X+ 		ntn[nomads].arm[i].sold=100+100*(rand()%6);
X+ 		ntn[nomads].arm[i].unittyp=A_LT_CAV;
X+ 		ntn[nomads].arm[i].stat=ATTACK;
X+ 		neededtroops -= ntn[nomads].arm[i].sold;
X+ #ifdef DEBUG
X+ 		printf("\t\tAdding nomad army %d size %d at (%d,%d)\n",i,
X+ 		       ntn[nomads].arm[i].sold,x,y);
X+ #endif
X+ 		}
X+ 	    else
X+ 		{
X+ 		do {
X+ 		x=(rand()%(MAPX-8))+4;
X+ 		y=(rand()%(MAPY-8))+4;
X+ 		} while ( sct[x][y].altitude == PEAK ||
X+ 			  sct[x][y].altitude == WATER ||
X+ 			 ( sct[x][y].owner !=0 &&
X+ 			   sct[x][y].owner != savages &&
X+ 			   sct[x][y].people >= 50 ) );
X+ 
X+ 		for(i=0;i<MAXARM;i++)
X+ 		    if ( ntn[savages].arm[i].sold <=0 )
X+ 			goto found_free_savage_army;
X+ 
X+ #ifdef DEBUG
X+ 		printf("\t\t Out of savage space\n");
X+ #endif
X+ 		savage_space=0;
X+ 		continue;
X+ 		
X+ 	    found_free_savage_army:
X+ 
X+ 		ntn[savages].arm[i].xloc=x;
X+ 		ntn[savages].arm[i].yloc=y;
X+ 		ntn[savages].arm[i].sold=100+100*(rand()%3);
X+ 		ntn[savages].arm[i].unittyp=defaultunit(savages);
X+ 		ntn[savages].arm[i].stat=ATTACK;
X+ 		neededtroops -= ntn[savages].arm[i].sold;
X+ #ifdef DEBUG
X+ 		printf("\t\tAdding savage army %d size %d at (%d,%d)\n",i,
X+ 		       ntn[savages].arm[i].sold,x,y);
X+ #endif
X+ 		}
X+ 	    }
X+ 	}
X+ #endif /* MORE_MONST */
X+ 
X  }
X  
X  void
X***************
X*** 177,197 ****
X  			break;
X  		}
X  	}
X- #ifdef MORE_MONST
X- 	/* place a few new Nomad armies */
X- 	for(armynum=0;armynum<MAXARM;armynum++) if(P_ASOLD<=0){
X- 		if(rand()%4!=0) continue;
X- 		x=(rand()%(MAPX-8))+4;
X- 		y=(rand()%(MAPY-8))+4;
X- 		if(is_habitable(x,y)) {
X- 			P_AXLOC=x;
X- 			P_AYLOC=y;
X- 			P_ASOLD=100+100*(rand()%6);
X- 			P_ATYPE=A_LT_CAV;
X- 			P_ASTAT=ATTACK;
X- 		}
X- 	}
X- #endif /* MORE_MONST */
X  }
X  
X  void
X--- 293,298 ----
X***************
X*** 227,251 ****
X  			}
X  		}
X  	}
X- #ifdef MORE_MONST
X- 	/* place a few new savage armies */
X- 	for(armynum=0;armynum<MAXARM;armynum++) if(P_ASOLD<=0){
X- 		x=(rand()%(MAPX-8))+4;
X- 		y=(rand()%(MAPY-8))+4;
X- 		if((rand()%4!=0) 
X- 		||( sct[x][y].altitude == PEAK)
X- 		||( sct[x][y].altitude == WATER))
X- 			continue;
X- 		if(sct[x][y].owner==0 || sct[x][y].owner==country 
X- 		||(sct[x][y].people< 50)) {
X- 			P_AXLOC=x;
X- 			P_AYLOC=y;
X- 			P_ASOLD=100+100*(rand()%3);
X- 			P_ATYPE=defaultunit(country);
X- 			P_ASTAT=ATTACK;
X- 		}
X- 	}
X- #endif /* MORE_MONST */
X  }
X  
X  void
X--- 328,333 ----
X***************
X*** 389,395 ****
X  {
X  	short x,y,armynum,nvynum;
X  	int i, free, done;
X! 	long militia=0l,ideal;
X  	long diff=0l;
X  	int ok;
X  
X--- 471,477 ----
X  {
X  	short x,y,armynum,nvynum;
X  	int i, free, done;
X! 	long ideal;
X  	long diff=0l;
X  	int ok;
X  
X***************
X*** 401,409 ****
X--- 483,495 ----
X  			if(rand()%2==0) P_NCREW = SHIPCREW;
X  	}
X  	check();
X+ 	curntn->tmil = 0L;
X  	for(armynum=1;armynum<MAXARM;armynum++) if(P_ASOLD>0){
X  		/* move army back if too far out */
X  		ok = 0;
X+ 		if (P_ASOLD < MINLEADER && P_ASOLD!=A_MILITIA) {
X+ 			curntn->tmil += P_ASOLD;
X+ 		}
X  		for(x=(int)P_AXLOC-3;x<=(int)P_AXLOC+3;x++)
X  			for(y=(int)P_AYLOC-3;y<=(int)P_AYLOC+3;y++)
X  				if((ONMAP(x,y))&&(sct[x][y].owner==country)) ok=1;
X***************
X*** 412,418 ****
X  			P_AYLOC=curntn->capy;
X  		}
X  
X! 		/* count and verify militia */
X  		if(P_ATYPE==A_MILITIA) {
X  			/* eliminate invalid militia */
X  			if(((sct[P_AXLOC][P_AYLOC].designation!=DTOWN)
X--- 498,504 ----
X  			P_AYLOC=curntn->capy;
X  		}
X  
X! 		/* verify militia */
X  		if(P_ATYPE==A_MILITIA) {
X  			/* eliminate invalid militia */
X  			if(((sct[P_AXLOC][P_AYLOC].designation!=DTOWN)
X***************
X*** 426,432 ****
X  					sct[P_AXLOC][P_AYLOC].people+=P_ASOLD;
X  				else sct[curntn->capx][curntn->capy].people+=P_ASOLD;
X  				P_ASOLD=0;
X! 			} else militia+=P_ASOLD;
X  		}
X  
X  		/* set default status */
X--- 512,518 ----
X  					sct[P_AXLOC][P_AYLOC].people+=P_ASOLD;
X  				else sct[curntn->capx][curntn->capy].people+=P_ASOLD;
X  				P_ASOLD=0;
X! 			}
X  		}
X  
X  		/* set default status */
X***************
X*** 442,453 ****
X  			break;
X  		}
X  	}
X- 	curntn->tmil -= militia;
X  
X  	/*make sure enough men in army 0 -- garrison duty in capitol*/
X  	armynum=0;
X! 	P_ASTAT=GARRISON;
X  	P_ATYPE=defaultunit(country);
X  	P_AXLOC=curntn->capx;
X  	P_AYLOC=curntn->capy;
X  
X--- 528,544 ----
X  			break;
X  		}
X  	}
X  
X  	/*make sure enough men in army 0 -- garrison duty in capitol*/
X  	armynum=0;
X! 	/* find lowest army of non-leader type */
X! 	while (armynum < MAXARM && (P_ATYPE>=MINLEADER && P_ASOLD>0)) {
X! 		armynum++;
X! 	}
X! 	/* oh well... wipe out army zero; c'est la vie */
X! 	if (armynum == MAXARM) armynum = 0;
X  	P_ATYPE=defaultunit(country);
X+ 	P_ASTAT=GARRISON;
X  	P_AXLOC=curntn->capx;
X  	P_AYLOC=curntn->capy;
X  
X***************
X*** 470,481 ****
X  
X  	/*too few soldiers on garrison*/
X  	/*diff is number to change mil in cap (>0)*/
X! 	if(curntn->tgold<0L) diff=0;
X! 	else diff = (long) min(ideal-P_ASOLD,(int) (curntn->metals / *(u_enmetal + (P_ATYPE%UTYPE))));
X  
X  	diff=(long) min((int) diff, sct[curntn->capx][curntn->capy].people/2L);
X  
X! 	if(curntn->tgold<0L || curntn->metals<0L) if(diff > 0L) diff=0;
X  
X  #ifdef DEBUG
X  	printf("\tadding %d men to garrison (too few men on garrison)\n",diff);
X--- 561,572 ----
X  
X  	/*too few soldiers on garrison*/
X  	/*diff is number to change mil in cap (>0)*/
X! 	diff = (long) min(ideal-P_ASOLD,(int) (curntn->metals / *(u_enmetal + (P_ATYPE%UTYPE))));
X  
X  	diff=(long) min((int) diff, sct[curntn->capx][curntn->capy].people/2L);
X  
X! 	if ((curntn->tgold<0L || curntn->metals<0L) && (diff > 0L)) diff=0L;
X! 	if (sct[curntn->capx][curntn->capy].owner != country) diff=0L;
X  
X  #ifdef DEBUG
X  	printf("\tadding %d men to garrison (too few men on garrison)\n",diff);
X***************
X*** 690,695 ****
X--- 781,787 ----
X  			for(armynum=0;armynum<MAXARM;armynum++) if(P_ASOLD==0){
X  				P_AXLOC=x;
X  				P_AYLOC=y;
X+ 				P_ATYPE=A_MILITIA;
X  				free=TRUE;
X  				break;
X  			}
X***************
X*** 711,727 ****
X  			}
X  			}
X  #ifdef DEBUG
X! 		printf("\tadding %ld troops to %s army %d (now %ld men - populace %ld)\n",ideal-P_ASOLD,unittype[P_ATYPE],armynum,ideal,sct[x][y].people);
X  #endif DEBUG
X  			P_ASOLD=ideal;
X- 			P_ATYPE=A_MILITIA;
X  			P_ASTAT=MILITIA;
X  		}
X  	}
X  	check();
X  
X!   	/* setup default units */
X!   	for(armynum=1;armynum<MAXARM;armynum++) 
X  	if((P_ASOLD>0)&&(P_ATYPE!=A_MILITIA)&&(P_ATYPE<MINLEADER)) 
X  		P_ATYPE=defaultunit(country);
X  }
X--- 803,822 ----
X  			}
X  			}
X  #ifdef DEBUG
X! 		printf("\tnow in sector %d,%d\n",x,y);
X! 		printf("\tadding %ld troops to %s army %d (now %ld men - populace %ld)\n",ideal-P_ASOLD,unittype[P_ATYPE%UTYPE],armynum,ideal,sct[x][y].people);
X  #endif DEBUG
X  			P_ASOLD=ideal;
X  			P_ASTAT=MILITIA;
X  		}
X  	}
X  	check();
X+ #ifdef DEBUG
X+ 	printf("\tnow setting all units to default type of %s\n",unittype[defaultunit(country)]);
X+ #endif /*DEBUG*/
X  
X! 	/* setup default units */
X! 	for(armynum=1;armynum<MAXARM;armynum++) 
X  	if((P_ASOLD>0)&&(P_ATYPE!=A_MILITIA)&&(P_ATYPE<MINLEADER)) 
X  		P_ATYPE=defaultunit(country);
X  }
X***************
X*** 1089,1095 ****
X  
X  		spreadsheet(country);
X  
X! 		hunger = spread.food/((float)(spread.civilians+2*curntn->tmil));
X  		if(hunger < P_EATRATE ) {
X  			goldthresh++;
X  			metalthresh++;
X--- 1184,1192 ----
X  
X  		spreadsheet(country);
X  
X! 		if (spread.civilians+2*curntn->tmil > 0) {
X! 			hunger = spread.food/((float)(spread.civilians+2*curntn->tmil));
X! 		} else hunger = 0.0;
X  		if(hunger < P_EATRATE ) {
X  			goldthresh++;
X  			metalthresh++;
X*** otrade.c	Tue Dec 12 21:19:37 1989
X--- trade.c	Tue Dec 12 21:20:12 1989
X***************
X*** 113,119 ****
X  
X  		/* go through list of commodities */
X  		for (holdint=0;holdint<itemnum;holdint++) {
X! 			if (deal[holdint]==SELL) {
X  				count++;
X  				mvprintw(count,0,"%2d) %-20s",
X  					holdint+1,
X--- 113,121 ----
X  
X  		/* go through list of commodities */
X  		for (holdint=0;holdint<itemnum;holdint++) {
X! 			if ((deal[holdint]==SELL) && ((country==0) ||
X! 			(ntn[natn[holdint]].dstatus[country] != UNMET)
X! 			|| (natn[holdint] == country))) {
X  				count++;
X  				mvprintw(count,0,"%2d) %-20s",
X  					holdint+1,
X***************
X*** 197,203 ****
X  				inloop=FALSE;
X  				done=FALSE;
X  				break;
X! 			} else if (holdint<1 || holdint>itemnum) {
X  				tradeerr("Invalid Item Number");
X  				return;
X  			}
X--- 199,206 ----
X  				inloop=FALSE;
X  				done=FALSE;
X  				break;
X! 			} else if (holdint<1 || holdint>itemnum
X! 				|| ntn[natn[holdint - 1]].dstatus[country]==UNMET) {
X  				tradeerr("Invalid Item Number");
X  				return;
X  			}
X*** ocheck.c	Tue Dec 12 21:19:34 1989
X--- check.c	Tue Dec 12 21:20:12 1989
X***************
X*** 50,65 ****
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( a->stat != ONBOARD && 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--- 50,65 ----
X  					__file__, __line__, country, i, a->yloc );
X  				a->yloc = 0;
X  			}
X  			if( a->stat != ONBOARD && 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+ 			if( a->stat == ONBOARD && a->smove > 0) {
X+ 				/* don't echo since this is still getting */
X+ 				/* set some place someplace I can't find yet */
X+ 				a->smove = 0;
X+ 			}
X  		} /* for */
X  
X  		for( i = 0; i < NTOTAL; i++ ) {
X***************
X*** 147,154 ****
X  int	line;
X  char	*file;
X  {
X! 	/* fprintf(stderr,"file %s line %d\n",file,line);  */
X! 	/* verifydata(file,line); */
X  }
X  #endif DEBUG
X  
X--- 147,154 ----
X  int	line;
X  char	*file;
X  {
X! 	fprintf(stderr,"file %s line %d\n",file,line);
X! 	verifydata(file,line);
X  }
X  #endif DEBUG
X  
X***************
X*** 158,163 ****
X--- 158,164 ----
X  #    include <unistd.h>
X  #    define do_lock(fd) lockf(fd,F_TLOCK,0)
X  #else
X+ #    include <sys/types.h>
X  #    include <sys/file.h>
X  #    define do_lock(fd) flock(fd,LOCK_EX|LOCK_NB)
X  #endif
X***************
X*** 192,199 ****
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--- 193,209 ----
X  		exit(FAIL);
X  	}
X  #else
X! 	struct stat fst;
X! 
X! 	if( stat( filename, &fst ) == 0 ) {
X! 		long now;
X! 		now = time(0);
X! 		if (now - fst.st_mtime < TIME_DEAD*3) {
X! 			hold=TRUE;
X! 		} else {
X! 			/* remove useless file */
X! 			unlink(filename);
X! 		}
X  	}
X  	if (hold==FALSE && keeplock==TRUE) {
X  		/* create lock file */
X*** otxt5	Tue Dec 12 21:19:38 1989
X--- txt5	Tue Dec 12 21:20:14 1989
X***************
X*** 216,221 ****
X--- 216,222 ----
X                    between 25%-125% of the tax rate [randomly determined]
X                    plus (poverty - 50)/2 and is then adjusted by the ratio of
X                    military to civilians.
X+               Money lost due to inflation will be indicated in the budget.
X  wealth      = see elsewhere.
X  END
X                  ADDITIONAL MODIFIERS TO NATIONAL ATTRIBUTES
X***************
X*** 222,234 ****
X  
X  MAGIC POWERS ADD OR SUBTRACT 10 FROM POWERS AS FOLLOWS:
X          SLAVER.....terror      ARCHITECT..storerate
X!         RELIGION...popularity  URBAN......-popularity 
X          DEMOCRACY..-terror     ROADS......communication
X          KNOWALL....knowledge   DESTROYER..terror
X          VAMPIRE....terror      
X  
X  CLASSES ADD 30 TO POWERS AS FOLLOWS:
X!         kingdom....popularity    dragon.....terror        
X          wizard.....knowledge     priest.....popularity
X          pirate.....terror        shadow.....terror
X          warlord....prestige      demon......terror
X--- 223,235 ----
X  
X  MAGIC POWERS ADD OR SUBTRACT 10 FROM POWERS AS FOLLOWS:
X          SLAVER.....terror      ARCHITECT..storerate
X!         RELIGION...popularity  URBAN......-popularity
X          DEMOCRACY..-terror     ROADS......communication
X          KNOWALL....knowledge   DESTROYER..terror
X          VAMPIRE....terror      
X  
X  CLASSES ADD 30 TO POWERS AS FOLLOWS:
X!         kingdom....popularity    dragon.....terror
X          wizard.....knowledge     priest.....popularity
X          pirate.....terror        shadow.....terror
X          warlord....prestige      demon......terror
SHAR_EOF
echo "File patchV4.7 is complete"
chmod 0644 patchV4.7 || echo "restore of patchV4.7 fails"
rm -f s2_seq_.tmp
echo "You have unpacked the last part"
exit 0