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

billr@saab.CNA.TEK.COM (Bill Randle) (08/07/89)

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

[[from the author...

This time it is only three shar files.  They unpack into two files:

    display.c    - replace the current display.c with this.
    patchV4.04   - patch file for remainder of files.

Here are some notes about patch #4:

   -it fixes the following bugs:
      = new nations being unable to fight monsters.
      = a number of bugs dealing with the demi-god routines.
      = an overflow bug due to mathematical ordering in newlogin.c.
      = a miscalculation on npctype definition resulting in a core dump
         in some instances.
      = npc nations being able to move through neutral territory.
      = npc nations being able to disband or group Zombies.
      = armies disappearing off of ships.  [damn stupid oversite
         on that one.]
      = XENIX bugs fixed.
      = password entry using gets() during curses mode.

    -it makes the following additions:
      = full dual display mode via the 'd/' command.
      = the man.pag was made up to date.
      = makeworld is now done through curses.
      = map print out routines enhanced and moved to 'conquer'.
      = NOSCORE option to limit amount of information displayed on
         score lists.
      = REMAKE compiler option to allow rebuilds of worlds without
         having to delete the data file.  This will also work for
         demi-gods.
      = MORE_MONST option now makes rebirth of monsters a compilation
         selection.

    -THINGS TO COME NEXT PATCH:
      = a set of conquer map manipulation programs:

       one for the sun to display the images to the screen.   [rjc]
         [Would have released this a while ago, but I can't test
         it yet, since I have not installed conquer on our suns]
       one for PostScript to generate nice looking maps.      [MaF]
         [Have seen the preliminary output of this and I am impressed,
         hopefully it will be totally finished in a few days]

      = some bug fixes.  [can't be specific, since I haven't
         heard the bug reports for this patch yet ;-)]

Once again you can find out a full list of what I was up to
by looking at the patched notes.v4 file.
 
adam ]]
=================================================================

And here is the first of three shar files:

=================================================================

#!/bin/sh
# shar:	Shell Archiver  (v1.22)
#
# This is part 1 of a multipart archive                                    
# do not concatenate these parts, unpack them in order with /bin/sh        
#
#	Run the following text with /bin/sh to create:
#	  patchV4.04
#	  display.c
#
if test -r s2_seq_.tmp
then echo "Must unpack archives in sequence!"
     next=`cat s2_seq_.tmp`; echo "Please unpack part $next next"
     exit 1; fi
sed 's/^X//' << 'SHAR_EOF' > patchV4.04 &&
X*** opatchlevel.h	Sun Aug  6 20:55:35 1989
X--- patchlevel.h	Sun Aug  6 20:55:41 1989
X***************
X*** 1 ****
X! #define PATCHLEVEL	3
X--- 1 ----
X! #define PATCHLEVEL	4
X*** onotes.v4	Sun Aug  6 20:55:35 1989
X--- notes.v4	Sun Aug  6 20:55:41 1989
X***************
X*** 102,114 ****
X   66. rewrote all routines that were called during a newlogin so that print
X  	statments use the newerror() or newmsg() interface.
X  ===4.0 patch number three released => 4.3 ==========================
X  
X  -------------------------------------------------------------------------
X  | 2.0 POSSIBLE SHORT-TERM ENHANCEMENTS/FIXES FOR CONQUER V4             |
X  -------------------------------------------------------------------------
X  o make land capture only occur during update.
X! o make the create world routine interactive with curses display.
X! o make the newlogin routine interactive with curses display.
X  o fix the helpfiles to reflect current changes in game as noted later in this
X  	file.
X  o there is some overflow somewhere, which creates a huge amount of gold
X--- 102,169 ----
X   66. rewrote all routines that were called during a newlogin so that print
X  	statments use the newerror() or newmsg() interface.
X  ===4.0 patch number three released => 4.3 ==========================
X+  67. fixed a bug reported long ago.. negative treasury and charity.
X+ 	I get too damn much mail.  [I just sent #3 out!!!!]
X+  68. main.c(798): "%s%s" to "%s%d"... fixes bug in sprintf.
X+  69. added sprinf(defaultdir,"") to main.c and admin.c.
X+  70. put test on error messages in place() to make sure it won't call newerror.
X+  71. moved the '-p' option from admin.c to main.c.
X+  72. made error messages in main.c go to stderr instead of stdout.
X+  73. made the '-p' flag display world as seen by nations eyes.
X+  74. made the designation portion of the display print elevation when NODESIG.
X+  75. added fix to make sure that demi-god exists.  [Richard Caley]
X+  76. added check to makeworld to make sure given demi-god name exists.
X+  76. also added a check to forms.c for demi-god name change.
X+  76. added checks for ORCTAKE definitions to newhelp.c [Jerome Marella]
X+  77. added a CURRENT directory definition to Makefile. [Kevin Coombes]
X+  78. fixed bugs in XENIX defines. [Jonathan Bayer]
X+  79. display.c(301): "+" -> '+'; I thought I fixed this *sigh*. [Richard Caley]
X+  80. added a REMAKE compiler option to allow destruction of currently running
X+ 	games.  This is usable by demi-god to restart a campaign.
X+  81. fixed up the man page.
X+  82. wrote a non-echo string entry routine for curses password entry.
X+  83. added above routine to newlogin.c, makeworl.c, and forms.c.
X+  84. removed restriction on changing to NPC after making moves.
X+ 	This makes sense... since players may move NPC pieces anyway.
X+  85. changed the makeworld routine to curses interface.  This is still
X+ 	rather rudimentary, and will be worked on prior to Version 5.0.
X+  86. added NADJLOC; to the two split sections in reports.c:fleetrpt().
X+  87. corrected misspelling of alignment throughout code.
X+  88. added check to land_reachp() for neutral status.  [Michael D. Smith]
X+  89. added MORE_MONST compiler option to decide whether or not empty
X+ 	monster armies should be filled during the game.
X+  90. fixed misspelling of 'defence' in npc.c and txt4.
X+  91. fixed overflow of jewels and metal displaying in newlogin.c.
X+  92. *&$%! fixed a stupid bug with checking if leader is really dead.
X+  93. added a 'shipchk' to the prep routine.  hopefully will fix land taking.
X+  94. added a redraw after movement if in army highlight mode.
X+  95. added in new method for displaying anything in 2nd column. [Richard Caley]
X+  96. tweeked the prompting for the second column display method.
X+  97. rewrote the section in the help files on the display mode.
X+  98. fixed major bug with destroying any army in water.  [Ben Herman]
X+ 	Another bug I thought I fixed long ago. *sigh*
X+  99. newlogin.c(1034):  typo caused nations to be too close. [Wes Shreiner]
X+ 100. decrease range of nomad movement to 1 sector from locaton.
X+ 101. removed the shipchk from prep()... didn't do jack anyway.
X+ 102. hacked at the display code some to fix redeclarations and unused vars.
X+ 103. fixed the bug with not being able to take sectors.  involved status
X+ 	of nations not being at WAR with nomads.  fixed this by setting
X+ 	statuses in three places:  destroy(), place(), check().
X+ 104. fixed seg fault when entering change() for savages.
X+ 105. removed the printing to fp in change() routine.
X+ 106. changed npctype to detect monsters, otherwise it core dumps.
X+ 107. changed the alignment printing for savages back to what it was.
X+ 108. made sure that NPCs do not group or disband ZOMBIES.
X+ 109. added a NOSCORE compiler option to allow only god to see full score list.
X+ 110. changed the class name NPC to monster.
X  
X  -------------------------------------------------------------------------
X  | 2.0 POSSIBLE SHORT-TERM ENHANCEMENTS/FIXES FOR CONQUER V4             |
X  -------------------------------------------------------------------------
X  o make land capture only occur during update.
X! o some problems due to two nations capturing same land.  should fix by above.
X! o some problems with MINER not providing initial stats on first turn after
X! 	nation has been added.
X  o fix the helpfiles to reflect current changes in game as noted later in this
X  	file.
X  o there is some overflow somewhere, which creates a huge amount of gold
X*** oMakefile	Sun Aug  6 20:55:33 1989
X--- Makefile	Sun Aug  6 20:55:41 1989
X***************
X*** 3,8 ****
X--- 3,11 ----
X  #	BY CHANGING THIS FILE, YOU AGREE TO ABIDE BY THE LIMITATIONS STATED IN
X  #	THE LIMITED USE CONTRACT CONTAINED IN THE FILE "header.h"
X  #
X+ #	Make sure to set your desired configuration by
X+ #	editing the file "header.h".
X+ #
X  #       This makefile has been modified to allow compilation using
X  #       a parallelized make program.  It has been used successfully
X  #       on an Encore Multimax parallel computer with both 4 and
X***************
X*** 13,18 ****
X--- 16,23 ----
X  #       Please report any problems to adb@bucsf.bu.edu
X  #				   or adb@bu-cs.bu.edu
X  #
X+ #	Conquer news mailing list: conquer-news-request@bu-cs.bu.edu.
X+ #
X  MAKE	= /bin/make
X  CC	= /bin/cc
X  RM      = /bin/rm -f
X***************
X*** 44,53 ****
X  #	of conquer.  [not distributed with conquer V4]
X  #GETOPT	= getopt.o
X  
X! #if the final link does not compile change to the line below
X  LIBRARIES = -lcurses -ltermcap
X  #LIBRARIES = -lcurses
X  
X  #	DEFAULT is the directory where default nations & help files will be 
X  #	stored.	 It is also the default directory = where players will play 
X  #	if they do not use the -d option.
X--- 49,68 ----
X  #	of conquer.  [not distributed with conquer V4]
X  #GETOPT	= getopt.o
X  
X! #
X! #	libraries for BSD systems:
X  LIBRARIES = -lcurses -ltermcap
X+ #
X+ #	libraries for SYSV systems:
X  #LIBRARIES = -lcurses
X+ #
X+ #	libraries for Xenix systems:
X+ #LIBRARIES = -ltermlib -ltcap -lcrypt
X  
X+ #	CURRENT is this directory.  The directory where the source
X+ #	and Makefile are located
X+ CURRENT = /usr4/acm/stud/adb/src/conquer
X+ 
X  #	DEFAULT is the directory where default nations & help files will be 
X  #	stored.	 It is also the default directory = where players will play 
X  #	if they do not use the -d option.
X***************
X*** 193,209 ****
X  insthelp:	helpfile
X  	@echo Installing helpfiles
X  	-$(RM) $(DEFAULT)/$(HELPOUT)0
X! 	-$(LN) $(HELPOUT)0 $(DEFAULT)/$(HELPOUT)0
X  	-$(RM) $(DEFAULT)/$(HELPOUT)1
X! 	-$(LN) $(HELPOUT)1 $(DEFAULT)/$(HELPOUT)1
X  	-$(RM) $(DEFAULT)/$(HELPOUT)2
X! 	-$(LN) $(HELPOUT)2 $(DEFAULT)/$(HELPOUT)2
X  	-$(RM) $(DEFAULT)/$(HELPOUT)3
X! 	-$(LN) $(HELPOUT)3 $(DEFAULT)/$(HELPOUT)3
X  	-$(RM) $(DEFAULT)/$(HELPOUT)4
X! 	-$(LN) $(HELPOUT)4 $(DEFAULT)/$(HELPOUT)4
X  	-$(RM) $(DEFAULT)/$(HELPOUT)5
X! 	-$(LN) $(HELPOUT)5 $(DEFAULT)/$(HELPOUT)5
X  	touch insthelp
X  
X  helpfile:	$(HELPOUT)0 $(HELPOUT)1 $(HELPOUT)2 $(HELPOUT)3 $(HELPOUT)4 $(HELPOUT)5
X--- 208,224 ----
X  insthelp:	helpfile
X  	@echo Installing helpfiles
X  	-$(RM) $(DEFAULT)/$(HELPOUT)0
X! 	-$(LN) $(CURRENT)/$(HELPOUT)0 $(DEFAULT)/$(HELPOUT)0
X  	-$(RM) $(DEFAULT)/$(HELPOUT)1
X! 	-$(LN) $(CURRENT)/$(HELPOUT)1 $(DEFAULT)/$(HELPOUT)1
X  	-$(RM) $(DEFAULT)/$(HELPOUT)2
X! 	-$(LN) $(CURRENT)/$(HELPOUT)2 $(DEFAULT)/$(HELPOUT)2
X  	-$(RM) $(DEFAULT)/$(HELPOUT)3
X! 	-$(LN) $(CURRENT)/$(HELPOUT)3 $(DEFAULT)/$(HELPOUT)3
X  	-$(RM) $(DEFAULT)/$(HELPOUT)4
X! 	-$(LN) $(CURRENT)/$(HELPOUT)4 $(DEFAULT)/$(HELPOUT)4
X  	-$(RM) $(DEFAULT)/$(HELPOUT)5
X! 	-$(LN) $(CURRENT)/$(HELPOUT)5 $(DEFAULT)/$(HELPOUT)5
X  	touch insthelp
X  
X  helpfile:	$(HELPOUT)0 $(HELPOUT)1 $(HELPOUT)2 $(HELPOUT)3 $(HELPOUT)4 $(HELPOUT)5
X*** oREADME	Sun Aug  6 20:55:33 1989
X--- README	Sun Aug  6 20:55:41 1989
X***************
X*** 16,21 ****
X--- 16,26 ----
X  useful to me as they are my primary method of deciding what to next add to the
X  code.  Your interest is appreciated.
X  
X+ A mailing list for conquer has been set up to provide a platform for conquer
X+ discussion, and location for conquer test patch releases.  The mailing list is
X+ "conquer-news@bu-cs.bu.edu" and addition to or deletions from the mailing
X+ list may be sent to "conquer-news-request@bu-cs.bu.edu".
X+ 
X  Included in this file are the following:
X  	1) A Brief Description of Conquer
X  	2) Installation (unpacking) Instructions
X*** oheader.h	Sun Aug  6 20:55:34 1989
X--- header.h	Sun Aug  6 20:55:42 1989
X***************
X*** 68,80 ****
X  #define METALPCT 33	/* percent of tradegoods that are metals	*/
X  #define JEWELPCT 33	/* percent of tradegoods that are luxury items	*/
X  #define HIDELOC		/* defined if news is not to report sectors	*/
X- 
X  #define OGOD		/* defined if you wish to enhance god powers.   */
X! 
X! #define DERVDESG	/* allow DERVISH to redesignate in a DESERT/ICE	*/
X  #define MONSTER	45	/* defined if pirates/savages/nomads/lzard exist.
X  			   represents # of sectors of land that need to be
X  			   in world per pirate/savage/nomad nation	*/
X  #define NPC	45	/* defined if NPC nations should exist. The numeric
X  			   represents # of sectors of land that need to be
X  			   in world per non-player character nation	*/
X--- 68,83 ----
X  #define METALPCT 33	/* percent of tradegoods that are metals	*/
X  #define JEWELPCT 33	/* percent of tradegoods that are luxury items	*/
X  #define HIDELOC		/* defined if news is not to report sectors	*/
X  #define OGOD		/* defined if you wish to enhance god powers.   */
X! #define REMAKE		/* may make a world even if datafile exists.	*/
X! 			/* this allows demi-gods the ability to remake  */
X! 			/* their world.                                 */
X! /* #define NOSCORE	/* only show full scores to god while in game	*/
X! #define DERVDESG	/* allow DERVISH to redesignate in DESERT/ICE	*/
X  #define MONSTER	45	/* defined if pirates/savages/nomads/lzard exist.
X  			   represents # of sectors of land that need to be
X  			   in world per pirate/savage/nomad nation	*/
X+ #define MORE_MONST	/* defined if destroyed monsters are replaced	*/
X  #define NPC	45	/* defined if NPC nations should exist. The numeric
X  			   represents # of sectors of land that need to be
X  			   in world per non-player character nation	*/
X*** odata.h	Sun Aug  6 20:55:34 1989
X--- data.h	Sun Aug  6 20:55:42 1989
X***************
X*** 158,164 ****
X  	short	turn;		/* game turn			*/
X  	long	m_mil;		/* number of mercs available	*/
X  	short	m_aplus;	/* mercenary attack bonus	*/
X! 	short	m_dplus;	/* mercenary defence bonus	*/
X  	long	w_jewels;	/* jewels in world		*/
X  	long	w_gold;		/* gold talons in world		*/
X  	long	w_food;		/* food in world		*/
X--- 158,164 ----
X  	short	turn;		/* game turn			*/
X  	long	m_mil;		/* number of mercs available	*/
X  	short	m_aplus;	/* mercenary attack bonus	*/
X! 	short	m_dplus;	/* mercenary defense bonus	*/
X  	long	w_jewels;	/* jewels in world		*/
X  	long	w_gold;		/* gold talons in world		*/
X  	long	w_food;		/* food in world		*/
X***************
X*** 218,225 ****
X  
X  
X  /* NATION STRATEGY: a nation's strategy is a part of the ntn[].active
X!  * variable which tells if it is a PC or NPC, its allignment, and its
X!  * constraints allignments can be good, neutral, or evil. 
X   * NPC Nations can be Expansionsist (with 0,2,4,6 sectors to expand into)
X   * or Isolationist.	*/
X  #define	INACTIVE	0
X--- 218,225 ----
X  
X  
X  /* NATION STRATEGY: a nation's strategy is a part of the ntn[].active
X!  * variable which tells if it is a PC or NPC, its alignment, and its
X!  * constraints alignments can be good, neutral, or evil. 
X   * NPC Nations can be Expansionsist (with 0,2,4,6 sectors to expand into)
X   * or Isolationist.	*/
X  #define	INACTIVE	0
X***************
X*** 246,252 ****
X  #define NPC_SAVAGE	21
X  
X  #define	ispc(x)		(((x)==PC_GOOD)||((x)==PC_EVIL)||((x)==PC_NEUTRAL))
X! #define	npctype(x)	(ispc(x) ? (x) : (x)/4)
X  #define	isgood(x)	(npctype(x) == 1)
X  #define	isneutral(x)	(npctype(x) == 2)
X  #define	isevil(x)	(npctype(x) == 3)
X--- 246,252 ----
X  #define NPC_SAVAGE	21
X  
X  #define	ispc(x)		(((x)==PC_GOOD)||((x)==PC_EVIL)||((x)==PC_NEUTRAL))
X! #define	npctype(x)	(ispc(x) ? (x) : (ismonst(x)?0:(x)/4))
X  #define	isgood(x)	(npctype(x) == 1)
X  #define	isneutral(x)	(npctype(x) == 2)
X  #define	isevil(x)	(npctype(x) == 3)
X***************
X*** 616,622 ****
X  extern int	unitvalid(),access(),orctake(),fort_val();
X  extern int	addgships(),addmships(),addwships(),fltships();
X  extern int	fltghold(),fltwhold(),fltmhold(),flthold(),compass();
X! extern int	get_country(),check_lock(),doclass();
X  extern unsigned short	fltspeed();
X  extern void	do_pirate(), do_nomad(), do_savage(), do_lizard();
X  extern void	getjewel(),getmetal(),loadfleet(),removemgk(),exenewmgk();
X--- 616,622 ----
X  extern int	unitvalid(),access(),orctake(),fort_val();
X  extern int	addgships(),addmships(),addwships(),fltships();
X  extern int	fltghold(),fltwhold(),fltmhold(),flthold(),compass();
X! extern int	get_country(),check_lock(),doclass(),get_pass();
X  extern unsigned short	fltspeed();
X  extern void	do_pirate(), do_nomad(), do_savage(), do_lizard();
X  extern void	getjewel(),getmetal(),loadfleet(),removemgk(),exenewmgk();
X***************
X*** 629,635 ****
X  extern void	errormsg(), clear_bottom(), addgroup(),ext_cmd();
X  extern void	randomevent(), wdisaster(), weather(), deplete();
X  extern void	verify_ntn(), verify_sct(), verifydata(), prep();
X! extern void	newbye(), newreset(), newmsg(), newerror(), newinit();
X  extern void	destroy(), updmove(), spreadsheet(), mailopen(), mailclose();
X  extern void	updexecs(), updcapture(), updsectors();
X  extern void	updmil(), updcomodities(), updleader();
X--- 629,636 ----
X  extern void	errormsg(), clear_bottom(), addgroup(),ext_cmd();
X  extern void	randomevent(), wdisaster(), weather(), deplete();
X  extern void	verify_ntn(), verify_sct(), verifydata(), prep();
X! extern void	errorbar(), newbye(), newreset(), newmsg(), newerror();
X! extern void	newinit();
X  extern void	destroy(), updmove(), spreadsheet(), mailopen(), mailclose();
X  extern void	updexecs(), updcapture(), updsectors();
X  extern void	updmil(), updcomodities(), updleader();
X***************
X*** 881,887 ****
X  extern	FILE	*fm;
X  extern	int	mailok;
X  extern	char	*seasonstr[];
X! extern	char	*allignment[];	
X  extern	struct	s_sector	**sct;
X  extern	struct	s_nation	ntn[NTOTAL];
X  extern	struct	s_nation	*curntn;	
X--- 882,888 ----
X  extern	FILE	*fm;
X  extern	int	mailok;
X  extern	char	*seasonstr[];
X! extern	char	*alignment[];	
X  extern	struct	s_sector	**sct;
X  extern	struct	s_nation	ntn[NTOTAL];
X  extern	struct	s_nation	*curntn;	
X*** oadmin.c	Sun Aug  6 20:55:33 1989
X--- admin.c	Sun Aug  6 20:55:42 1989
X***************
X*** 38,43 ****
X--- 38,44 ----
X  /* nation id of owner*/
X  short	country=0;
X  struct	s_nation	*curntn;
X+ extern char datadir[];
X  
X  FILE *fexe, *fopen();
X  
X***************
X*** 54,67 ****
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[FILELTH];
X  	extern char *optarg;
X  	char defaultdir[BIGLTH],cq_opts[BIGLTH];
X! 	struct passwd *getpwnam();
X  
X! 	mflag = aflag = xflag = pflag = rflag = 0;
X  	srand((unsigned) time((long *) 0));
X  	strcpy(cq_opts,"");
X  	name = string;
X  	*name = 0;
X--- 55,69 ----
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, rflag;
X  	char string[FILELTH];
X  	extern char *optarg;
X  	char defaultdir[BIGLTH],cq_opts[BIGLTH];
X! 	struct passwd *getpwnam(), *pwent;
X  
X! 	mflag = aflag = xflag = rflag = 0;
X  	srand((unsigned) time((long *) 0));
X+ 	strcpy(datadir,"");
X  	strcpy(cq_opts,"");
X  	name = string;
X  	*name = 0;
X***************
X*** 102,110 ****
X  				if (i<l) {
X  					/* grab the data directory */
X  					for (j=0; j<l-i && cq_opts[i+j]!=',';j++) {
X! 						defaultdir[j] = cq_opts[i+j];
X  					}
X! 					defaultdir[j]='\0';
X  					i += j-1;
X  				}
X  				break;
X--- 104,112 ----
X  				if (i<l) {
X  					/* grab the data directory */
X  					for (j=0; j<l-i && cq_opts[i+j]!=',';j++) {
X! 						datadir[j] = cq_opts[i+j];
X  					}
X! 					datadir[j]='\0';
X  					i += j-1;
X  				}
X  				break;
X***************
X*** 123,135 ****
X  	     }
X  	}
X  
X- 	/* set the default data directory */
X- 	if (defaultdir[0] == '\0') {
X- 		strcpy(defaultdir, DEFAULTDIR);
X- 	}
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--- 125,132 ----
X  	     }
X  	}
X  
X  	/* process the command line arguments */
X! 	while((i=getopt(argc,argv,"maxr:d:"))!=EOF) switch(i){
X  	/* process the command line arguments */
X  	case 'm':  /* make a new world*/
X  		mflag++;
X***************
X*** 140,148 ****
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--- 137,142 ----
X***************
X*** 152,166 ****
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--- 146,159 ----
X  		strcpy(scenario, optarg);
X  		break;
X  	case 'd':
X! 		strcpy(datadir, optarg);
X  		break;
X  	case '?': /*  print out command line arguments */
X! 		printf("Command line format: %s [-max -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-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*** 170,178 ****
X  	(void) setuid (geteuid ()) ;
X  
X  	/* set proper defaultdir */
X! 	if (defaultdir[0] != '/') {
X! 		strcpy(cq_opts, defaultdir);
X! 		sprintf(defaultdir, "%s/%s", DEFAULTDIR, cq_opts);
X  	}
X  
X  	/* now that we have parsed the args, we can got to the
X--- 163,177 ----
X  	(void) setuid (geteuid ()) ;
X  
X  	/* set proper defaultdir */
X! 	if (datadir[0] != '/') {
X! 		if (strlen(datadir) > 0) {
X! 			sprintf(defaultdir, "%s/%s", DEFAULTDIR, datadir);
X! 		} else {
X! 			strcpy(defaultdir,DEFAULTDIR);
X! 			strcpy(datadir,"[default]");
X! 		}
X! 	} else {
X! 		strcpy(defaultdir,datadir);
X  	}
X  
X  	/* now that we have parsed the args, we can got to the
X***************
X*** 183,199 ****
X  		exit(FAIL);
X  	}
X  	if((mflag)||(rflag)) {
X  		if(realuser!=(getpwnam(LOGIN)->pw_uid)) {
X  			printf("Sorry -- you can not create a world\n");
X! 			printf("you need to be logged in as %s",LOGIN);
X! 			if (strcmp(LOGIN, ntn[0].leader)!=0) {
X! 				printf(" or %s",ntn[0].leader);
X! 			}
X! 			printf("\n");
X  		}
X  		sprintf(string,"%sup",isonfile);
X  		unlink(string);
X- 		makeworld(rflag);
X  		exit(SUCCESS);
X  	}
X  
X--- 182,244 ----
X  		exit(FAIL);
X  	}
X  	if((mflag)||(rflag)) {
X+ #ifdef REMAKE
X+ 		/* check if datafile currently exists*/
X+ 		if(access(datafile,00) == 0) {
X+ 			/* read in the data*/
X+ 			readdata();
X+ 			verifydata( __FILE__, __LINE__ );
X+ 
X+ 			/* verify ability to remake the world */
X+ 			if ((realuser != (getpwnam(LOGIN))->pw_uid ) &&
X+ 			    ((pwent=getpwnam(ntn[0].leader)) == NULL ||
X+ 				realuser != pwent->pw_uid )) {
X+ 				printf("Sorry -- you can not create a world\n");
X+ 				printf("you need to be logged in as %s",LOGIN);
X+ 				if (strcmp(LOGIN, ntn[0].leader)!=0) {
X+ 					printf(" or %s",ntn[0].leader);
X+ 				}
X+ 				printf(".\n");
X+ 				exit(FAIL);
X+ 			}
X+ 			printf("************* WARNING!!!! *******************\n\n");
X+ 			printf("    There is already a game in progress.\n\n");
X+ 			printf("*********************************************\n\n");
X+ 			printf("Do you wish to destroy the current game? ");
X+ 			scanf("%s",string);
X+ 			if (strcmp(string,"yes")!=0 && strcmp(string,"y")!=0) {
X+ 				printf("Okay... the world is left intact\n");
X+ 				exit(FAIL);
X+ 			}
X+ 			printf("Are you absolutely certain? ");
X+ 			scanf("%s",string);
X+ 			if (strcmp(string,"yes")!=0 && strcmp(string,"y")!=0) {
X+ 				printf("Okay... the world is left intact\n");
X+ 				exit(FAIL);
X+ 			}
X+ 			printf("The re-destruction of the world has begun...\n");
X+ 			sleep(1);
X+ 		}
X+ #else
X+ 		/* check for god permissions */
X  		if(realuser!=(getpwnam(LOGIN)->pw_uid)) {
X  			printf("Sorry -- you can not create a world\n");
X! 			printf("you need to be logged in as %s.\n",LOGIN);
X! 			exit(FAIL);
X  		}
X+ 
X+ 		/* check if datafile already 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+ 		}
X+ #endif /* REMAKE */
X+ 
X+ 		makeworld(rflag);
X  		sprintf(string,"%sup",isonfile);
X  		unlink(string);
X  		exit(SUCCESS);
X  	}
X  
X***************
X*** 245,252 ****
X  	}
X  
X  #ifdef OGOD
X! 	if((realuser!=(getpwnam(LOGIN)->pw_uid))&&
X! 	   (realuser!=(getpwnam(ntn[0].leader)->pw_uid))) {
X  		printf("Sorry -- you can not administrate conquer\n");
X  		printf("you need to be logged in as %s",LOGIN);
X  		if (strcmp(LOGIN, ntn[0].leader)!=0) {
X--- 290,298 ----
X  	}
X  
X  #ifdef OGOD
X! 	if ((realuser != (getpwnam(LOGIN))->pw_uid ) &&
X! 	  ((pwent=getpwnam(ntn[0].leader)) == NULL ||
X! 	  realuser != pwent->pw_uid )) {
X  		printf("Sorry -- you can not administrate conquer\n");
X  		printf("you need to be logged in as %s",LOGIN);
X  		if (strcmp(LOGIN, ntn[0].leader)!=0) {
X***************
X*** 257,285 ****
X  	}
X  #endif OGOD
X  
X! 	if (pflag) {	/* print a map of the game */
X! 		fprintf(stderr,"\nFor convenience, this output is to stderr,\n");
X! 		fprintf(stderr,"while the maps will be sent to stdout.\n\n");
X! 		fprintf(stderr,"\tThe valid options are,\n");
X! 		fprintf(stderr,"\t\t1) altitudes\n\t\t2) vegetations\n");
X! 		fprintf(stderr,"\t\t3) nations\n");
X! 		fprintf(stderr,"\t\t4) designations\n\n");
X! 		fprintf(stderr,"\tWhat type of map? ");
X! 		scanf("%hd", &dismode);
X! 		fprintf(stderr,"\n");
X! 		if(dismode==1) printele();
X! 		else if(dismode==2) printveg();
X! 		else if(dismode==3) pr_ntns();
X! 		else if(dismode==4) pr_desg();
X! 		else {
X! 		     fprintf(stderr,"must be 1-4\n");
X! 		     exit(FAIL);
X! 		}
X! 		exit(SUCCESS);
X! 	} else if (xflag) {	/* update the game */
X  #ifndef OGOD
X! 		if((realuser!=(getpwnam(LOGIN)->pw_uid))&&
X! 		   (realuser!=(getpwnam(ntn[0].leader)->pw_uid))) {
X  			printf("sorry -- your uid is invalid for updating\n");
X  			printf("you need to be logged in as %s",LOGIN);
X  			if (strcmp(LOGIN, ntn[0].leader)!=0) {
X--- 303,313 ----
X  	}
X  #endif OGOD
X  
X! 	if (xflag) {	/* update the game */
X  #ifndef OGOD
X! 		if ((realuser != (getpwnam(LOGIN))->pw_uid ) &&
X! 		  ((pwent=getpwnam(ntn[0].leader)) == NULL ||
X! 		  realuser != pwent->pw_uid )) {
X  			printf("sorry -- your uid is invalid for updating\n");
X  			printf("you need to be logged in as %s",LOGIN);
X  			if (strcmp(LOGIN, ntn[0].leader)!=0) {
X***************
X*** 318,328 ****
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--- 346,355 ----
X  	printf("error: must specify an option\n");
X  
X  	/*  print out command line arguments */
X! 	printf("Command line format: %s [-max -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-x       execute program\n");
X  	exit(SUCCESS);
X  }
X***************
X*** 378,385 ****
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--- 405,411 ----
X  		WORLDMIL+=curntn->tmil;
X  	}
X  	if (WORLDGOLD==0) WORLDGOLD=1;
X! 	
X  	/* count the number of sectors */
X  	for(country=1;country<NTOTAL;country++) {
X  		if(!isntn(ntn[country].active)) continue;
X*** omakeworl.c	Sun Aug  6 20:55:34 1989
X--- makeworl.c	Sun Aug  6 20:55:42 1989
X***************
X*** 15,20 ****
X--- 15,21 ----
X  /*DEFINE TEMPORARY VARIABLES FROM MAKEFILE*/
X  #include <ctype.h>
X  #include <stdio.h>
X+ #include <pwd.h>
X  #include "header.h"
X  #include "data.h"
X  
X***************
X*** 24,29 ****
X--- 25,31 ----
X  int pwater;		/* percent water in world (0-100) */
X  extern short	country;
X  extern int	numleaders;
X+ char datadir[FILELTH];
X  char **area_map;			/*Value Map of Areas*/
X  char **type;
X  
X***************
X*** 41,146 ****
X  }
X  
X  void
X  makeworld(rflag)
X  int	rflag;		/* TRUE if you wish to read in a map from mapfiles */
X  {
X  	char passwd[PASSLTH+1],*getpass();
X! 	char newstring[BIGLTH];
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! 	}
X! printf("\n************************** WELCOME TO CONQUER **************************");
X! printf("\n*\tThe world will now be created...                               *");
X! printf("\n*\t                                                               *");
X! printf("\n*\tYour super user login will be 'god'.                           *");
X! printf("\n*\t                                                               *");
X! printf("\n*\tNon player countries will be read from the file 'nations'      *");
X! printf("\n*\tand will have the same password as god (which you are about to *");
X! printf("\n*\tenter). Add player nations with <conqrun -a>.  Have fun!!!     *");
X! printf("\n*\t                                                               *");
X! printf("\n*\tRemember to check the world out before playing to make sure    *");
X! printf("\n*\tno nations are in bad positions (surrounded by water... )      *");
X! printf("\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 %s 2> /dev/null",
X  		exefile, msgfile, newsfile, isonfile, tradefile, timefile);
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! 
X  	/* finally ask for the secondary administrator */
X! 	printf("\nYou may now designate an alternate ruler for this world.");
X  	while(TRUE) {
X! 		printf("\nWhat demi-god shall rule this world? ");
X! 		gets( newstring );
X  		if (strlen(newstring)==0) {
X! 			printf("\nGod blesses this world with his presense!\n");
X  			(void) strcpy(ntn[0].leader,LOGIN);
X  			break;
X  		} else if (strlen(newstring) <= LEADERLTH) {
X! 			/* HOW DO YOU VERIFY THAT IT IS AN ACTUAL USER? */
X! 			printf("\nThe demi-god %s may administrate this new world.\n",newstring);
X! 			(void) strncpy(ntn[0].leader,newstring,LEADERLTH);
X! 			break;
X  		}
X- 		printf("\nName too long.");
X  	}
X! 
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--- 43,209 ----
X  }
X  
X  void
X+ zeroworld()
X+ {
X+ 	int i,armynum,nvynum;
X+ 
X+ 	/* initialize all countries */
X+ 	for (i = 0; i < NTOTAL; i++) {
X+ 		curntn = &ntn[i];
X+ 		for (armynum=0; armynum < MAXARM; armynum++) {
X+ 			P_ASOLD = (long)0;
X+ 			P_AXLOC = P_AYLOC = P_ATYPE = P_AMOVE = (unsigned char)0;
X+ 			P_ASTAT = DEFEND;
X+ 		}
X+ 		for (nvynum=0; nvynum < MAXNAVY; nvynum++) {
X+ 			P_NWSHP = P_NMSHP = P_NGSHP = (unsigned short)0;
X+ 			P_NCREW = P_NPEOP = P_NARMY = (unsigned char)0;
X+ 			P_NXLOC = P_NYLOC = P_NMOVE = (unsigned char)0;
X+ 		}
X+ 		curntn->active = INACTIVE;
X+ 		curntn->repro = (char)0;
X+ 		curntn->jewels = curntn->tgold = curntn->metals = 0L;
X+ 		curntn->powers = curntn->tciv = curntn->tmil = curntn->score = 0L;
X+ 		curntn->race = TUNKNOWN;
X+ 		curntn->maxmove = 0;
X+ 		curntn->class = curntn->aplus = curntn->dplus = (short)0;
X+ 		curntn->inflation = curntn->tsctrs = curntn->tships = (short)0;
X+ 	}
X+ }
X+ 
X+ void
X  makeworld(rflag)
X  int	rflag;		/* TRUE if you wish to read in a map from mapfiles */
X  {
X  	char passwd[PASSLTH+1],*getpass();
X! 	char newstring[BIGLTH],tempc[BIGLTH];
X  	FILE *fopen();
X+ 	struct passwd *getpwnam();
X+ 	int i,valid;
X  
X! 	/* conquer makeworld information */
X! 	newinit();
X! 	sprintf(newstring, "Datadir: %s", datadir);
X! 	errorbar("World Generator", newstring);
X  
X! 	mvaddstr(0,COLS/2-9,"WELCOME TO CONQUER");
X! 	mvaddstr(2,5,"Genesis begins...  Your super user login will be 'god'.");
X! 	mvaddstr(3,0,"Non-player countries will be read in from the file 'nations',");
X! 	mvaddstr(4,0,"and will have the same password as god, which you will soon set.");
X! 	mvaddstr(5,0,"     To add players after building:  conqrun -a");
X! 	if (strcmp(datadir,"[default]")!=0)
X! 		printw(" -d %s", datadir);
X! 	addch('.');
X! 
X! 	newmsg("..Zero out extraneous files from prior games");
X! 	/* flush out beginning input */
X! 	while(getch()!='\n') ;
X  	sprintf(newstring,"rm -f %s* %s* %s* %s* %s %s 2> /dev/null",
X  		exefile, msgfile, newsfile, isonfile, tradefile, timefile);
X  	system(newstring);
X! 	newerror("....Initialize the nation structures");
X! 	zeroworld();
X! 	newerror("Initialization complete:  And there was light....");
X  
X! 	valid=FALSE;
X! 	while(valid==FALSE) {			/* password routine */
X! 		mvprintw(7,0,"Enter Super-User Password: ");
X! 		clrtoeol();
X! 		refresh();
X! 		i = get_pass(newstring);
X! 		if (i < 4) {
X! 			newerror("Password Too Short");
X! 			continue;
X! 		} else if (i > PASSLTH) {
X! 			newerror("Password Too Long");
X! 			continue;
X! 		}
X! 		mvprintw(7,0,"Reenter Super-User Password: ");
X! 		clrtoeol();
X! 		refresh();
X! 		i = get_pass(passwd);
X  
X+ 		if((i<4)||(i>PASSLTH)||(strncmp(passwd,newstring,PASSLTH)!=0)){
X+ 			newerror("Invalid Password Match");
X+ 		} else valid=TRUE;
X+ 	}
X  	strncpy(ntn[0].passwd,crypt(passwd,SALT),PASSLTH);
X! 	
X  	/* finally ask for the secondary administrator */
X! 	mvaddstr(7,0,"You may now designate an alternate ruler for this world.");
X  	while(TRUE) {
X! 		mvaddstr(8,0,"What demi-god shall rule this world? ");
X! 		clrtoeol();
X! 		refresh();
X! 		get_nname( newstring );
X  		if (strlen(newstring)==0) {
X! 			newerror("God blesses this world with his presense!");
X  			(void) strcpy(ntn[0].leader,LOGIN);
X+ 			mvaddstr(7,0,"Demi-God: [none]");
X+ 			clrtoeol();
X  			break;
X  		} else if (strlen(newstring) <= LEADERLTH) {
X! 			if (getpwnam(newstring)!=NULL) {
X! 				sprintf(tempc,"The demi-god %s may administrate this new world.",newstring);
X! 				newerror(tempc);
X! 				(void) strncpy(ntn[0].leader,newstring,LEADERLTH);
X! 				mvprintw(7,0,"Demi-God: %s",ntn[0].leader);
X! 				clrtoeol();
X! 				break;
X! 			} else {
X! 				sprintf(tempc,"Their is no mortal named %s on this system.",newstring);
X! 				newerror(tempc);
X! 			}
X! 		} else {
X! 			newerror("That Name is Too long.");
X  		}
X  	}
X! 	mvaddstr(8,0,"Please Enter the Size of the World.  [Divisible by 8 and > 23]");
X! 	clrtoeol();
X  	while(TRUE) {
X! 		mvaddstr(9,0,"Enter number of X sectors: ");
X! 		clrtoeol();
X! 		refresh();
X! 		world.mapx = get_number();
X  		if(((world.mapx % 8) != 0 ) || (world.mapx<24)){
X! 			newerror("Invalid X Value Entered");
X  			continue;
X  		}
X! 		break;
X! 	}
X! 	while (TRUE) {
X! 		mvaddstr(10,0,"Enter number of Y sectors: ");
X! 		clrtoeol();
X! 		refresh();
X! 		world.mapy = get_number();
X  		if(((world.mapy % 8) != 0 ) || (world.mapy<24)){
X! 			newerror("Invalid Y Value Entered");
X  			continue;
X  		}
X  		break;
X  	}
X+ 	mvprintw(8,0,"Map Size: %dx%d", (int)world.mapx, (int)world.mapy);
X+ 	clrtoeol();
X+ 	move(10,0);
X+ 	clrtoeol();
X  
X  	getspace();	/* malloc space for this world */
X  
X  	/* get amount of water to have in the world */
X  	while(TRUE) {
X! 		mvaddstr(9,0,"Enter percent water to have in world (0-100): ");
X! 		clrtoeol();
X! 		refresh();
X! 		pwater = get_number();
X  		if((pwater<0) || (pwater>100 )){
X! 			newerror("Invalid Percentage Entered");
X  			continue;
X  		}
X  		break;
X  	}
X+ 	mvprintw(9,0,"Percentage Water: %d", pwater);
X+ 	clrtoeol();
X+ 	refresh();
X  
X  	if( rflag==FALSE ) createworld();
X  	else readmap();	/* read map in from mapfiles */
X***************
X*** 156,163 ****
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  
X  void
X--- 219,228 ----
X  		fprintf(fm,"5\tGLOBAL ANNOUNCEMENTS\n");
X  		fclose(fm);
X  	} else {
X! 		sprintf(tempc,"error opening news file <%s>\n",newstring);
X! 		newerror(tempc);
X  	}
X+ 	newreset();
X  }
X  
X  void
X***************
X*** 181,192 ****
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--- 246,266 ----
X  	area_map = (char **) m2alloc(MAPX,MAPY,sizeof(char));
X  	type = (char **) m2alloc(MAPX,MAPY,sizeof(char));
X  
X! 	mvaddstr(11,0,"Creating world");
X! 	mvaddstr(12,5,"In the beginning, the world was a set of bits ordered in");
X! 	mvaddstr(13,0,"a random way.  Then the conquer game administrator (hereafter");
X! 	mvaddstr(14,0,"known as god) decreed 'conqrun -m'!!!");
X! 
X  	/*initialize variables */
X+ 	newerror("Day 1... And the variables were initialized.");
X+ 	move(11,0);
X+ 	clrtoeol();
X+ 	move(12,0);
X+ 	clrtoeol();
X+ 	move(13,0);
X+ 	clrtoeol();
X+ 	move(14,0);
X+ 	clrtoeol();
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*** 332,338 ****
X  				else type[X*8+i][Y*8+j]=HALF;
X  				break;
X  			default:
X! 				fprintf(stderr,"ERROR\n");
X  				abrt();
X  			}
X  		}
X--- 406,413 ----
X  				else type[X*8+i][Y*8+j]=HALF;
X  				break;
X  			default:
X! 				newerror("Uh oh!!!  The world has gone wacky.");
X! 				newreset();
X  				abrt();
X  			}
X  		}
X***************
X*** 350,357 ****
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--- 425,435 ----
X  	chance=0;
X  	for(X=0;X<MAPX;X++) for(Y=0;Y<MAPY;Y++)
X  		if(type[X][Y] == WATER) chance++;
X  
X+ 	mvprintw(10,0,"Water: %d / %d sectors",chance,NUMSECTS);
X+ 	clrtoeol();
X+ 	newerror("Day 2... God added water to the world");
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***************
X*** 364,371 ****
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--- 442,452 ----
X  	chance=0;
X  	for(X=0;X<MAPX;X++) for(Y=0;Y<MAPY;Y++)
X  		if(type[X][Y] == WATER) chance++;
X  
X+ 	mvprintw(10,0,"Water: %d / %d sectors",chance,NUMSECTS);
X+ 	clrtoeol();
X+ 	newerror("But God was not pleased... and smoothed the oceans.");
X+ 
X  	/*Adjust world given sectors as land or sea, place vegetation,
X  	designation, and altitude */
X  
X***************
X*** 377,383 ****
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--- 458,466 ----
X  	avvalue	= PMOUNT * (100-pwater);
X  	avvalue	/= 10000;
X  	nmountains	= NUMSECTS * avvalue;
X! 	
X! 	mvprintw(11,0,"Hills and Mountains: %d",nmountains);
X! 	newerror("Day 3... God created hills and mountains");
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***************
X*** 568,573 ****
X--- 651,657 ----
X  	int valid;
X  	int nmountains;
X  	struct	s_sector	*sptr;
X+ 	char newstring[BIGLTH];
X  
X  	TURN=1;
X  
X***************
X*** 574,580 ****
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--- 658,664 ----
X  	nmountains = 10 * (END_NORMAL+1);
X  	for(i=0;i<=END_NORMAL;i++) nmountains -= ( *(tg_value+i) - '0');
X  
X! 	newerror("Day 4... God placed the world's raw materials");
X  	for(y=0;y<MAPY;y++) for(x=0;x<MAPX;x++) {
X  
X  		sptr = &sct[x][y];
X***************
X*** 628,651 ****
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*/
X--- 712,752 ----
X  				sptr->tradegood = i;
X  			}
X  			if(sptr->tradegood == TG_none)
X! 				newerror("??? DEBUG -tradegood==NONE");
X  		}
X  	}
X  
X! 	mvprintw(13,5,"All manner of creatures were created: big ones, little ones,");
X! 	mvprintw(14,0,"fat ones, skinny ones, orange ones, turquois ones, bright blue ones.");
X! 	mvprintw(15,0,"WAIT!!!  God has suddenly realized that smurfs were taking things");
X! 	mvprintw(16,0,"too far and stopped creating new ones, and placed everybody on the map...");
X! 	newerror("Day 5... God decreed that world would be populated");
X! 	move(14,0);
X! 	clrtoeol();
X! 	move(15,0);
X! 	clrtoeol();
X! 	move(16,0);
X! 	clrtoeol();
X  	populate();
X  	MERCMEN = ST_MMEN;
X  	MERCATT = ST_MATT;
X  	MERCDEF = ST_MDEF;
X! 	newerror("Day 6... God, believing in long weekends, went and got smashed");
X! 	newerror("Day 7... God rested (to get rid of that stupid hangover)");
X! 	sprintf(newstring," ...Log in via 'conquer -n god");
X! 	if (strcmp(datadir,"[default]")!=0) {
X! 		strcat(newstring," -d ");
X! 		strcat(newstring,datadir);
X! 	}
X! 	strcat(newstring,"'");
X! 	newerror(newstring);
X! 	sprintf(newstring," ...Players may be added via 'conqrun -a");
X! 	if (strcmp(datadir,"[default]")!=0) {
X! 		strcat(newstring," -d ");
X! 		strcat(newstring,datadir);
X! 	}
X! 	strcat(newstring,"'");
X! 	newerror(newstring);
X  }
X  
X  /*fill: subroutine to fill in a square edges with land or sea*/
X***************
X*** 722,728 ****
X  void
X  populate()
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--- 823,829 ----
X  void
X  populate()
X  {
X! 	int	i=0,x=0,y=0,j=0,xloc,yloc,xpos,ypos;
X  	int	nvynum=0,armynum=0,points,shipsize,temp,cnum;
X  	short	short1,short2;			/*temporary short variables */
X  	short	class;
X***************
X*** 747,753 ****
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--- 848,854 ----
X  	for( country=1; country<NTOTAL; country++ ) {
X  		curntn = &ntn[country];
X  		if( isactive( curntn->active )) {
X! 			newerror("THIS SHOULDNT HAPPEN");
X  			continue;
X  		}
X  		strcpy(curntn->passwd,ntn[0].passwd);
X***************
X*** 819,826 ****
X  			} else	if(nnomads < MAXARM )	nnomads++;
X  			break;
X  	}
X! 	printf("placing %d lizards, %d pirates, %d savages, and %d nomads\n",
X  		nlizards,npirates,nbarbarians,nnomads);
X  
X  	while((nlizards+npirates+nbarbarians+nnomads > 0 )&&(loopcnt++ <5000)) {
X  		if( nlizards>0 ) {
X--- 920,929 ----
X  			} else	if(nnomads < MAXARM )	nnomads++;
X  			break;
X  	}
X! 	mvprintw(13,0,"Placing %d lizards, %d pirates, %d savages, and %d nomads",
X  		nlizards,npirates,nbarbarians,nnomads);
X+ 	clrtoeol();
X+ 	refresh();
X  
X  	while((nlizards+npirates+nbarbarians+nnomads > 0 )&&(loopcnt++ <5000)) {
X  		if( nlizards>0 ) {
X***************
X*** 987,1026 ****
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? (y or n)");
X! 	while( ((i=getchar()) != 'y')&&(i != 'n') ) ;
X! 	if( i!='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  		while( ((i=getchar()) != 'y')&&(i != 'n') ) ;
X  		if( i=='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",NPC);
X  
X  	cnum=1;
X  	while(fgets(line,LINELTH,fp)!=NULL) {
X  		/*read and parse a new line*/
X  		if(line[0]!='#') {
X--- 1090,1138 ----
X  		}
X  	}
X  
X! 	newerror("... All random population and monsters placed");
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! 			char tempc[BIGLTH];
X! 			sprintf(tempc,"cannot find helpfile <%s/%s>.",DEFAULTDIR,fname);
X! 			newerror(tempc);
X! 		}
X  	}
X  
X  #ifdef NPC
X! 	mvaddstr(14,0,"Do you want NPC nations in this campaign? (y or n)");
X! 	clrtoeol();
X! 	refresh();
X! 	while( ((i=getch()) != 'y')&&(i != 'n') ) ;
X! 	if( i!='y' ) {
X! 		newerror("OK; no NPC nations used");
X! 		return;
X! 	}
X  	if((fp=fopen(npcsfile,"r"))==NULL) {
X! 		mvaddstr(14,0,"Do you wish to use default NPC nations file (y or n)?");
X! 		clrtoeol();
X! 		refresh();
X  		while( ((i=getchar()) != 'y')&&(i != 'n') ) ;
X  		if( i=='y'){
X  			sprintf(line,"%s/%s",DEFAULTDIR,npcsfile);
X  			if ((fp=fopen(line,"r"))==NULL) {
X! 				newerror("Cannot read nation file... no NPCs added");
X  				return;
X! 			} else newerror("OK; default nations used");
X  		} else {
X! 			newerror("OK; no NPC nations used");
X  			return;
X  		}
X  	}
X  
X  	cnum=1;
X+ 	mvprintw(14,0,"ADDING NATIONS:");
X+ 	refresh();
X+ 	xpos = 16;
X+ 	ypos = 14;
X  	while(fgets(line,LINELTH,fp)!=NULL) {
X  		/*read and parse a new line*/
X  		if(line[0]!='#') {
X***************
X*** 1034,1049 ****
X  
X  			country=cnum;
X  			curntn = &ntn[country];
X  			if( cnum > MAPX*MAPY/NPC*(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--- 1146,1170 ----
X  
X  			country=cnum;
X  			curntn = &ntn[country];
X+ 			curntn->class = (short)class;
X+ 			sprintf(line," %s (%s)",curntn->name,*(Class+curntn->class));
X+ 			mvaddstr(ypos,xpos,line);
X+ 			xpos += strlen(line);
X+ 			if (xpos > COLS-20) {
X+ 				xpos = 5;
X+ 				ypos++;
X+ 			}
X+ 			refresh();
X  			if( cnum > MAPX*MAPY/NPC*(100-pwater)/100 ) {
X! 				sprintf(line,"World too small to add npc nation %d %s",cnum,curntn->name);
X! 				newerror(line);
X  				continue;
X  			} 
X  			if( isactive(ntn[cnum].active) ) {
X! 				sprintf(line,"Not enough available nations to add npc nation %d %s",cnum,curntn->name);
X! 				newerror(line);
X  				continue;
X  			}
X  			curntn->maxmove = short1;
X  			curntn->repro = short2;
X  			if( allign == 'G' )
X***************
X*** 1061,1067 ****
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--- 1182,1190 ----
X  			else if( allign == 'i' )
X  				curntn->active = ISOLATIONIST;
X  			else {
X! 				sprintf(line,"invalid nation alignment (%c)");
X! 				newerror(line);
X! 				newreset();
X  				abrt();
X  			}
X  			strcpy(curntn->passwd,ntn[0].passwd);
X***************
X*** 1069,1076 ****
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--- 1192,1199 ----
X  			points -= doclass( class, FALSE );
X  			points -= startcost();
X  			if(points < 10 ) {
X! 				newerror("ERROR: nation doesn't have enough points left for 10000 civilians");
X! 				newreset();
X  				abrt();
X  			}
X  			curntn->tciv = 1000L * points;
X***************
X*** 1100,1105 ****
X  		}
X  	}
X  	att_base();	/* get nation attributes */
X! 	printf("all npc nations placed\n");
X  #endif NPC
X  }
X--- 1223,1228 ----
X  		}
X  	}
X  	att_base();	/* get nation attributes */
X! 	newerror("All NPC nations placed");
X  #endif NPC
X  }
X*** oforms.c	Sun Aug  6 20:55:34 1989
X--- forms.c	Sun Aug  6 20:55:43 1989
X***************
X*** 13,18 ****
X--- 13,19 ----
X  /*	screen subroutines	*/
X  
X  #include <ctype.h>
X+ #include <pwd.h>
X  #include "header.h"
X  #include "data.h"
X  
X***************
X*** 62,72 ****
X--- 63,83 ----
X  					mvaddstr(ypos+4,0,"class:");
X  					mvaddstr(ypos+5,0,"alignment:");
X  					mvaddstr(ypos+6,0,"score:");
X+ #ifdef NOSCORE
X+ 					mvaddstr(ypos+7,0,"npc nation:");
X+ 					if (country==0) {
X+ 						mvaddstr(ypos+8,0,"talons:");
X+ 						mvaddstr(ypos+9,0,"military:");
X+ 						mvaddstr(ypos+10,0,"civilians:");
X+ 						mvaddstr(ypos+11,0,"sectors:");
X+ 					}
X+ #else
X  					mvaddstr(ypos+7,0,"talons:");
X  					mvaddstr(ypos+8,0,"military:");
X  					mvaddstr(ypos+9,0,"civilians:");
X  					mvaddstr(ypos+10,0,"sectors:");
X  					mvaddstr(ypos+11,0,"npc nation:");
X+ #endif /* NOSCORE */
X  				}
X  
X  				/* display nation information */
X***************
X*** 79,86 ****
X  					if(ntn[nationid].race==*(races+i)[0])
X  						mvprintw(ypos+3,xpos,"%s",*(races+i));
X  				mvprintw(ypos+4,xpos,"%s",*(Class+ntn[nationid].class));
X! 				mvprintw(ypos+5,xpos,"%s",allignment[npctype(ntn[nationid].active)]);
X  				mvprintw(ypos+6,xpos,"%ld",ntn[nationid].score);
X  				mvprintw(ypos+7,xpos,"%ld",ntn[nationid].tgold);
X  				mvprintw(ypos+8,xpos,"%ld",ntn[nationid].tmil);
X  				mvprintw(ypos+9,xpos,"%ld",ntn[nationid].tciv);
X--- 90,108 ----
X  					if(ntn[nationid].race==*(races+i)[0])
X  						mvprintw(ypos+3,xpos,"%s",*(races+i));
X  				mvprintw(ypos+4,xpos,"%s",*(Class+ntn[nationid].class));
X! 				mvprintw(ypos+5,xpos,"%s",alignment[npctype(ntn[nationid].active)]);
X  				mvprintw(ypos+6,xpos,"%ld",ntn[nationid].score);
X+ #ifdef NOSCORE
X+ 				if(isnpc(ntn[nationid].active))
X+ 					mvprintw(ypos+7,xpos,"Yes");
X+ 				else mvprintw(ypos+7,xpos,"No");
X+ 				if (country==0) {
X+ 					mvprintw(ypos+8,xpos,"%ld",ntn[nationid].tgold);
X+ 					mvprintw(ypos+9,xpos,"%ld",ntn[nationid].tmil);
SHAR_EOF
echo "End of part 1, continue with part 2"
echo "2" > s2_seq_.tmp
exit 0