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

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

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

	[This patch is split into four parts Patch3[a-d]. You can
	 not feed this directly to patch. You must unshar this and
	 the following 3 articles then feed the file "patchV4.03"
	 to 'patch'.	-br]

[[Due to diffs being larger than the actual files,
I have put the following files in:

       README     - the installation and a general notes file.
       Makefile   - hopefully this is more portable now.
       newlogin.c - entire file rewritten.
                    [Try "conqrun -a" now!!!]
       oMakefile  - original 4.0 Makefile.
                    [supporting two Makefiles, ack!]
       patchV4.03 - a patch for the rest!

This time, they can safely replace all of the above.
Don't remove any other files though :-)... maybe try
the unshar in another directory, then move them over.

A short list of what I have done:

 -- added the environment variable CONQ_OPTS to enable default
     user values to be sent to conquer.
 -- added the ability to allow another person to administrate
     a world.  [Method:  One "conquer" administrator for all
     worlds of conquer and each world can also have a separate
     administrator.]
 -- fixed up the help files.
 -- added a nice highlight of nation name in news.  [This was
     contributed by T. Kivinen]
 -- REWROTE NEWLOGIN ROUTINE!!!  Added a curses interface to
     the newlogin routine.  This makes building a country a
     much more pleasant experience.
 -- one note:  Orcs repro limit is still 14% but may only purchase
     up to 12% at the start of the game.  [Making the limit like
     the +2% allowed with other nations and extra magic]
 -- and many more....

As before, a mostly complete list of changes will be found
in the files 'notes.v4' after patching.

Well... here it is, comments and questions appreciated.

conquer mailing list:  conquer-news@bu-cs.bu.edu

adam bryant
adb@bu-cs.bu.edu
conquer@bu-cs.bu.edu
]]

#!/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:
#	  Makefile
#	  README
#	  newlogin.c
#	  oMakefile
#	  patchV4.03
#
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' > Makefile &&
X#	conquer: Copyright (c) 1989 by Edward M Barlow
X#
X#	BY CHANGING THIS FILE, YOU AGREE TO ABIDE BY THE LIMITATIONS STATED IN
X#	THE LIMITED USE CONTRACT CONTAINED IN THE FILE "header.h"
X#
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#       6 cpus.
X#
X#       It should pose no problems for non parallel makes.
X#
X#       Please report any problems to adb@bucsf.bu.edu
X#				   or adb@bu-cs.bu.edu
X#
XMAKE	= /bin/make
XCC	= /bin/cc
XRM      = /bin/rm -f
X
X#	LN must be "ln -s" if source and default directories span disks
XLN	= ln
XCP	= cp
XNULL	= 2>/dev/null
X
X#	Flags to lint
XLTFLG   = -h -lcurses
X
X#	Options for shar program, SHARLIM is limit of each shar
X#	file created in kilobytes and SHARNAM is the prefix for
X#	SHARFILE name.
X#	[This is for a public domain shar from USENET, I can send
X#	copies if you wish - adb@bu-cs.bu.edu]
XSHAR	= xshar
XSHARLIM	= 50
XSHARNAM	= shar.
XSHARFLG = -D -c -l$(SHARLIM) -o$(SHARNAM)
X
X#	This should be installed by whomever you want to own the game.
X#	I recommend "games" or "root".
X
X#	uncomment the next line if you dont have getopt in your library
X#	(eg you are on a pc, or a non unix system).  getopt.c is a
X#	public domain software, and has not been tested by the authors
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
XLIBRARIES = -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.
XDEFAULT = /usr4/acm/stud/adb/games/conqlib
X
X#	This directory is where the executables will be stored
XEXEDIR = /usr4/acm/stud/adb/games
X
X#	Definitions used for compiling conquer
XCDEFS  = -DDEFAULTDIR=\"$(DEFAULT)\" -DEXEDIR=\"$(EXEDIR)\"
X
X#	Options flag used for non-debugging purposes
XOPTFLG  = -O
X
X#	Options flag used for debugging purposes
X#	[make sure to comment out 'strip' commands in install section]
X#OPTFLG  = -DDEBUG -g
X
X#	this is the name of the user executable
X#       the user executable contains commands for the games players
XGAME  = conquer
X#	this is the name of the administrative executable
X#       the administrative executable contains commands for the game super user
XADMIN = conqrun
X#	this is the name of the sorting program which conquer uses
XSORT  = conqsort
X
X#       GAME IDENTIFICATION
X#
X#	Set this to some unique identifier for each game you wish
X#	to create via 'make new_game'.  It will make a subdirectory
X#	$(GAMEID) to the DEFAULT data directory where it will store
X#	data for the new game.  [Leave it blank to create the default
X#	game]
XGAMEID = 
X
X# AFILS are files needed for game updating...
XAFILS = combat.c cexecute.c io.c admin.c makeworl.c navy.c spew.c \
Xnewlogin.c update.c magic.c npc.c misc.c randeven.c data.c trade.c check.c
XAOBJS = combat.o cexecuteA.o ioA.o admin.o makeworl.o navyA.o spew.o \
Xnewlogin.o update.o magicA.o npc.o miscA.o randeven.o dataA.o \
XtradeA.o $(GETOPT) check.o
X
X# GFILS are files needed to run a normal interactive game
XGFILS = commands.c cexecute.c forms.c io.c main.c move.c navy.c \
Xmagic.c misc.c reports.c data.c display.c extcmds.c trade.c check.c
XGOBJS = commands.o cexecuteG.o forms.o ioG.o main.o move.o navyG.o \
XmagicG.o miscG.o reports.o dataG.o display.o extcmds.o tradeG.o \
X$(GETOPT) check.o
X
X# List of temporary C files
XDAFILS = cexecuteA.c ioA.c miscA.c navyA.c magicA.c dataA.c tradeA.c
XDGFILS = cexecuteG.c ioG.c miscG.c navyG.c magicG.c dataG.c tradeG.c
X
X#txt[0-4] are input help files.  help[0-4] are output. HELPSCR is sed script.
XHELP=txt
XHELPOUT=help
XHELPSCR=sed
X
XHEADERS=header.h data.h newlogin.h patchlevel.h
XSUPT1=nations Makefile $(HELP)[0-5] README run man.pag rules
XSUPT2=execute messages news commerce
XALLFILS=$(SUPT1) $(HEADERS) $(AFILS) commands.c forms.c main.c move.c \
Xreports.c display.c extcmds.c newhelp.c sort.c getopt.c
X
Xall:	$(ADMIN) $(GAME) $(SORT) helpfile
X	@echo YAY! make new_game to set up permissions, zero appropriate
X	@echo initial files, move $(GAME) and $(ADMIN) to 
X	@echo $(EXEDIR), and set up the world.
X	@echo If a game is in progress, make install will just move $(GAME) 
X	@echo and $(ADMIN) to $(EXEDIR).
X	@echo
X
X$(ADMIN):	$(AOBJS)
X	@echo phew...
X	-$(RM) $(DAFILS) $(NULL)
X	@echo if the next command does not work you might also need -ltermcap
X	@echo === compiling administrative functions
X	$(CC) $(OPTFLG) -o $(ADMIN) $(AOBJS) $(LIBRARIES)
X#	comment out the next line during debugging	
X	strip $(ADMIN)
X
X$(GAME):	$(GOBJS)
X	@echo phew... 
X	-$(RM) $(DGFILS) $(NULL)
X	@echo if the next command does not work you might also need -ltermcap
X	@echo === compiling user interface
X	$(CC) $(OPTFLG) -o $(GAME) $(GOBJS) $(LIBRARIES)
X#	comment out the next line during debugging
X	strip $(GAME)
X
X$(SORT):	sort.c
X	$(CC) $(OPTFLG) -o $(SORT) sort.c
X#	comment out the next line if debugging
X	strip $(SORT)
X
Xclobber:
X	$(RM) *.o $(HELPOUT)[0-5] $(SORT) newhelp in$(GAME) in$(SORT) in$(ADMIN) $(HELPSCR).[12] lint[aghs] conquer.doc $(GAME) $(ADMIN) $(NULL)
X
Xclean:
X	$(RM) *.o lint[aghs] conquer.doc $(NULL)
X
Xin$(GAME):	$(GAME)
X	-$(RM) $(EXEDIR)/$(GAME)
X	$(CP) $(GAME) $(EXEDIR)
X	chmod 4751 $(EXEDIR)/$(GAME)
X	touch in$(GAME)
X
Xin$(ADMIN):	$(ADMIN)
X	-$(RM) $(EXEDIR)/$(ADMIN)
X	$(CP) $(ADMIN) $(EXEDIR)
X	chmod 4751 $(EXEDIR)/$(ADMIN)
X	touch in$(ADMIN)
X
Xin$(SORT):	$(SORT)
X	-$(RM) $(EXEDIR)/$(SORT)
X	$(CP) $(SORT) $(EXEDIR)
X	chmod 751 $(EXEDIR)/$(SORT)
X	touch in$(SORT)
X
Xinstall:	in$(GAME) in$(ADMIN) in$(SORT) insthelp
X	@echo ""
X	@echo "Installation complete"
X
Xnew_game:	all insthelp
X	@echo Installing new game
X	-mkdir $(EXEDIR) $(NULL)
X	-mkdir $(DEFAULT)  $(NULL)
X	-mkdir $(DEFAULT)/$(GAMEID) $(NULL)
X	chmod 755 $(EXEDIR)
X	chmod 750 $(DEFAULT)/$(GAMEID) $(DEFAULT)
X	$(CP) $(GAME) $(ADMIN) $(SORT) $(EXEDIR)
X	chmod 4755 $(EXEDIR)/$(GAME) $(EXEDIR)/$(ADMIN)
X	chmod 0755 $(EXEDIR)/$(SORT)
X	chmod 0600 nations
X	chmod 0700 run
X	$(CP) nations rules $(DEFAULT)/$(GAMEID)
X	$(CP) nations rules $(DEFAULT)
X	@echo now making the world
X	$(EXEDIR)/$(ADMIN) -d "$(GAMEID)" -m
X	$(EXEDIR)/$(ADMIN) -d "$(GAMEID)" -a
X
Xinsthelp:	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
Xhelpfile:	$(HELPOUT)0 $(HELPOUT)1 $(HELPOUT)2 $(HELPOUT)3 $(HELPOUT)4 $(HELPOUT)5
X	@echo Helpfiles built
X	touch helpfile
X
X$(HELPOUT)0:	$(HELP)0 $(HELPSCR).1 $(HELPSCR).2
X	@echo building $(HELPOUT)0
X	cat $(HELP)0 | sed -f $(HELPSCR).1 | sed -f $(HELPSCR).2 > $(HELPOUT)0
X
X$(HELPOUT)1:	$(HELP)1 $(HELPSCR).1 $(HELPSCR).2
X	@echo building $(HELPOUT)1
X	cat $(HELP)1 | sed -f $(HELPSCR).1 | sed -f $(HELPSCR).2 > $(HELPOUT)1
X
X$(HELPOUT)2:	$(HELP)2 $(HELPSCR).1 $(HELPSCR).2
X	@echo building $(HELPOUT)2
X	cat $(HELP)2 | sed -f $(HELPSCR).1 | sed -f $(HELPSCR).2 > $(HELPOUT)2
X
X$(HELPOUT)3:	$(HELP)3 $(HELPSCR).1 $(HELPSCR).2
X	@echo building $(HELPOUT)3
X	cat $(HELP)3 | sed -f $(HELPSCR).1 | sed -f $(HELPSCR).2 > $(HELPOUT)3
X
X$(HELPOUT)4:	$(HELP)4 $(HELPSCR).1 $(HELPSCR).2
X	@echo building $(HELPOUT)4
X	cat $(HELP)4 | sed -f $(HELPSCR).1 | sed -f $(HELPSCR).2 > $(HELPOUT)4
X
X$(HELPOUT)5:	$(HELP)5 $(HELPSCR).1 $(HELPSCR).2
X	@echo building $(HELPOUT)5
X	cat $(HELP)5 | sed -f $(HELPSCR).1 | sed -f $(HELPSCR).2 > $(HELPOUT)5
X
X$(HELPSCR).1:	newhelp
X	newhelp
X
X$(HELPSCR).2:	newhelp
X	newhelp
X
Xnewhelp:	dataG.o	newhelp.o
X	$(CC) dataG.o newhelp.o -o newhelp
X
Xlint:
X	lint $(LTFLG) $(CDEFS) -DCONQUER $(GFILS) > lintg
X	lint $(LTFLG) $(CDEFS) -DADMIN $(AFILS) > linta
X
Xdocs:	conquer.doc
X
Xconquer.doc:	$(HELPOUT)0 $(HELPOUT)1 $(HELPOUT)2 $(HELPOUT)3 $(HELPOUT)4 $(HELPOUT)5
X	cat $(HELPOUT)? |sed -e "s/^DONE//g"|sed -e "s/^END//g" >conquer.doc
X
Xcpio:
X	-$(RM) core
X	find . -name '*[CrpsEech]' -print | cpio -ocBv > cpiosv
X
Xshar:	
X	echo " lines   words chars   FILENAME" > MANIFEST
X	wc $(ALLFILS) >> MANIFEST
X	$(SHAR) $(SHARFLG) $(ALLFILS) MANIFEST
X
X.cA.o:	$<
X	( trap "" 0 1 2 3 4 ; $(LN) $*.c $*A.c ;\
X	$(CC) $(OPTFLG) $(CDEFS) -DADMIN -c $*A.c ;\
X	$(RM) $*A.c )
X
X.cG.o:	$<
X	( trap "" 0 1 2 3 4 ; $(LN) $*.c $*G.c ;\
X	$(CC) $(OPTFLG) $(CDEFS) -DCONQUER -c $*G.c ;\
X	$(RM) $*G.c )
X
X.c.o:	$<
X#	compiles using both defines since they
X#	are needed for the data.h definitions for
X#	each file... but should not be needed for
X#	the actual C source file being compiled
X	$(CC) $(OPTFLG) $(CDEFS) -DADMIN -DCONQUER -c $*.c
X
X$(GOBJS):	data.h header.h
X
X$(AOBJS):	data.h header.h
X
XioG.o:	data.h header.h patchlevel.h
X
XioA.o:	data.h header.h patchlevel.h
X
Xnewlogin.o:	data.h header.h newlogin.h patchlevel.h
X
Xmain.o:	data.h header.h patchlevel.h
X
Xnewhelp.c:	data.h header.h patchlevel.h
X
X#	Clear suffixes
X.SUFFIXES:	
X
X#	Suffixes for conquer files.
X.SUFFIXES:	A.o G.o .c .h .o
SHAR_EOF
chmod 0640 Makefile || echo "restore of Makefile fails"
sed 's/^X//' << 'SHAR_EOF' > README &&
X	*********************************************************
X	*	README FILE FOR THE INSTALLER OF CONQUER	*
X	*********************************************************
X
XWhat you have here is a copyrighted release 4 version version of CONQUER.  
XI make no guaranties to the sanity or style of this code, but do believe
Xthat it should work as documented.  I have included numerous bugfixes
Xfrom previous releases posting, and have added numerous enhancements. 
XThe file notes.v4 details changes between v3.5 and v4, bugs and other things.  
X
XI have no current email address... Too bad.  I will post a patch to THIS FILE
Xwhen i get a new email address. The hazards of switching jobs.  Adam Bryant
Xhas volunteered to take mail for the summer of 1989 at "arpa!bu-cs.bu.edu!adb"
Xor "adb@bu-cs.bu.edu".  He is the co-author of the game... so send comments to
Xhim.  We like feedback on the game.  Comments and feature requests are very
Xuseful to me as they are my primary method of deciding what to next add to the
Xcode.  Your interest is appreciated.
X
XIncluded in this file are the following:
X	1) A Brief Description of Conquer
X	2) Installation (unpacking) Instructions
X	3) Configuration Instructions
X	4) Compilation Instructions
X	5) Administration instructions
X	6) Changes in this version
X
XThis version should not be redistributed without the permission of Edward
XBarlow or Adam Bryant ( please read the copyright note in header.h ).
X
XAgain, any comments or bug reports would be greatly appreciated.
X
X-----------------------------------------------------------
XI   A Brief Description of Conquer
X-----------------------------------------------------------
XA complete description of Conquer v4 is contained in "man.page" and
X"conquer.docs".  "conquer.docs" is created from the files txt[0-5] which are
Xcustomized from data in the header files.  These txt[] files are then
Xconverted int help[0-5] files, which contain configuration data.  "make docs"
Xwill create this file from current data.  Note conquer.doc IS NOT created
Xprogram is compiled.  I have tried to make the documentation as good as
Xpossible, but I guarantee that I have missed a lot.  Consider this a feature
Xand enjoy any (hopefully pleasant) suprises you get.
X-----------------------------------------------------------
XII  Installation (unpacking) Instructions
X-----------------------------------------------------------
XThis program came in several shell archive scripts. They can can be unpacked
Xby using "sh filename".  If you are reading this, you know this.
X
XIf you suspect missing files, please check the MANIFEST.
X-----------------------------------------------------------
XIII Configuration
X-----------------------------------------------------------
XTHE FOLLOWING FILES SHOULD BE MODIFIED TO REFLECT YOUR ENVIRONMENT
XAND THE TYPE OF GAME YOU WISH TO PLAY.  THE GAME WILL NOT RUN UNLESS
XYOU MODIFY THESE FILES APPROPRIATELY.
X
Xheader.h	modify as per instructions
XMakefile	modify as per instructions
X
XI have tried to comment this stuff appropriately.
X
XThe options specified in these files will be reflected
Xin the conquer.docs and help files when the program is compiled.
X
XYou will probably also want to take a look at the "rules*" file. This
Xcontains the grammar rules for the random mail messages generated by
XNPC's. You may wish to insert some local people's names, or think of
Xsome really juicy insults. The format of the file should be obvious;
Xbasically %FOO declares a class FOO and one of the things inside that
Xclass will be selected randomly. Obviously, %MAIN is the top level which
Xthen calls on the subclasses to construct sentences.
X
X-----------------------------------------------------------
XIV  Compilation Instructions
X-----------------------------------------------------------
XThis program should be easy to compile.  After header.h and Makefile have
Xbeen edited properly, you may type 'make' to compile conquer, and
X'make new_game' to build and install a new game.
X
XNote: Sometimes curses does not include termcap or termlib.  If all the
X	'.c' files get compiled, but do not link together,  and 
X	unreferenced symbol errors occur,  try adding "-ltermcap" after
X	the "-lcurses" line in the makefile.
X
X-----------------------------------------------------------
XV   administration instructions
X-----------------------------------------------------------
XNow that you have compiled it, this is how you administer/set up/run the game.
XI recommend following these instructions once yourself in a mock game 
X(ie. no other players) for a few turns to get things straight.  Then you 
Xcan add other players.
X
XThe command line format for the administration commands is 
X
X	conqrun [-maxp -dDIR -rSCENARIO]\n",argv[0]);
X		-m          make a world
X		-a          add new player
X		-x          execute program
X		-d DIR      to use play different game
X		-p          print a map
X		-r SCENARIO read map while making a new world
X			    uses SCENARIO.ele, SCENARIO.veg, &  SCENARIO.nat
X
XAlso, some useful god functions are provided through the conquer program
Xthrough logging in as 'god' with 'conquer -n god'.
X
XConquer now supports two layers of game administration:  the god of
Xconquer, as defined by the LOGIN define in header.h, may allow each
Xworld to have an administrator or demi-god.  This demi-god will be able
Xto perform updates and other god functions for this world only.  This
Xfeature allows for multiple worlds, each governed by a different god.
XDuring the creation of a world, god will be prompted for the name of the
Xdemi-god for the new world.  Just hitting return will mean that god will
Xhimself act as the demi-god for this world.
X
XUnlike godship, the demi-god for a world may be changed during the
Xrunning of a game, without recompilation of conquer.  This is done using
Xthe 'c'hange menu when logged in as god.
X
XIn addition the the conqrun command, the makefile helps you as follows:
X
Xmake:		Compiles the code.
Xmake clobber:   Clobber everything but the source (destroys executables)
Xmake clean:     Clean up objects (does not destroy executables)
Xmake new_game:	Create a new game, make world, add players...
Xmake install:	Install game in appropriate directory
Xmake docs:	Creates documentation from help file
X
XFinally, I have included an 'at' script that permits automatic updating.
Xrun:		read this shell script, it permits you to run the update
X		automatically.  It needs to be modified for time to update.
X
XThe command line for the conquer executable can be found by reading
Xthe help files.  
X
XAgain, prior to the compile, you should have followed the instructions
Xin the Makefile and in header.h.  
X
XYou can administrate world either via "make new_game" or via:
X	<conqrun -m>    this will make your world.  
X			This also sets up npc nations as per the nations file
X			npc stats can be adjusted by editing nations
X			prior to making the world.  Non player nations have
X			the same password as god.
Xor	<conqrun -rSCENARIO>    this will make your world by using scenarios.
X			Basically, the scenarios include a nation file and
X			three map files (elevation, vegetation, and nation
X			setup). Look at the rome scenario included in the game.
X			[ this scenario is not finished yet ]
X
XYou can add ( 0 or more ) players via
X	<conqrun -a>    which should be self explanatory.  This wont work if
X			the world is filled, as it would be if a scenario was
X			read in and the SCENARIO.ntn file filled the world.
X			This is because the program wont find spots to place
X			your players.  Adjust the nations file for your
X			scenario to set up players.  When they log in, they
X			will be asked for a new password.
X
X
XOnce you log in as a player or as god, you can get help by
Xtyping '?'.  Play around with the commands and get your syntax right.
X
XTry logging in as either a player or non player nation (they use the super
Xuser password) and noticing any differences.
X
XIMPORTANT NOTE ON PLAY BALANCE: 
XThe world is not created equal.  Some players may start in very bad
Xpositions.  You can either start them over (destroy that nation in the
Xchange nation command and create a new one), or modify the surrounding
Xterain appropriately (god can use the redesignate command to change
Xelevation and vegetation).
X
XNow move around on the map and learn where the players are positioned.
XIf there is a problem (they are surrounded by water...), use the
Xredesignate command to change elevation or vegetation.  In the worst
Xcase, god can destroy a nation with 'c', the change nation command.
XOnce you think the game will be fair, it is time to allow players to
Xproceed.
X
XNow you are all set -- play via 
X	<conquer>
X
Xand update with <conqrun -x> via an script similar to "run"
SHAR_EOF
chmod 0640 README || echo "restore of README fails"
sed 's/^X//' << 'SHAR_EOF' > newlogin.c &&
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 new login for a new player*/
X#include <ctype.h>
X#include "patchlevel.h"
X#include "header.h"
X#include "data.h"
X#include "newlogin.h"
X
X/* information about national classes */
Xchar *Classwho[]= { "DEHO", "DEH", "DEH", "EH", "H", "DHO", "HE", "DHO",
X	"O", "O", "O" };
Xchar *CPowlist[]= { "None", "None", "None", "SUMMON", "RELIGION", "SAILOR",
X	"URBAN", "WARLORD", "DESTROYER", "MA_MONST", "THE_VOID"};
Xint  Classcost[]= { 0, 0, 0, 4, 2, 2, 2, 6, 4, 4, 2 };
Xlong Classpow[]= { 0x0L, 0x0L, 0x0L, SUMMON, RELIGION, SAILOR,
X	URBAN, 0x000000007L, DESTROYER, 0x00000700L, THE_VOID };
X
Xchar *Mprompt[]= { "<<--", "-->>" };
Xchar *LType[]={ "Random", "Fair", "Great" };
X
Xchar *Mlabels[]= { "Population", "Treasury", "Location",
X	"Military", "Attack Bonus", "Defense Bonus", "Reproduction",
X	"Movement", "Magic Powers", "Leaders", "Raw Materials" };
X
Xchar *Mitems[]= { "people", "gold talons", "location", "soldiers",
X	"percent", "percent", "percent", "move points", "powers",
X	"nation leaders", "units of food" };
X
Xchar *Mhelp[]= { "Population: Amount of citizens in your nation",
X	"Treasury: Amount of monetary wealth in your nation",
X	"Location: Relative value of nation placement in world",
X	"Soldiers: Number of men in the national army, not counting leaders",
X	"Attack Bonus: Skill level of your troops when attacking",
X	"Defense Bonus: Skill level of your troops when defending",
X	"Reproduction: Yearly rate of civilian population increase",
X	"Movement: Number of movement points per normal army unit",
X	"Magic Powers: Randomly obtain a new magical power",
X	"Leaders: Number of leader units, including national ruler",
X	"Raw Materials: Starting values for jewels, metal, and food" };
X
Xextern int pwater;		/* percent water in world (0-100) */
Xextern FILE *fexe, *fopen();
Xextern short country;
Xint	numleaders;
Xint spent[CH_NUMBER];
X
X/* Teraform the area around somebodies capitol */
X/* this gives everybody some chance of success */
Xvoid
Xteraform( x,y,range, chance )
Xint x,y;
Xint range,chance;
X{
X	int i,j;
X	switch(curntn->race) {
X	case DWARF:
X		sct[x][y].altitude=MOUNTAIN;
X		for(i=x-range;i<=x+range;i++)
X		for(j=y-range;j<=y+range;j++)
X		if((i!=x)&&(j!=y)&&(ONMAP(i,j))
X		&&(sct[i][j].altitude!=WATER)){
X			if (rand()%3==0)
X				sct[i][j].altitude=MOUNTAIN;
X			else	sct[i][j].altitude=HILL;
X
X			if( rand()%100 < chance ) getmetal( &sct[i][j] );
X		}
X		return;
X	case ELF:
X		sct[x][y].vegetation = FOREST;
X		for(i=x-range;i<=x+range;i++)
X		for(j=y-range;j<=y+range;j++)
X		if((i!=x)&&(j!=y)&&(ONMAP(i,j))
X		&&(sct[i][j].altitude!=WATER)) {
X			if (rand()%3==0)
X				sct[i][j].vegetation=FOREST;
X			else	sct[i][j].vegetation=WOOD;
X			if( rand()%100 < chance ) getjewel( &sct[i][j] );
X		}
X		return;
X	case ORC:
X		sct[x][y].altitude=MOUNTAIN;
X		for(i=x-range;i<=x+range;i++)
X		for(j=y-range;j<=y+range;j++)
X		if((i!=x)&&(j!=y)&&(ONMAP(i,j))
X		&&(sct[i][j].altitude!=WATER)) {
X			if (rand()%3==0)
X				sct[i][j].altitude=MOUNTAIN;
X			else	sct[i][j].altitude=HILL;
X
X			if( rand()%100 < chance ) {
X				if(rand()%2==0)
X					getmetal( &sct[i][j] );
X				else	getjewel( &sct[i][j] );
X			}
X		}
X		return;
X	case HUMAN:
X		sct[x][y].altitude = CLEAR;
X		for(i=x-range;i<=x+range;i++)
X		for(j=y-range;j<=y+range;j++)
X		if((i!=x)&&(j!=y)&&(ONMAP(i,j))
X		&&(sct[i][j].altitude!=WATER)) {
X			if (rand()%2==0)
X			sct[x][y].altitude = CLEAR;
X
X			if (rand()%2==0)
X				sct[i][j].vegetation=WOOD;
X			else	sct[i][j].vegetation=GOOD;
X
X			if( rand()%100 < chance ) {
X				if (rand()%2==0)
X					getmetal( &sct[i][j] );
X				else	getjewel( &sct[i][j] );
X			}
X		}
X		return;
X	}
X}
X
Xvoid
Xmailtopc(string)
Xchar	*string;
X{
X	int	ctry;
X	for( ctry=0; ctry<NTOTAL; ctry++){
X		if((ctry==0)||(ispc(ntn[ctry].active))){
X			mailopen(ctry);
X			fprintf(fm,"%s",string);
X			mailclose();
X		}
X	}
X}
X
X/* function  to initialize the curses display */
Xvoid
Xnewinit()
X{
X	initscr();
X	/* check terminal size */
X	if (COLS<80 || LINES<24) {
X		mvaddstr(LINES-2,0,"conqrun: terminal should be at least 80x24");
X		mvaddstr(LINES-1,0,"Please try again with a different setup");
X		beep();
X		getch();
X		newbye(SUCCESS);
X	}
X	crmode();
X	noecho();
X}
X
X/* function to end the curses display */
Xvoid
Xnewreset()
X{
X	clear();
X	refresh();
X	nocrmode();
X	endwin();
X}
X
X/* function to leave the program completely */
Xvoid
Xnewbye(status)
X	int status;
X{
X	newreset();
X	exit(status);
X}
X
X/* message without wait for keystroke */
Xvoid
Xnewmsg(str)
X	char *str;
X{
X	mvaddstr(LINES-1,0,str);
X	clrtoeol();
X	refresh();
X}
X
X/* message with wait for keystroke */
Xvoid
Xnewerror(str)
X	char *str;
X{
X	mvaddstr(LINES-1,0,str);
X	clrtoeol();
X	mvaddstr(LINES-1,COLS-13,"Hit Any Key");
X	beep();
X	refresh();
X	getch();
X	move(LINES-1,0);
X	clrtoeol();
X	refresh();
X}
X
X/* function to check if a character is in a character array */
Xint
Xin_str(ch,str)
X	char ch, *str;
X{
X	int i,l=strlen(str);
X
X	for(i=0;i<l;i++)
X		if (ch == str[i]) return(TRUE);
X	return(FALSE);
X}
X
X/* function to display the comment and error window */
Xvoid
Xerrorbar(str1,str2)
X	char *str1,*str2;
X{
X	int i;
X	move(LINES-4,0);
X	standout();
X	for(i=0;i<COLS-1;i++)
X		addch(' ');
X	standend();
X	mvprintw(LINES-3,0," Conquer %s.%d: %s",VERSION,PATCHLEVEL,str1);
X	mvaddstr(LINES-3,COLS-strlen(str2)-2,str2);
X	move(LINES-2,0);
X	for(i=0;i<COLS-1;i++)
X		addch('-');
X}
X
X/* display amount string at current location */
Xvoid
Xdispitem(item, amount)
X	int item;
X	long amount;
X{
X	if (item == CH_LOCATE) {
X		printw("%s %s", LType[amount], Mitems[item]);
X	} else {
X		printw("%ld %s", amount, Mitems[item]);
X	}
X
X	if (item != CH_RAWGOODS) {
X		addch('.');
X		return;
X	}
X
X	/* now show the extras for the Raw Materials */
X	printw(", %ld jewels", amount*NLJEWELS/Mvalues[CH_RAWGOODS]);
X	printw(", and %ld metal.", amount*NLMETAL/Mvalues[CH_RAWGOODS]);
X}
X
X/* show the current amount for country item */
Xvoid
Xshowitem(line,item)
X	int line, item;
X{
X	char tempc[LINELTH];
X	
X	move(line,15);
X	if (item == CH_LOCATE) {
X		sprintf(tempc,"%s %s", LType[spent[item]], Mitems[item]);
X		printw("%23s",tempc);
X	} else {
X		sprintf(tempc,"%ld %s", spent[item]*Mvalues[item], Mitems[item]);
X		printw("%23s",tempc);
X	}
X	
X	if (item != CH_RAWGOODS) return;
X	line++;
X
X	/* now show the extras for the Raw Materials */
X	if (NLJEWELS==NLMETAL) {
X		sprintf(tempc,"%ld jewels & metal",
X			   spent[CH_RAWGOODS]*NLJEWELS);
X		mvprintw(line,0,"%38s",tempc);
X		mvprintw(line,COLS/2+10,"%ld jewels & metal",NLJEWELS);
X	} else {
X		sprintf(tempc,"%ld jewels",
X			   spent[CH_RAWGOODS]*NLJEWELS);
X		mvprintw(line,0,"%38s",tempc);
X		mvprintw(line++,COLS/2+10,"%ld jewels",NLJEWELS);
X		sprintf(tempc,"%ld metal",
X			   spent[CH_RAWGOODS]*NLMETAL);
X		mvprintw(line,0,"%38s",tempc);
X		mvprintw(line,COLS/2+10,"%ld metals",NLMETAL);
X	}
X}
X
X/* convert the stored information into the nation statistics */
Xvoid
Xconvert()
X{
X	int i,loop;
X	long x;
X
X	curntn->tciv = Mvalues[CH_PEOPLE] * spent[CH_PEOPLE];
X	curntn->tgold = Mvalues[CH_TREASURY] * spent[CH_TREASURY];
X	switch(spent[CH_LOCATE]) {
X	case 2:
X		curntn->location = GREAT;
X		break;
X	case 1:
X		curntn->location = FAIR;
X		break;
X	case 0:
X	default:
X		curntn->location = RANDOM;
X		break;
X	}
X	curntn->tmil = Mvalues[CH_SOLDIERS] * spent[CH_SOLDIERS];
X	curntn->aplus = (short) Mvalues[CH_ATTACK] * spent[CH_ATTACK];
X	curntn->dplus = (short) Mvalues[CH_DEFEND] * spent[CH_DEFEND];
X	curntn->repro = (char) Mvalues[CH_REPRO] * spent[CH_REPRO];
X	curntn->maxmove = (unsigned char) Mvalues[CH_MOVEMENT]
X		* spent[CH_MOVEMENT];
X	for(i = 0; i < spent[CH_MAGIC]; i++) {
X		/* purchase magic */
X		loop = TRUE;
X		while (loop == TRUE) {
X			if((x=getmagic((rand()%M_MGK+M_MIL)))!=0L){
X				CHGMGK;
X				loop = FALSE;
X			}
X		}
X	}
X	numleaders = (int) Mvalues[CH_LEADERS] * spent[CH_LEADERS];
X	curntn->tfood = Mvalues[CH_RAWGOODS] * spent[CH_RAWGOODS];
X	curntn->jewels = NLJEWELS * spent[CH_RAWGOODS];
X	curntn->metals = NLMETAL * spent[CH_RAWGOODS];
X}
X
Xvoid
Xnewlogin()
X{
X	/* use points to create empire, add if late starter*/
X	int points, clr;
X	int choice, direct;
X	int valid=TRUE;  /*valid==FALSE means continue loop*/
X	int temp,ypos,xpos;
X	int more=TRUE;	/*0 if add another player*/
X	long x;
X	char tempc[LINELTH],strin[LINELTH+1];
X	char passwd[PASSLTH+1];
X	register i;
X
X	/* setup curses display */
X	newinit();
X
X	/*find valid nation number type*/
X	country=0;
X	for(i=1;i<NTOTAL;i++) if(ntn[i].active==INACTIVE) {
X		country=i;
X		curntn = &ntn[country];
X		break;
X	}
X
X	while(more==TRUE) {
X		clear();
X
X		sprintf(tempc,"Country #%d", country);
X		errorbar("Nation Builder",tempc);
X		if(country==0) {
X			newerror("No more nations available");
X			newreset();
X			return;
X		}
X
X		/* open output for future printing*/
X		mvprintw(0,0,"Building Country Number %d",country);
X		sprintf(tempc,"%s%d",exefile,i);
X		if ((fexe=fopen(tempc,"w"))==NULL) {
X			sprintf(tempc,"Error opening <%s>",tempc);
X			newerror(tempc);
X			newbye(FAIL);
X		}
X
X		/* begin purchasing */
X		points=MAXPTS;
X		for (i=0; i<CH_NUMBER; i++) {
X			spent[i] = 0;
X		}
X
X		valid=FALSE;
X		/*get name*/
X		while(valid==FALSE) {
X			valid=TRUE;
X			mvprintw(1,0,"Enter a Name for your Country: ");
X			clrtoeol();
X			refresh();
X			get_nname(tempc);
X
X			if((strlen(tempc)<=1)
X			 ||(strlen(tempc)>NAMELTH)){
X				newerror("Invalid Name Length");
X				valid=FALSE;
X			}
X
X			/*check if already used*/
X			if((strcmp(tempc,"god")==0)
X			||(strcmp(tempc,"unowned")==0)){
X				newerror("Name already used");
X				valid=FALSE;
X			}
X
X			for(i=1;i<NTOTAL;i++)
X			if((i!=country)&&(strcmp(ntn[i].name,tempc)==0)&&(isntn(ntn[i].active))) {
X				newerror("Name already used");
X				valid=FALSE;
X			}
X		}
X		strcpy(curntn->name,tempc);
X		move(0,0);
X		clrtoeol();
X		move(1,0);
X		clrtoeol();
X		standout();
X		mvprintw(0,COLS/2-15-strlen(curntn->name)/2,
X			"< Building Country %s >",curntn->name,country);
X		standend();
X		clrtoeol();
X
X		valid=FALSE;
X		while(valid==FALSE) {			/* password routine */
X			mvprintw(2,0,"Enter National Password: ");
X			clrtoeol();
X			refresh();
X			gets(tempc);
X			if((strlen(tempc)<2)||(strlen(tempc)>PASSLTH)) {
X				newerror("Invalid Password Length");
X				continue;
X			}
X			mvprintw(2,0,"Reenter National Password: ");
X			clrtoeol();
X			refresh();
X			gets(passwd);
X
X			if((strlen(tempc)<2)||(strlen(tempc)>PASSLTH)
X			   ||(strncmp(passwd,tempc,PASSLTH)!=0)){
X				newerror("Invalid Password Match");
X			} else valid=TRUE;
X		}
X		strncpy(curntn->passwd,crypt(tempc,SALT),PASSLTH);
X
X		/*get your name*/
X		valid=FALSE;
X		while(valid==FALSE) {
X			valid=TRUE;
X			mvprintw(2,0,"Enter the name of your country's leader (Ex. The_Ed, Gandalf, Conan)");
X			clrtoeol();
X			mvprintw(3,0,"    [maximum %d characters]: ",LEADERLTH);
X			refresh();
X			get_nname(tempc);
X			if((strlen(tempc)>LEADERLTH)||(strlen(tempc)<2)) {
X				newerror("Invalid Name Length");
X				valid=FALSE;
X			}
X			else strcpy(curntn->leader,tempc);
X		}
X
X		mvprintw(2,0,"Leader Name: %s", curntn->leader);
X		clrtoeol();
X		mvprintw(3,0,"Enter your Race [ (D)warf (E)lf (H)uman (O)rc ]:");
X		clrtoeol();
X		refresh();
X		valid=FALSE;
X		while(valid==FALSE) {
X			valid=TRUE;
X			switch(getch()) {
X			case 'D':
X			case 'd':
X				/*MINER POWER INATE TO DWARVES*/
X				newerror("Dwarves have MINING skills");
X				mvprintw(3,0,"National Race: Dwarf");
X				clrtoeol();
X				curntn->powers=MINER;
X				x=MINER;
X				CHGMGK;
X				points -= getclass(DWARF);
X				curntn->race=DWARF;
X				spent[CH_TREASURY]=NLDGOLD;
X				spent[CH_RAWGOODS]=NLDRAW;
X				spent[CH_PEOPLE]= NLDCIVIL;
X				spent[CH_SOLDIERS]= NLDMILIT;
X				spent[CH_REPRO]= NLDREPRO;
X				spent[CH_MOVEMENT]= NLDMMOVE;
X				spent[CH_ATTACK]= NLDAPLUS;
X				spent[CH_DEFEND]= NLDDPLUS;
X				spent[CH_LOCATE]= NLRANDOM;
X				points-=nstartcst();
X				break;
X			case 'E':
X			case 'e':
X				newerror("Elves are magically cloaked (VOID power)");
X				mvprintw(3,0,"National Race: Elf");
X				clrtoeol();
X				curntn->powers=THE_VOID;
X				x=THE_VOID;
X				CHGMGK;
X				points -= getclass(ELF);
X				curntn->race=ELF;
X				spent[CH_TREASURY]=NLEGOLD;
X				spent[CH_RAWGOODS]=NLERAW;
X				spent[CH_PEOPLE]= NLECIVIL;
X				spent[CH_SOLDIERS]= NLEMILIT;
X				spent[CH_REPRO]= NLEREPRO;
X				spent[CH_MOVEMENT]= NLEMMOVE;
X				spent[CH_ATTACK]= NLEAPLUS;
X				spent[CH_DEFEND]= NLEDPLUS;
X				spent[CH_LOCATE]= NLFAIR;
X				points-=nstartcst();
X				break;
X			case 'O':
X			case 'o':
X				/*MINOR MONSTER POWER INATE TO ORCS*/
X				newerror("Your leader is a Monster!");
X				mvprintw(3,0,"National Race: Orc");
X				clrtoeol();
X				curntn->powers=MI_MONST;
X				x=MI_MONST;
X				CHGMGK;
X				points -= getclass(ORC);
X				curntn->race=ORC;
X				spent[CH_TREASURY]=NLOGOLD;
X				spent[CH_RAWGOODS]=NLORAW;
X				spent[CH_PEOPLE]= NLOCIVIL;
X				spent[CH_SOLDIERS]= NLOMILIT;
X				spent[CH_REPRO]= NLOREPRO;
X				spent[CH_MOVEMENT]= NLOMMOVE;
X				spent[CH_ATTACK]= NLOAPLUS;
X				spent[CH_DEFEND]= NLODPLUS;
X				spent[CH_LOCATE]= NLRANDOM;
X				points-=nstartcst();
X				break;
X			case 'H':
X			case 'h':
X				curntn->race=HUMAN;
X				newerror("Humans have the combat skill of a WARRIOR");
X				mvprintw(3,0,"National Race: Human");
X				clrtoeol();
X				curntn->powers = WARRIOR;
X				x=WARRIOR;
X				CHGMGK;
X				points -= getclass(HUMAN);
X				spent[CH_TREASURY]=NLHGOLD;
X				spent[CH_RAWGOODS]=NLHRAW;
X				spent[CH_PEOPLE]= NLHCIVIL;
X				spent[CH_SOLDIERS]= NLHMILIT;
X				spent[CH_REPRO]= NLHREPRO;
X				spent[CH_MOVEMENT]= NLHMMOVE;
X				spent[CH_ATTACK]= NLHAPLUS;
X				spent[CH_DEFEND]= NLHDPLUS;
X				spent[CH_LOCATE]= NLRANDOM;
X				points-=nstartcst();
X				break;
X			default:
X				valid=FALSE;
X			}
X		}
X		mvprintw(4,0,"Nation Class: %s",Class[curntn->class]);
X		clrtoeol();
X
X		valid=FALSE;
X		if( curntn->race == ORC ) {	/* orcs are always evil */
X			valid=TRUE;
X			curntn->active=PC_EVIL;
X		} else {
X			mvprintw(5,0,"Please Enter Alignment [ (G)ood, (N)eutral, (E)vil ]");
X			refresh();
X		}
X		while (valid==FALSE) {
X			valid=TRUE;
X			switch(getch()) {
X			case 'G':
X			case 'g':
X				curntn->active=PC_GOOD;
X				break;
X			case 'N':
X			case 'n':
X				curntn->active=PC_NEUTRAL;
X				break;
X			case 'E':
X			case 'e':
X				curntn->active=PC_EVIL;
X				break;
X			default:
X				valid=FALSE;
X				break;
X			}
X		}
X		mvprintw(2,COLS/2,"Alignment: %s", allignment[curntn->active]);
X		clrtoeol();
X
X
X		/* get new nation mark */
X		curntn->mark = ' ';
X		while(TRUE) {
X			temp = 30;
X			mvprintw(6,0,"This can be any of the following:");
X			for (tempc[0]='!';tempc[0]<='~';tempc[0]++) {
X				if( markok( tempc[0], FALSE ) ) {
X					temp += 2;
X					if (temp>COLS-20) {
X						printw("\n    ");
X						temp = 8;
X					}
X					printw(" %c",tempc[0]);
X				}
X			}
X			mvprintw(5,0,"Enter National Mark (for maps): ");
X			clrtoeol();
X			refresh();
X			tempc[0] = getch();
X			if( markok( tempc[0], TRUE ) ){
X				curntn->mark=(*tempc);
X				break;
X			}
X		}
X
X		mvprintw(3,COLS/2,"National Mark [%c]",curntn->mark);
X		clrtoeol();
X		move(5,0);
X		clrtoeol();
X		move(6,0);
X		clrtoeol();
X		move(7,0);
X		clrtoeol();
X		refresh();
X
X		ypos = 6;
X		mvprintw(ypos,0,"  %-13s       %s", "ITEM", "CURRENTLY HAVE" );
X		mvprintw(ypos++,COLS/2+5,"%4s %s", "COST", "AMOUNT" );
X		for(i=0; i<CH_NUMBER; i++) {
X			mvprintw(ypos,0,"%-15s", Mlabels[i]);
X			showitem(ypos,i);
X			if (i==CH_LOCATE) {
X				mvprintw(ypos,COLS/2+5,"%3d  %s", Mcost[i],
X					    "Better Location");
X			} else {
X				if (curntn->race==ORC) {			
X					switch(i) {
X					case CH_MOVEMENT:
X						mvprintw(ypos++,COLS/2+5,"  -  --------");
X						continue;
X					case CH_REPRO:
X						x = 2*Munits[i]*Mvalues[i];
X						break;
X					case CH_ATTACK:
X					case CH_DEFEND:
X						x = Munits[i]*Mvalues[i]/2;
X						break;
X					default:
X						x = Munits[i]*Mvalues[i];
X						break;
X					}
X					mvprintw(ypos,COLS/2+5,"%3d ", Mcost[i]);
X					printw(" %ld %s", x, Mitems[i]);
X				} else {
X					mvprintw(ypos,COLS/2+5,"%3d ", Mcost[i]);
X					printw(" %ld %s", Munits[i]*Mvalues[i], Mitems[i]);
X				}
X			}
X			ypos++;
X		}
X
X		/* show everything before menu */
X		direct = ADDITION;
X		choice = CH_PEOPLE;
X		xpos = COLS/2;
X		ypos = 7;
X		valid = FALSE;
X		clr = 1;
X		standout();
X		mvaddstr(LINES-4,0,"  ESC: Exit  ?: Info  <,+,h: left  >,+,l: right  k: up  j: down  ' ': ADD/SUB");
X		standend();
X
X		while(valid==FALSE) {
X			if (clr==1) {
X				standout();
X				mvprintw(4,COLS/2,"Points Left: %d", points);
X				standend();
X				clrtoeol();
X				clr++;
X			} else if (clr==2) {
X				newmsg("");
X				clr = 0;
X			}
X			standout();
X			mvaddstr(ypos+choice,xpos,Mprompt[direct]);
X			standend();
X			refresh();
X			switch(getch()) {
X			case '':
X				/* redraw */
X				wrefresh(stdscr);
X				break;
X			case '?':
X				/* help on topic */
X				newerror(Mhelp[choice]);
X				break;
X			case '\033':
X				/* exit option */
X				if (points > 0) {
X					newmsg("Use remaining points for population? [ny]");
X					if (getch()!='y') {
X						newerror("All points must be spent prior to exiting");
X						break;
X					}
X					temp = points * Munits[CH_PEOPLE] / Mcost[CH_PEOPLE];
X					x = temp * Mvalues[CH_PEOPLE];
X					spent[CH_PEOPLE] += temp;
X					showitem(ypos+CH_PEOPLE,CH_PEOPLE);
X					points = 0;
X					sprintf(tempc,"Buying %ld more civilians", x);
X					newerror(tempc);
X				}
X				newmsg("Is the modification complete? (y or n)");
X				while (((temp=getch())!='y')&&(temp!='n')) ;
X				if (temp == 'y') {
X					valid = TRUE;
X				}
X				clr = 1;
X				break;
X			case '-':
X			case '>':
X			case 'l':
X			case 'L':
X				/* subtraction */
X				direct = SUBTRACTION;
X				break;
X			case '+':
X			case '<':
X			case 'h':
X			case 'H':
X				/* addition */
X				direct = ADDITION;
X				break;
X			case '\b':
X			case '\177':
X				/* decrease choice -- with wrap */
X				mvaddstr(ypos+choice,xpos,"    ");
X				if (choice==CH_PEOPLE) {
X					choice = CH_RAWGOODS;
X				} else {
X					choice--;
X					if (choice==CH_MOVEMENT && curntn->race==ORC) {
X						choice--;
X					}
X				}
X				break;
X			case 'k':
X			case 'K':
X				/* move choice up one */
X				if (choice > CH_PEOPLE) {
X					mvaddstr(ypos+choice,xpos,"    ");
X					choice--;
X					if (choice==CH_MOVEMENT && curntn->race==ORC) {
X						choice--;
X					}
X				}
X				break;
X			case '\r':
X			case '\n':
X				/* increase choice -- with wrap */
X				mvaddstr(ypos+choice,xpos,"    ");
X				if (choice==CH_RAWGOODS) {
X					choice = CH_PEOPLE;
X				} else {
X					choice++;
X					if (choice==CH_MOVEMENT && curntn->race==ORC) {
X						choice++;
X					}
X				}
X				break;
X			case 'j':
X			case 'J':
X				/* move choice down one */
X				if (choice < CH_RAWGOODS) {
X					mvaddstr(ypos+choice,xpos,"    ");
X					choice++;
X					if (choice==CH_MOVEMENT && curntn->race==ORC) {
X						choice++;
X					}
X				}
X				break;
X			case ' ':
X			case '.':
X				/* make the selection */
X				if (curntn->race == ORC) {
X					switch(choice) {
X					case CH_REPRO:
X						temp = 2*Munits[choice];
X						break;
X					case CH_ATTACK:
X					case CH_DEFEND:
X						temp = Munits[choice]/2;
X						break;
X					default:
X						temp = Munits[choice];
X						break;
X					}
X				} else temp = Munits[choice];
X				if (direct == ADDITION) {
X					if (Mcost[choice] > points) {
X						sprintf(tempc, "You do not have %d points to spend",
X							Mcost[choice]);
X						newerror(tempc);
X					} else if ((choice == CH_REPRO)&&(curntn->race==ORC)
X						&&(spent[choice] + temp > 12)) {
X						newerror("You may not purchase any more of that item");
X					} else if ((spent[choice] + temp > Maxvalues[choice])
X						&&((curntn->race!=ORC)||(choice!=CH_REPRO))) {
X						newerror("You may not purchase any more of that item");
X					} else {
X						spent[choice] += temp;
X						newmsg("You now have ");
X						dispitem(choice,spent[choice]*Mvalues[choice]);
X						showitem(ypos+choice,choice);
X						points -= Mcost[choice];
X						clr = 1;
X					}
X				} else if (direct == SUBTRACTION) {
X					if (spent[choice] - temp < Minvalues[choice]) {
X						newerror("You may not sell back any more of that item");
X					} else {
X						spent[choice] -= temp;
X						newmsg("You now have ");
X						dispitem(choice,spent[choice]*Mvalues[choice]);
X						showitem(ypos+choice,choice);
X						points += Mcost[choice];
X						clr = 1;
X					}
X				}
X				break;
X			default:
X				break;
X			}
X		}
X		check();
X
X		/* check for save */
X		newmsg("Save this nation? [ny]");
X		if(getch()!='y'){
X			curntn->active=INACTIVE;
X			curntn->powers=0;
X			newerror("Ok, Nation Deleted");
X			fclose(fexe);
X		} else {
X			convert();
X			place(-1,-1);
X			newerror("Ok, Your Nation has been Added to the World");
X			att_setup(country);	/* setup values ntn attributes */
X			fclose(fexe);
X			sprintf(tempc,"NOTICE: Nation %s added to world on turn %d\n",curntn->name,TURN);
X			mailtopc(tempc);
X			/* cannot clear until after placement and initializing */
X			curntn->powers=0;
X		}
X		country=0;
X		for(i=1;i<NTOTAL;i++) if (ntn[i].active==INACTIVE) {
X			country = i;
X			curntn = &ntn[country];
X			break;
X		}
X		if (country!=0) {
X			newmsg("Do you wish to Add another Nation? [ny]");
X			if (getch()!='y') more = FALSE;
X			else more = TRUE;
X		} else {
X			more = FALSE;
X			newerror("No More Available Nations");
X		}
X	}
X	newreset();
X	att_base();	/* calculate base nation attributes */
X	writedata();
X}
X
X/*****************************************************************/
X/* PLACE(): put nation on the map.  Fill out army structures too */
X/*****************************************************************/
Xvoid
Xplace(xloc,yloc)
Xint	xloc,yloc;	/* if not -1,-1 should place in this spot */
X{
X	int	placed=0,armysize=100;
X	short	armynum=0;
X	long	people;
X	char tempo[LINELTH+1];
X	int	x,y,i,j,temp,t;
X	int	n=0, leadtype;
X	long	soldsleft;	/* soldiers left to place */
X
X	if( xloc != -1 && yloc != -1 && is_habitable(xloc,yloc)) {
X		placed=1;
X		x = xloc;
X		y = yloc;
X	}
X
X	switch(curntn->location) {
X	case OOPS:
X		while((placed == 0)&&(n++<2000)){
X			if(ispc(curntn->active)){
X				x = (rand()%(MAPX-8))+4;
X				y = (rand()%(MAPY-8))+4;
X			} else {
X				x = (rand()%(MAPX-2))+1;
X				y = (rand()%(MAPY-2))+1;
X			}
X			if(is_habitable(x,y)) placed=1;
X
X			for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++)
X				if(sct[i][j].owner!=0) placed=0;
X			temp=0;
X			for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++)
X				if(sct[i][j].altitude==WATER) temp++;
X			if(temp>=7) placed=0;
X		}
X		teraform( x,y,1,25 );
X		break;
X	case RANDOM:
X		while ((placed == 0)&&(n++<2000)){
X			if(ispc(curntn->active)){
X				if(MAPX>12){
X					x = rand()%(MAPX-12)+6;
X					y = rand()%(MAPY-12)+6;
X				} else {
X					x = rand()%(MAPX-8)+4;
X					y = rand()%(MAPY-8)+4;
X				}
X				if(is_habitable(x,y)) placed=1;
X				/*important that no countries near*/
X				for(i=x-2;i<=x+2;i++) for(j=y-2;j<=y+2;j++)
X					if((isntn(ntn[sct[i][j].owner].active))
X					&&(sct[i][j].owner!=0)) placed=0;
X			} else {
X				x = (rand()%(MAPX-6))+3;
X				y = (rand()%(MAPY-6))+3;
X				if(is_habitable(x,y)) placed=1;
X				/*important that no countries near*/
X				for(i=x-2;i<=x+2;i++) for(j=y-2;j<=y+2;j++)
X					if((isntn(ntn[sct[i][j].owner].active))
X					&&(sct[i][j].owner!=0)) placed=0;
X			}
X			temp=0;
X			for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++)
X				if(sct[i][j].altitude==WATER) temp++;
X			if(temp>=7) placed=0;
X			for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++)
X				if(sct[i][j].owner!=0) placed=0;
X		}
X		teraform( x,y,1,40 );
X		break;
X	case FAIR:
X		while ((placed == 0)&&(n++<2000)) {
X			if(ispc(curntn->active)){
X				if(MAPX>24) {
X					x = rand()%(MAPX-24)+12;
X				} else {
X					x = rand()%(MAPX-14)+7;
X				}
X				if(MAPY>24) {
X					y = rand()%(MAPY-24)+12;
X				} else {
X					y = rand()%(MAPY-14)+7;
X				}
X			} else {
X				x = rand()%(MAPX-10)+5;
X				y = rand()%(MAPY-10)+5;
X			}
X
X			if(!is_habitable(x,y)) continue;
X			if(tofood( &sct[x][y],country)<DESFOOD) continue;
X
X			placed=1;
X			for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++)
X				if(sct[i][j].owner!=0) placed=0;
X
X			if(pwater>50) {
X				temp=0;
X				for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++)
X				if(sct[i][j].altitude==WATER) temp++;
X				if(temp>=7) placed=0;
X
X				/*important that no countries near*/
X				for(i=x-3;i<=x+3;i++) for(j=y-3;j<=y+3;j++){
X				if((isntn(ntn[sct[i][j].owner].active))
X					&&(sct[i][j].owner!=0)) placed=0;
X				}
X			} else {
X				temp=0;
X				for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++)
X					if(sct[i][j].altitude==WATER) temp++;
X				if(temp>=5) placed=0;
X
X				/*important that no countries near*/
X				for(i=x-3;i<=x+3;i++) for(j=y-3;j<=y+3;j++){
X				if((isntn(ntn[sct[i][j].owner].active))
X				&&(sct[i][j].owner!=0)) placed=0;
X				}
X			}
X		}
X
X		teraform( x,y,1,65 );
X		break;
X	case GREAT:
X		placed = 0;
X		while ((placed == 0) && (n++<2000)){
X			if(ispc(curntn->active)){
X				if (MAPX>40){
X					x = rand()%(MAPX-40)+20;
X				}else{
X					x = rand()%(MAPX-18)+9;
X				}
X				if (MAPY>40){
X					y = rand()%(MAPY-40)+20;
X				}else{
X					y = rand()%(MAPY-18)+9;
X				}
X
X				if(is_habitable(x,y)) placed=1;
X				/*important that no countries near*/
X				for(i=x-4;i<=x+4;i++) for(j=y-4;j<=y+4;j++){
X				if((isntn(ntn[sct[i][j].owner].active))
X				&&( sct[i][j].owner!=0)) placed=0;
X				}
X			} else {
X				if(MAPX>24){
X					x = rand()%(MAPX-24)+12;
X				}else {
X					x = rand()%(MAPX-12)+6;
X				}
X				if(MAPY>24){
X					y = rand()%(MAPY-24)+12;
X				}else {
X					y = rand()%(MAPY-12)+6;
X				}
X				if(is_habitable(x,y)) placed=1;
X				/*important that no countries near*/
X				for(i=x-2;i<=x+2;i++) for(j=y-2;j<=y+2;j++){
X				if((isntn(ntn[sct[i][j].owner].active))
X					&&(sct[i][j].owner!=0)) placed=0;
X				}
X			}
X
X			for(i=x-1;i<=x+1;i++) for(j=y-1;j<=y+1;j++)
X				if(sct[i][j].owner!=0) placed=0;
X
X			temp=0;
X			/*if any water within 2 sectors placed = 0*/
X			for(i=x-2;i<=x+2;i++) for(j=y-2;j<=y+2;j++)
X				if(tofood( &sct[x][y],country)<=0)
X					temp++;
X
X			if( pwater>50 ) {
X				if(temp>=18) placed=0;
X			} else {
X				if(temp>=15) placed=0;
X			}
X		}
X		teraform( x,y,1,100 );
X	}
X
X	/*done with one try*/
X	if(placed==1) {
X		curntn->capx = x;
X		curntn->capy = y;
X		sct[x][y].designation=DCAPITOL;
X		sct[x][y].tradegood=rand()%(END_KNOWLEDGE-END_SPOILRATE)+END_SPOILRATE+1;
X		sct[x][y].jewels=0;
X		sct[x][y].metal=0;
X		sct[x][y].owner=country;
X		sct[x][y].people=curntn->tciv;
X		sct[x][y].fortress=5;
X
X		/* put all military into armies of armysize */
X		armysize = (TAKESECTOR*12)/10;
X		if(armysize<100) armysize=100;
X		/* cant have more than 50% leaders */
X		if( MAXARM < numleaders * 2 ) numleaders = MAXARM / 2;
X		armynum=0;
X		soldsleft = curntn->tmil;
X		P_ASOLD = curntn->tmil/MILINCAP;
X		soldsleft-=P_ASOLD;
X		P_ATYPE=defaultunit(country);
X		P_ASTAT=GARRISON;
X		P_AMOVE=0;
X		P_AXLOC=curntn->capx;
X		P_AYLOC=curntn->capy;
X		armynum++;
X
X		armysize = max( armysize, soldsleft  / (MAXARM-numleaders-1));
X
X		/* give you your leaders */
X		leadtype = getleader(curntn->class);
X		P_ATYPE = leadtype-1;	/* This is the national leader */
X		P_ASOLD = *(unitminsth+((leadtype-1)%UTYPE));
X		P_AXLOC = curntn->capx;
X		P_AYLOC = curntn->capy;
X		P_ASTAT = DEFEND;
X		P_AMOVE = 2*curntn->maxmove;
X		armynum++;
X		numleaders--;
X		while ((armynum < MAXARM)&&(numleaders>0)) {
X			P_ATYPE=leadtype;
X			P_ASOLD= *(unitminsth+(leadtype%UTYPE));
X			P_AXLOC=curntn->capx;
X			P_AYLOC=curntn->capy;
X			P_ASTAT=DEFEND;
X			P_AMOVE=2*curntn->maxmove;
X			armynum++;
X			numleaders--;
X		}
X
X		/* give you the rest of your armies */
X		while((armynum < MAXARM)&&(soldsleft >0)) {
X			P_ATYPE=defaultunit(country);
X			if(soldsleft >= armysize){
X				P_ASOLD=armysize;
X				soldsleft -=armysize;
X			} else {
X				P_ASOLD=soldsleft ;
X				soldsleft=0;
X			}
X			P_AXLOC=curntn->capx;
X			P_AYLOC=curntn->capy;
X			P_ASTAT=DEFEND;
X			P_AMOVE=curntn->maxmove;
X			armynum++;
X		}
X
X		if(soldsleft >0) {
X			curntn->arm[0].sold += soldsleft;
X			curntn->arm[0].unittyp = A_INFANTRY;
X		}
X
X		/* give you some terain to start with: pc nations get more*/
X		if (isnotpc(curntn->active)) t=1;
X		else if (curntn->location==OOPS) t=0;
X		else if (curntn->location==RANDOM) t=0;
X		else if (curntn->location==FAIR) t=1;
X		else if (curntn->location==GREAT) t=2;
X		else {
X			newerror("Error in finding placement");
X			t=0;
X		}
X		if( t==1 )
X			people = sct[x][y].people / 12;
X		else if( t==2 )
X			people = sct[x][y].people / 30;
X
X		curntn->tsctrs=1;
X		for(i=x-t;i<=x+t;i++) for(j=y-t;j<=y+t;j++)
X			if((tofood( &sct[i][j],country)>=DESFOOD)
X			&&(sct[i][j].owner==0)
X			&&(is_habitable(i,j)==TRUE)
X			&&(sct[i][j].people==0)) {
X				curntn->tsctrs++;
X				sct[i][j].owner=country;
X				sct[i][j].designation=DFARM;
X				sct[i][j].people=people;
X				sct[x][y].people-=people;
X			}
X	}
X	else {
X		if(curntn->location==OOPS) newerror("MAJOR ERROR IN PLACEMENT");
X		else if(curntn->location==RANDOM) {
X			newerror("Random Place Failed, trying to place again");
X			curntn->location=OOPS;
X			place(-1,-1);
X		} else if(curntn->location==FAIR) {
X			sprintf(tempo,"Fair Place Failed, trying again - Adding %ld people to nation",Munits[CH_PEOPLE]*Mvalues[CH_PEOPLE]/Mcost[CH_PEOPLE]);
X			newerror(tempo);
X			/*give back one point -> NLPOP people*/
X			curntn->tciv += Munits[CH_PEOPLE] * Mvalues[CH_PEOPLE]
X				/ Mcost[CH_PEOPLE];
X			curntn->location=RANDOM;
X			place(-1,-1);
X		} else if(curntn->location==GREAT) {
X			sprintf(tempo,"Great Place Failed, trying again - Adding %ld people to nation",Munits[CH_PEOPLE]*Mvalues[CH_PEOPLE]/Mcost[CH_PEOPLE]);
X			newerror(tempo);
X			/*give back one point -> NLPOP people*/
X			curntn->tciv+= Munits[CH_PEOPLE] * Mvalues[CH_PEOPLE]
X				/ Mcost[CH_PEOPLE];
X			curntn->location=FAIR;
X			place(-1,-1);
X		}
X	}
X}
X
X/*get class routine*/
X/* return the number of points needed */
Xint
Xgetclass(race)
X	int race;
X{
X	short chk=FALSE;
X	short tmp;
X	short ypos=4;
X	int i,j;
X	
X	mvprintw(ypos,0,"The List of Possible Nation Classes:");
X	ypos+=2;
X	mvprintw(ypos++,0,"     %-8s %4s   %15s %8s %4s", "class", "who",
X		"", "magic", "cost");
X	mvprintw(ypos++,0,"     %-8s %4s   %15s %8s %4s", "--------", "----",
X		"", "-------", "----");
X	for(i=1;i<NUMCLASS;i++) {
X		if (in_str(race,Classwho[i])==TRUE) {
X			mvprintw(ypos++,0," %2d) %-8s %4s %15s", i, Class[i],
X				Classwho[i], "...............");
X			tmp = strlen(CPowlist[i]);
X			for(j=0; j < 10-tmp ; j++) {
X				addch('.');
X			}
X			printw(" %s", CPowlist[i]);
X			if (i == C_WARLORD && race == HUMAN)
X				printw(" %4d", Classcost[i]*2/3);
X			else printw(" %4d", Classcost[i]);
X		}
X	}
X	ypos++;
X	while(chk==FALSE){
X		mvprintw(ypos,0,"Enter the number of your choice: ");
X		clrtoeol();
X		refresh();
X		tmp = get_number();
X		if (tmp < 1 || tmp > NUMCLASS) {
X			newerror("Invalid Choice");
X		} else if (in_str(race,Classwho[tmp])==TRUE) {
X			chk = TRUE;
X		} else {
X			newerror("That Class is Invalid for your Race");
X		}
X	}
X	curntn->class=tmp;
X	for(tmp=ypos; tmp>4; tmp--) {
X		move(tmp,0);
X		clrtoeol();
X	}
X	
X	return( doclass( curntn->class, TRUE ) );
X}
X
Xint
Xdoclass( tmp, isupd )
Xshort	tmp;
Xint	isupd;	/* true if update, false if interactive */
X{
X	int cost;
X	long x;
X
X	/* determine number of leaders you want */
X	if((tmp == C_TRADER) || (tmp <= C_WIZARD))
X		spent[CH_LEADERS] = 5;
X	else	spent[CH_LEADERS] = 7;
X
X	/* assign the powers */
X	x=Classpow[tmp];
X
X	/* check for special case */
X	if (tmp==C_WARLORD && curntn->race==HUMAN) {
X		x ^= WARRIOR;
X		cost = Classcost[tmp]*2/3;
X	} else {
X		cost = Classcost[tmp];
X	}
X	curntn->powers |= x;
X
X	if ( isupd ) CHGMGK;
X	return(cost);
X}
X
Xint
Xnstartcst()	/* to be used for new method */
X{
X	float points=0.0;
X	char temp[LINELTH];
X	int i;
X
X	/* calculate cost for all so far */
X	for (i=0; i<CH_NUMBER; i++) {
X		points += Mcost[i] * (float) spent[i] / Munits[i];
X	}
X
X	/* extra points for starting late */
X	points -= (float) (TURN-1) / LATESTART;
X	if( (TURN-1)/LATESTART > 0.0 ) {
X		sprintf(temp,"%.1f points added for starting late",
X			   (float) (TURN-1) / LATESTART);
X		newerror(temp);
X	}
X	points += 1.0;	/* round up */	
X	return((int)points);
X}
X
Xint
Xstartcost()	/* cant be used for npc nations yet!!! see below */
X{
X	float	points;	/* points */
X
X	points = ((float)curntn->tciv)/ONLPOP;
X	points += ((float)curntn->tgold)/ONLGOLD;
X	points += ((float)curntn->tmil)/ONLSOLD;
X	if(curntn->race==ORC) {
X		points += ((float)curntn->repro)*ONLREPCOST/(ONLREPRO_ORC);
X		points += ((float)curntn->aplus*2)/ONLATTACK;
X		points += ((float)curntn->dplus*2)/ONLDEFENCE;
X	} else {
X		points += ((float)curntn->aplus)/ONLATTACK;
X		points += ((float)curntn->dplus)/ONLDEFENCE;
X		points += ((float)curntn->repro)*ONLREPCOST/ONLREPRO;
X	}
X	points += ((float)curntn->maxmove)/ONLMOVE;
X	if(curntn->location==FAIR)
X		points += ONLLOCCOST;
X	else if(curntn->location==GREAT)
X		points += 2*ONLLOCCOST;
X	/* points+=ONLDBLCOST*curntn->tfood/ONLHFOOD; */
X	points -= (TURN-1) / LATESTART;	/* extra points if you start late */
X	if( TURN > 1 )
X	printf("point cost for nation %d is %.2f (bonus for latestart is %f)\n",country,points,(float) (TURN-1)/LATESTART);
X
X	points += 1.0;	/* round up */
X	return((int) points);
X}
SHAR_EOF
chmod 0640 newlogin.c || echo "restore of newlogin.c fails"
sed 's/^X//' << 'SHAR_EOF' > oMakefile &&
X#	conquer: Copyright (c) 1988 by Edward M Barlow
X#
X#	BY CHANGING THIS FILE, YOU AGREE TO ABIDE BY THE LIMITATIONS STATED IN
X#	THE LIMITED USE CONTRACT CONTAINED IN THE FILE "header.h"
X#
XMAKE	= /bin/make
XCC	= /bin/cc
XRM	= /bin/rm -f
X
X#	LN must be "ln -s" if source, data, and default span disks
XLN	= ln
XCP	= cp
XNULL	= 2>/dev/null
X
X#	This should be installed by whomever you want to own the game.
X#	I recommend "games" or "root".
X
X#if the final link does not compile change to the line below
X#LIBRARIES = -lcurses -ltermcap
XLIBRARIES = -lcurses
X
X#	this is the name of the user executable
X#	the user executable contains commands for the games players
XGAME = conquer
X#	this is the name of the administrative executable
X#	the administrative executable contains commands for the game super user
XADMIN = conqrun
X
X#	This directory is where the executables will be stored
X#	This would be the equivalent of /usr/games
XEXEDIR = /c28/smile/game/runv
X
X#	GAME IDENTIFICATION
X#	GAMEID is the game identifier
X#	DATA is the directory where an individual Conquer game data will be
X#	stored.  It is the directory you use in the -d option of the game.
X#	"make new_game" will build a world in that directory.  The current
X#	game will be automatically executed upon login (no need for -d)
X#	but if other games are compiled, you need to use -d (ie. the
X#	game automatically looks at the DATA directory it was compiled with.
XGAMEID = 1
XDATA = $(EXEDIR)/lib$(GAMEID)
X
X#	The following CFLAGS should be set by a normal user
XCFLAGS  = -DDEFAULTDIR=\"$(DATA)\" -O -s -DEXEDIR=\"$(EXEDIR)\"
X#	The following CFLAGS should be used if you wish to debug the game
X#CFLAGS  = -DDEFAULTDIR=\"$(DATA)\" -DDEBUG -g -DEXEDIR=\"$(EXEDIR)\"
X
X# AFILS are files needed for game updating...
XAFILS = combat.c cexecute.c io.c admin.c makeworl.c  navy.c spew.c \
Xnewlogin.c update.c magic.c npc.c misc.c randeven.c data.c trade.c check.c
XAOBJS = combat.o cexecuteA.o ioA.o admin.o makeworl.o  navyA.o \
Xnewlogin.o update.o magicA.o npc.o miscA.o randeven.o dataA.o \
XtradeA.o check.o $(GETOPT) spew.o
X
X# GFILS are files needed to run a normal interactive game
XGFILS = commands.c cexecute.c forms.c io.c main.c move.c navy.c \
Xmagic.c misc.c reports.c data.c display.c extcmds.c trade.c check.c
XGOBJS = commands.o cexecute.o forms.o io.o main.o move.o navy.o \
Xmagic.o misc.o reports.o data.o display.o extcmds.o trade.o check.o $(GETOPT)
X
X#txt[0-5] are input help files.  help[0-5] are output
XHELP0=txt0
XHELP1=txt1
XHELP2=txt2
XHELP3=txt3
XHELP4=txt4
XHELP5=txt5
XHELPOUT=help
X
XHEADERS=header.h data.h newlogin.h patchlevel.h
XHELPFILES= $(HELP0) $(HELP1) $(HELP2) $(HELP3) $(HELP4) $(HELP5)
XALLFILS=$(HEADERS) $(AFILS) commands.c forms.c main.c move.c \
Xreports.c display.c extcmds.c $(HELPFILES) nations Makefile README \
Xrun man.pag notes.v4 rules sort.c newhelp.c
X
Xall:	$(ADMIN) $(GAME) helpfile conqsort
X	@echo YAY! make new_game to set up permissions, zero appropriate
X	@echo initial files, move $(GAME) and $(ADMIN) to
X	@echo $(EXEDIR), and set up the world.
X	@echo If a game is in progress, make install will just move $(GAME)
X	@echo and $(ADMIN) to $(EXEDIR).
X	@echo
X
X$(ADMIN):	$(AOBJS)
X	@echo phew...
X	@echo if the next command does not compile, you might also need -ltermcap
X	@echo === compiling administrative functions
X	$(CC) -p -o $(ADMIN) $(AOBJS) $(LIBRARIES)
X
X$(GAME):	$(GOBJS)
X	@echo phew...
X	@echo if the next command does not compile, you might also need -ltermcap
X	@echo === compiling user interface
X	$(CC) -O -o $(GAME) $(GOBJS) $(LIBRARIES)
X
Xconqsort:
X	$(CC) -O -oconqsort sort.c
X
Xclobber:
X	$(RM) *.o core newhelp sed.1 sed.2 lint* \
X		conquer.doc $(GAME) $(ADMIN) $(HELPOUT)[0-5] 2>/dev/null
X
Xclean:
X	$(RM) *.o core conquer.doc sed.1 sed.2 newhelp $(HELPOUT)[0-5] 2>/dev/null
X
Xinstall:  all
X	-$(LN) $(GAME) $(EXEDIR)/$(GAME) $(NULL)
X	-$(LN) $(ADMIN) $(EXEDIR)/$(ADMIN) $(NULL)
X	-$(LN) conqsort $(EXEDIR)/conqsort $(NULL)
X	chmod 4755 $(EXEDIR)/$(GAME)
X	chmod 4750 $(EXEDIR)/$(ADMIN)
X	$(CP) conqsort nations rules $(HELPOUT)? $(DATA) $(NULL)
X
Xnew_game:  all
X	@echo Installing new game in $(EXEDIR)
X	-mkdir $(EXEDIR) 2>/dev/null
X	chmod 755 $(EXEDIR)
X	-$(LN) $(GAME) $(EXEDIR)/$(GAME) $(NULL)
X	-$(LN) $(ADMIN) $(EXEDIR)/$(ADMIN) $(NULL)
X	chmod 4755 $(EXEDIR)/$(GAME)
X	chmod 4750 $(EXEDIR)/$(ADMIN)
X	chmod 0700 run
X	@echo Copying data to library $(DATA)
X	-mkdir $(DATA) 2>/dev/null
X	chmod 751 $(DATA)
X	chmod 0600 nations
X	$(CP) nations rules $(HELPOUT)? $(DATA) $(NULL)
X	@echo now making the world
X	$(EXEDIR)/$(ADMIN) -d$(DATA) -m
X	$(EXEDIR)/$(ADMIN) -d$(DATA) -a
X
Xhelpfile:	$(HELPOUT)0
X	@echo Helpfiles built
X
X$(HELPOUT)0:	newhelp $(HELPFILES)
X	@echo Building the help files
X	newhelp
X	cat $(HELP0) | sed -f sed.1 > $(HELPOUT)0
X	cat $(HELP1) | sed -f sed.1 | sed -f sed.2 > $(HELPOUT)1
X	cat $(HELP2) | sed -f sed.1 > $(HELPOUT)2
X	cat $(HELP3) | sed -f sed.1 | sed -f sed.2 > $(HELPOUT)3
X	cat $(HELP4) | sed -f sed.1 > $(HELPOUT)4
X	cat $(HELP5) | sed -f sed.1 > $(HELPOUT)5
X	chmod 0644 $(HELPOUT)[0-5]
X	-$(RM) sed.1 sed.2
X
Xlint:
X	lint -DDEFAULTDIR=\"$(DATA)\" -DEXEDIR=\"$(EXEDIR)\" -DCONQUER $(GFILS) $(LIBRARIES)> lintg
X	lint -DDEFAULTDIR=\"$(DATA)\" -DEXEDIR=\"$(EXEDIR)\" -DADMIN $(AFILS) $(LIBRARIES) > linta
X
Xdocs:	helpfile conquer.doc
X
Xconquer.doc:	$(HELPOUT)0 $(HELPOUT)1 $(HELPOUT)2 $(HELPOUT)3 $(HELPOUT)4 $(HELPOUT)5
X	cat $(HELPOUT)?|sed -e "s/^DONE//g"|sed -e "s/^END//g" > conquer.doc
X
Xshar:
X	echo " lines   words chars   FILENAME" > MANIFEST
X	wc $(ALLFILS) >> MANIFEST
X	$(HOME)/src/xshar/xshar -D -c -l64 -oshar -v $(ALLFILS)
X
Xcombat.o:	data.h header.h combat.c
X	$(CC) $(CFLAGS) -DADMIN -c combat.c
Xcexecute.o:	data.h header.h cexecute.c
X	$(CC) $(CFLAGS) -DCONQUER -c cexecute.c
Xio.o:	data.h header.h  io.c
X	$(CC) $(CFLAGS) -DCONQUER -c io.c
XcexecuteA.o:	data.h header.h cexecute.c
X	$(CC) $(CFLAGS) -DADMIN -c cexecute.c
X	mv cexecute.o cexecuteA.o
XioA.o:	data.h header.h  io.c
X	$(CC) $(CFLAGS) -DADMIN -c io.c
X	mv io.o ioA.o
Xadmin.o:	data.h header.h admin.c
X	$(CC) $(CFLAGS) -DADMIN -c admin.c
Xmakeworl.o:	data.h header.h makeworl.c
X	$(CC) $(CFLAGS) -DADMIN -c makeworl.c
Xnewlogin.o:	data.h header.h newlogin.h newlogin.c
X	$(CC) $(CFLAGS) -DADMIN -c newlogin.c
Xupdate.o:	data.h header.h update.c
X	$(CC) $(CFLAGS) -DADMIN -c update.c
Xmagic.o:	data.h header.h magic.c
X	$(CC) $(CFLAGS) -DCONQUER -c magic.c
XmagicA.o:	data.h header.h magic.c
X	$(CC) $(CFLAGS) -DADMIN -c magic.c
X	mv magic.o magicA.o
Xnpc.o:	data.h header.h npc.c
X	$(CC) $(CFLAGS) -DADMIN -c npc.c
Xmisc.o:	data.h header.h misc.c
X	$(CC) $(CFLAGS) -DCONQUER -c misc.c
XmiscA.o:	data.h header.h misc.c
X	$(CC) $(CFLAGS) -DADMIN -c misc.c
X	mv misc.o miscA.o
Xrandeven.o:	data.h header.h randeven.c
X	$(CC) $(CFLAGS) -DADMIN -c randeven.c
Xdata.o:	data.h header.h data.c
X	$(CC) $(CFLAGS) -DCONQUER -c data.c
XdataA.o:	data.h header.h data.c
SHAR_EOF
echo "End of part 1, continue with part 2"
echo "2" > s2_seq_.tmp
exit 0