Before attempting to upgrade from an old version, you
should go through the next section anyway. Upgrading details are
at the end of this file.

Building the Blind executable:

global.h is a header file that I added to get gcc -Wall to shut up
about Sun's non-ansi header files & such. You may not need or want it.
In particular, the prototypes may conflict with those on your system.
Should you get errors about conflicting types as a result of this file, 
delete the offending line out of global.h.

If you have gdb (the GNU debugger) you can set DBGFLAGS to -ggdb instead
of -g while debugging. Due to the cranky nature of the code, I recommend 
running the first couple of turns (10 or so) with unoptimized code, and 
with debugging info on. Except for turns where there are major battles,
the code seldom take more than a minute to run a turn (sans report writing,
which can take several turns) on a sun 4 (IPX at the moment), so I personally
don't optimize the code.

You will probably want to build two copies of the Blind program. One copy
for the GM's use, which has complete access to the datafile, and a second
"preprocessor" which has more limited access (in particular, it can not write
over the datafile, all it can do is help you to weed out player errors).

If you are going to be running the game where the player's e-mail you orders,
you'll probably want to have a preprocesor set up so that they can access
it. There are copies of the scripts that I use to do that for my games 
included in the distribution.

The following options are available to be changed in the Makefile:

 Game specific compile flags:
   -DINTERACTIVE - user prompted again for parts of commands that are incorrect,
            rather than having them tossed. This option is not fully supported,
            and may go away in the future.
            Default: off

 [All the flags below where added by Howard Bampton (bampton@cs.utk.edu):]

                 ++++ GM helper flags ++++

   -DBACKUPS Make backup copy of data file on exit. The backup file
           will be named 'blindrc.<turnnumber>.bak' Implies
           PREPROC not defined.
           Default: off
           TESTED (provided the system call works, no error checking)

   -DREPORTDIR=\"directory\" Reports will be written to directory, instead
           of the current one.
           Default: off
           TESTED (fails if direcotory isn't writable/there)

   -DGAMENAME Allows you to save the gamename into the blindrc file
           Default: off
           **** MODIFIED DATAFILE ****

   -DFCASTNAMES forecast reports by default are named "forecast.F"
           Enabling this option, will cause them to be named.
           <empirename>.F [with naming restrictions similar to
           normal reports- spaces, back tics, quotes all get stripped.]

   -DVERBOSE Prints out status info (phases in particular) while 
           running a turn.
           Default: on
           TESTED

                 ++++ New game flags ++++

   -DNEWGAME This includes the functions for creating a new game. Once your
           game is up and running, you may want to recompile without this flag
           to save space.
           Implies PREPROC not defined.
           Default: off
           TESTED

   -DRANDPLACE If defined, random player placement is done (otherwise
           GM enters locations). This option is only of use if you are
           creating a new game. Implies PREPROC not defined.
           Default: off
           TESTED

   -DMINSEP=# sets the minimum separation between players to #LY, requires
           -DRANDPLACE. Implies PREPROC not defined.
           This option only has to be defined if you are creating a new
           galaxy, and wish to change the default value of 20LY.
           Default: off
           TESTED, typical values range from 20-40LY. (25-30 is best?)

                 ++++ Optional features ++++

   -DKCMD  Adds the K-command (allowing you to set war/peace status on
           a per planet/per empire basis).
           Default: on
           *** Modified data files. ***
           TESTED


   -DCARRYOVER keeps track of opposing player's & their tech levels from
           turn to turn.
           Default: on
           *** Modified data files. ***
           TESTED

   -DV3    Include more V3 compatibility. At present:
           changed weapon mass, population to industry mods, new cargo 
           rules, battle summary [left over ships]
           Default: on
           *** Modified data files. ***
           TESTED 

   -DNEW   *** This switch is no longer used,
           Adds upgrade code, and potential for selective planet defense code.
           Note: The selective planet defense coding required more changes
           to the data file than originally planned. See -DKCMD.
           Also adds scrap command, ships in production tables, limited options
           If you are using any other compile switches other than
           PREPROC, you should use this option. I haven't tested
           the code with, for example, V3 defined and NEW not defined.
           Default: off
           *** Modified data files. ***

   -DUPGRADE Adds in support new features for V2.40: Fleets, partial techs,
           ships built in a class, etc. This is essentially a new "NEW".
           At some future date, support for non UPGRADE blindrc files will
           be dropped.
           Note: Do not define this flag, and the DBOMBBUG flag.
           Default: on 
           *** Modified data files. ***
           TESTED (well, hopefully)

                 ++++ Bug Workarounds ++++

   -DBOMBBUG *** This switch will no longer be supported after 2.40**
           The save/load game functions don't save the ID of the
           person who bombed a planet. If you are running a game created
           under a version before 2.37, define this.
           Implies UPGRADE not defined 
           *** Modified data files. ***

   -DSIZEBUG For reasons unknown, sizeof(shiptype) doesn't change when
           you add the UPGRADE numbuilt data to shiptype, so it can not
           read the data file. This works around that bug.
           Try doing the upgrade without this. If the upgrade fails, define
           it.

   -DNONAMEBUG This changes the time that the C command takes effect.
           Default: on
           *** Modified data files. ***
           TESTED.

                 ++++ Preprocesor options ++++

   -DPREPROC if you are using a preprocessor (returns error code==
           #errors encountered, extra newlines, reduced top level
           command set) This implies INTERACTIVE not defined...
           TESTED

   -DSMART  Deals with botched commands in a smarter manner, similar to
           V3.x "mistakes" section. Note this is intended to be used with
           a preprocessor. Errors are dumped to stderr.
           Implies PREPROC defined.
           TESTED

   -DFORECAST Adds functions to allow forecasts of next turn's status
           to be made & mailed. Note: this slows down execution speed
           by a large amount, since it is potentially writing a report
           every time the program is run.
           Implies PREPROC defined (pointless without it).
           TESTED 

                 ++++ Experimental, under construction ++++

   -DFULL_REPORTS   Give "full" header info on reports- e-mail, game name, 
           due date order format etc. [Experimental, not working] Implies 
           PREPROC not defined.
           WORK IN PROGRESS, doesn't work yet.

   -DNEW[1-3]  Experimental code, use at own risk (may not work or compile)
            Once it works, it is merged into either -DUPGRADE, or given it's
            own flag.

                 ++++ Experimental, under construction ++++

   -DFIX
   -DNOTIMEB
   -DIO    Do not use these flags. It is for playing fancy games with header
           files, or updating data files.

                 ++++ OS specific compile options: ++++

   -DULTRIX The Ultrix boxes I tested this on did not have a strdup()
            function. This compile switch provides one.

Notes:
   *** Modified data files. ***
      If you use an option marked as this, you will be unable to read the data
   file unless you have those options compiled into the executable.
   I.e. A blindrc written by a Blind executable compiled with -DNEW
   can't read a blindrc file with -DNEW, -DCARRYOVER. 
      There are some exceptions- adding -DKCMD to one with -DNEW, 
   works.

Once you've decided what features listed above you want, edit the makefile,
and look for this line:
# Comment out lines which have undesired compile flags

comment out (with #'s) those features you do not want.

The current makefile has all its own dependencies.

++++++

After that you are ready to go type
make New-game 
or
make Blind
[for creating/running new games, or running an inprogress game]
If all goes well, you will have a file named "Blind". Change the 
PROGRAM variable in the makefile if you want it named something else.

Note:
  If NEWGAME is defined, you _must_ do "make New-game".

for making the preprocessor, type (after changing the makefile as
desired): make blind.dbg
which will produce the file blind.dbg Change the PREPROC variable in 
the makefile if you want it named something else. If you use the FORECAST
option, do a "make dbg-plus" instead (the forecast option requires an
additional file to be compiled)

WARNING: gnu's make does not honor the ".KEEP_STATE" directive in the
makefile. You will either have to do a make clean every time you change the
Makefile, or add a dependency of all the .o files on the Makefile.
[They are commented out at the end of the current makefile]

++++++

Summary of make options:
make Blind     - "normal" game executable
make New-game  - for new games (includes game creation code)
make blind.dbg - for the original preprocessor
make dbg-plus  - for the preprocessor with the FORECAST code

++++++

File descriptions:
Blind.c       The "main" file.
addplayer.c   Code for adding new players, not needed after first turn.
battle.c      Combat/bombing section of the code
common.h      The header file with all the types.
cmd.c         The command parsing/handling code.
edit.c        Prototype of a data file editor.
enterturn.c   Name to number functions, plus support functions for cmds.c
cmds.c        The command entering/parsing code.
global.h      Shut up gcc -Wall prototypes 
savegame.c    saving game functions
loadgame.c    loading game functions
misc.c        miscellany
new-game.c    start a new game code (planet stuff)
prot.h        global prototypes
report.c      report printing code
turn.c        turn running code (sans battle code).
version.c     info on compile options, rcsid stuff
protos/*      Prototypes for various functions.


+++++++
Compiler errors/warnings:
  On our Sun's, with gcc -Wall, these are the errors that you'll get.
All of these errors can be safely ignored:

Blind.c: warning: implicit declaration of function `_flsbuf'

From several files (savegame,new-game):
global.h:40: warning: `struct timeb' declared inside parameter list
global.h:40: warning: its scope is only this definition or declaration,
global.h:40: warning: which is probably not what you want.

report.c: In function `spf':
report.c:64: warning: precision and `0' flag both used in one %-sequence
report.c: In function `ff':
report.c:141: warning: precision and `0' flag both used in one %-sequence

Any other errors/warnings need to be checked into.

+++++++++ Upgrading from an older datafile ++++++++
If you do not want to add any of the features of the UPGRADE
option, you are done. Compile and run at will.

If your game does not have the upgrade command in it, you will
probably be unable to upgrade your program.

If your game was not compiled with the BOMBBUG option, you will need to
edit savegame.c, and work around the BOMBBUG/FIX code near line 250.

If your compile options included NEW and BOMBBUG, all you need to
do is:
  1) Edit the Makefile, and turn on the features that you had before
  2) Add the new features you want (UPGRADE, REPORTDIR, NONAMEBUG)
  3) Type: 'make upgrade clean Blind'
  4) Watch.

Notes/warnings: The dependencies are not quite for upgrade, so
after doing a 'make upgrade' you should always delete loadgame.o 
and savegame.o (or do a 'make clean' just to be certain).

A backup copy of the blindrc file will be made, just in case
something fails during the upgrade.

The blindrc file to be upgraded must be in the current directory
for the upgrade to work automatically.

To manually upgrade, run the program "Fix" (entering the game's
name if you added that feature), and quit. The savegame() function
will write out the new style blindrc file format.

