Before attempting to upgrade from an old version (pre 2.4x), 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, 
you can delete the offending line out of global.h without breaking anything
(you may get warnings from the compiler about implicit declariations as a 
result, fix them or not). Different versions of gcc (2.3.3 and 2.5.8 for 
example) define different prototypes, so a few changes will probably be 
needed in 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 (3 or so) after installing a version with 
unoptimized code, and with debugging info on. Except for turns where there 
are major battles, the code seldom takes more than a minute or two to run a 
turn (sans report writing and data file reading/writing, which can take several 
minutes) on a sun 4 (IPX or Sparc 20 at the moment), so I personally don't 
optimize the code or turn debugging info off.

You will probably want to build three 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).
The third copy is needed to create the game's datafile and can be deleted after
you've created the game.

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. What documatation there is for it is included
(I don't encourage the use of the scripts, they work well, but are poorly
written, and should really be replaced).

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 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. It is
           no longer used by most of the code, other than the version file.
           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?)


   -DBALANCE If defined, attempts to "Balance" the planet distribution
           in a "fair" manner. Check doc/Starting-a-game for a discussion
           of what I am doing with the Balance option. It is strongly
           recomended that you use this option. Note: This may
           substantially increase the ammount of time it takes to
           create a galaxy.
           Default: off
           TESTED

                 ++++ 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
           (potential for this, see below), 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 

   -DPTECH Adds code for 'Partial techs'. Check the rules for details.
           Mostly TESTED (use at own risk, appears to work)

                 ++++ 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. Probably will never be
           completed.

   -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.

   -DBLINDCARRY Planned new feature. May be renamed.

                 ++++ Reserved, for internal use ++++

   -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: ++++

            Note: Define only 1 of these. Defining 0, or more than 1
            may cause strange behavior.

   -DSUNOS4 If you are compiling on a Sun running SunOS 4.1 through 4.1.4,
            define this. It might also work on a SunOS 4.0 box, but I no
            longer have access to one.
   -DHPUX   If you are using HP-UX 9.03, define this. It will probably
            work under 8.07 and other flavors of 9.x as well.
   -DSOLARIS If you are compiling on a Solaris 2.x machine, define this.
            Do not define the SUNOS4 flag! I tested this on a Solaris 2.3
            box.
   -DULTRIX The Ultrix boxes I tested this on did not have a strdup()
            function. This compile switch provides one. 
            There are actually two- one I wrote (which I thought works), 
            and one from Mr SJ Murphy <sjmur2@aurora.cc.monash.edu.au>
            which replaces mine (which apparently didn't work).
            Both are in misc.c. Take your pick, one should work.
            11/20/94 Addendum: my strdup function had the args to
            memcpy() backwards.
            Note: Ultrix's make appears to be stupid. All the @if
            stuff has to go for the targets to build.
   -DAIX    If you want to use an AIX machine (I tried a Risc6000, 3.25 box)
            Start with this flag.


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 (but no the other way around).

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, so there is no need to 
use makedepend. If you are not using a sun running SunOS 4.1.? on a sun4
platform, you may need to make additional changes. Likely changes (more 
detail in the relevant chunk of the Makefile): CCPIPE should be undefined
on sun3's and Ultrix 4.3, 4.4 machines; CC if you want to use something
other than gcc (good luck)


++++++

After that you are ready to go type (For the lazy, see the section labeled
"Lazy Compiling").

There are 3 executables you are likely to want:
1) One for creating new games
2) One for running games in progress
3) One for preprocessing player orders

For making a new game, you will want to make the target 'New-game', by typing
make New-game
[After deciding on features to enable, as well as the features relating to
how you want to create a new game.] If all goes well, there will be an
executable named "New-game" when the compilation finishes. See the file
doc/Starting-a-game for what to do now.

make Blind
[for 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)

Note:
  Doing a "make" with PREPROC defined will generate errors when it gets
to the final stage of compiling (it will be unable to resolve the symbols
sterilize and frand). If PREPROC is defined, you _must_ do
"make blind.dbg" or "make dbg-plus"

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]
If you can't stand doing that, do as suggested in Lazy Compiling.

++++++
Lazy Compiling

If you absolutely hate editing the makefile all the time to switch between
compiling a Blind and blind.dbg executable, enable the features you want 
in the Makefile (with or without the preprocessor options). 

Edit support/Compile-all to build a forecasting blind.dbg (or not).

Run support/Compile-all from the same directory as the C source code.
It will build Blind and blind.dbg executables for you. Note: This is slower
than editing the makefile, since it compiles both programs from scratch.

++++++

Installing

I don't install it myself using the Makefile, but if you wish, edit
INSTALLDIR in the Makefile to point to the right place, and do a
make install after you have a Blind and blind.dbg executable.

Warning: make install will NOT check for Blind and blind.dbg being up
to date, nor will it make backup copies of the old executables.

++++++

Summary of common make options:
make Blind      - "normal" game executable
make New-game   - for creating new games (includes game creation code)
make blind.dbg  - for the original preprocessor (obsolete)
make dbg-plus   - for the preprocessor with the FORECAST code
make clean      - deletes cruft
make very-clean - deletes all cruft - core *.o blindrc forecast.F Blind
                  blind.dbg New-game Edit

++++++

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
cmds.c          The command entering/parsing code.
edit.c          Prototype of a data file editor.
enterturn.c     Name to number functions, plus support functions for cmds.c
loadgame.c      loading game functions
misc.c          miscellany
new-game.c      start a new game code (planet stuff)
new-galaxy.c    start a new game code (main driver)
report.c        report printing code
savegame.c      saving game functions
turn.c          turn running code (sans battle code).
version.c       info on compile options, rcsid stuff
report-battle.c report writing code for battles
report-gm.c     report writing code for gm snooping functions
report-main.c   main report writing code and misc functions for it
report-map.c    report writing code for maps
report-planets.c report writing code for system printing
report-ships.c  report writing code for ship printing
report-status.c report writing code for player status
cmds/Cmds-lib.c misc functions for parsing player commands
cmds/?.c        code to deal with the command (e.g. a.c for the "A" command)
protos/*        Prototypes for various functions, and data structure definitions
protos/global.h      Shut up gcc -Wall prototypes 



+++++++
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,new-galaxy,addplayer):
global.h:42: warning: `struct timeb' declared inside parameter list
global.h:42: warning: its scope is only this definition or declaration,
global.h:42: warning: which is probably not what you want.

This appears to only happen under gcc 2.5.8 and older:
report-main.c: In function `spf':
report-main.c:64: warning: precision and `0' flag both used in one %-sequence
report-main.c: In function `ff':
report-main.c:141: warning: precision and `0' flag both used in one %-sequence

cmds/?.c:1: warning: `rcsid' defined but not used

gcc 2.6.0 also, for reasons that are not clear to me, complains about
the seventh arg to putmap in report-map.c. gcc 2.5.8 and earlier does not.

Any other errors/warnings need to be checked into.

+++++++++ Troubleshooting the compile process ++++++

1) I get gazilions of errors on the system's header files.
   A: Have your sys-admin run "fixincludes". gcc -ansi
      doesn't like certain vendor's header files (Sun OS 4.x)
   A2: Drop the -ansi flag from the CFLAGS

2) I get warnings about -Wconversion -Wmissing-prototypes
    -Wstrict-prototypes or -ggdb being unknown flags from gcc/gcc-cc1
   A: You are using an old version of gcc. Upgrade (:-)
   A2: Drop them. They are intended to warn you of brain death on
       my part, and inconsistences between header files. Replace
       "-ggdb" with "-g" 

3) I can't get an executable under Ultrix 4.3/4.4, even though you claim
   it will compile.
   A: The idiot checking in the Makefile tickles a misfeature of Ultrix.
      You can get the Makefile to work correctly if you remove the code
      between the @if and fi blocks for the the Blind, New-game etc targets.
+++++++++ Upgrading from an older (pre 2.40) 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 (for players), 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 right 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 datafile 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.

