1    | /*
2    |  * $Log: global.c,v $
3    |  * Revision 1.15  2004/09/06 22:08:17  millis
4    |  * Bug363 Allow more than one victor
5    |  *
6    |  * Revision 1.14  2004/05/22 08:58:22  millis
7    |  * Bug 297: Add Intimate Diplomacy
8    |  *
9    |  * Revision 1.13  2004/01/04 11:34:35  millis
10   |  * Implement Bug #262 (ExtraCentres for 1900 Steamroller)
11   |  *
12   |  * Revision 1.12  2003/05/14 07:59:17  nzmb
13   |  * Fixed bug #122 -- splits dip.reply into part created before and after
14   |  * the GM issues a "become" command.
15   |  *
16   |  * Revision 1.11  2003/05/13 10:59:09  millis
17   |  * Correctly set bailout flag to initial 0 value
18   |  *
19   |  * Revision 1.10  2003/05/13 00:07:26  millis
20   |  * Bug 110, move on process deadline by 24 hours on bailout recovery
21   |  *
22   |  * Revision 1.9  2003/05/12 23:23:46  millis
23   |  * Fix bug 133, allow turn to process when set to manualprocess and process command sent.
24   |  *
25   |  * Revision 1.8  2003/01/14 13:51:36  millis
26   |  * Merges from USTV
27   |  *
28   |  * Revision 1.7  2002/08/27 23:56:10  millis
29   |  * Added better victory display (fixing Mach victory bug)
30   |  *
31   |  * Revision 1.6  2002/05/11 09:15:31  greg
32   |  * Minor bug fixes
33   |  * - fixed subjectline for absence requests
34   |  * - fixed phase length, so it's no longer hard coded for responses
35   |  * - partial fix for unusable builds, players with only unusable builds
36   |  *    will no longer be flagged as having orders due, however players
37   |  *    with some usable builds will need to waive any unusable builds,
38   |  *    also, if one or more players have unusable builds, but no
39   |  *    player has usable builds, the build phase will process after
40   |  *    a short delay
41   |  *
42   |  * Revision 1.5  2001/10/20 12:11:11  miller
43   |  * Merged in changes from DEMA and USTV 
44   |  *
45   |  * Revision 1.4.2.2  2001/10/19 23:33:42  dema
46   |  * Added initial_money + CVS header
47   |  *
48   |  *
49   |  */    
50   | 
51   | #include <stdio.h>
52   | #include "dip.h"
53   | #include "mach.h"
54   | 
55   | /* name and place of config file */
56   | char *CONFIG_FILE ="dip.conf";
57   | char *CONFIG_DIR = ".";
58   | 
59   | struct dipent dipent;
60   | FILE *log_fp;			/* General log/interlock file                   */
61   | FILE *rfp;			/* Reply file pointer                           */
62   | FILE *cfp;			/* Control file pointer                         */
63   | FILE *xfp;			/* Control file pointer                         */
64   | int nded;
65   | 
66   | char subjectline[80];
67   | 
68   | struct dedication ded[MAXUSER];
69   | 
70   | /* from mach.h */
71   | int npown[NPROV + 1];		/* New province owner  (Machiavelli)         */
72   | int ncown[NPROV + 1];		/* New city owner             (Machiavelli)          */
73   | 
74   | struct treasury ducats[NPOWER + 1];
75   | struct expense expense[NPOWER + 1][4];
76   | struct vincome vincome[MAXVINC];
77   | short bids[NPOWER + 1][NPOWER + 1];  /* Who is bidding what for whom  */
78   | 
79   | 
80   | unsigned char chits[NPOWER + 1][MAX_CHIT];	/* Assassination chits      */
81   | short payments[NPOWER + 1][NPOWER + 1];		/* Who is paying whom what  */
82   | short borrow[NPOWER + 1][2];	/* How much from bank       */
83   | unsigned char allies[NPOWER + 1][NPOWER + 1];	/* Who is allowing whom     */
84   | 
85   | int ftab[12 - 1][12 - 1];	/* Machiavelli famine province list          */
86   | int ptab[12 - 1][12 - 1];	/* Machiavelli plague province list          */
87   | int stab[12 - 1][12 - 1];       /* Machiavelli storm  province list          */
88   | struct p_unit permitted_units[MAXPLAYERS]; /* Mach list of permitted unit types	     */
89   | struct p_money initial_money;   /* Mach set of initial money */
90   | 
91   | struct extra_centre extra_centres[MAXPLAYERS]; /* list of extra units for certain powers */
92   | 
93   | /* from porder.c, probably from some header file before that, i didn't
94   |  * keep very good track -- nw Sun Oct  5 07:00:38 GMT 1997
95   |  */
96   | int cmap[CMAP_SIZE];
97   | struct province pr[NPROV + 1];
98   | int npr;			/* Actual number of provinces                 */
99   | struct units unit[MAXUNIT];
100  | char *mtype[] =
101  | {"land", "landx", "landh", "landl", "coast", "north coast",
102  |  "east coast", "west coast", "south coast", "conditional"};
103  | char line[1024];
104  | unsigned char *heap;
105  | int hp, hpx, maxheap;
106  | int nv;				/* Number of variable income cities           */
107  | 
108  | int nhk=0; 
109  | struct hk_struct hk[MAX_POWERS];
110  | 
111  | int ngw =0;
112  | struct gw_struct gw[MAX_GATEWAYS];
113  | 
114  | int nrw = 0;
115  | struct rw_struct rw[MAX_RAILWAYS];
116  | 
117  | FILE *ifp;
118  | 
119  | int nunit;			/* Actual number of units in the game         */
120  | int err;			/* Number of errors encountered               */
121  | int pline;			/* Nonzero if we've printed input line out    */
122  | int marker;			/* Nonzero if processing latest set of orders */
123  | int eof, eol;			/* Nonzero if end of file or end of line      */
124  | int processing;			/* Nonzero when processing orders             */
125  | 
126  | int need_order[NPOWER + 1];	/* Set nonzero if orders needed next phase */
127  | int more_orders;		/* Nonzero if not all units ordered           */
128  | 
129  | /*
130  |  * the following variables were moved here from dip.h so we don't
131  |  * get multiple definitions
132  |  */
133  | 
134  | /* this may need to be included in the other programs as well */
135  | char *notifies = "*";
136  | 
137  | int aflg = 0;			/* -a: don't mess with the at queue at all      */
138  | int Aflg = 0;			/* -A: don't take anything off the at queue     */
139  | char *dflg;			/* -d home directory                            */
140  | int Dflg = 0;			/* -D: output goes to stdout rather than reply  */
141  | char *nflg;			/* Our program name                             */
142  | int qflg = 0;			/* -q: quick mode, just process mail, not games */
143  | int tflg = 0;			/* -t variant: test adjudication                */
144  | char *rflg = NULL;		/* -r name: randomizer for die rolls            */
145  | int sflg = 0;			/* -s sequence: test adjudication               */
146  | int vflg = 0;			/* -v: verbose, issue all error messages        */
147  | int xflg = 0;			/* -x: no incoming mail on stdin                */
148  | char *inname = NULL;
149  | FILE *inp;
150  | 
151  | int control = 0;
152  | int predict = 0; 		/* =1 to predict a move for master */
153  | 
154  | int canbuild = 1;		/* can the power being reminded to move build? */
155  | int victor = 0;			/* Set to number of victorious powers */
156  | int victors[MAXPLAYERS];	/* Array of victors */
157  | 
158  | int process_set; 		/* Set to 1 if process command has been set */
159  | 
160  | int bailout_recovery = 0;       /* Set to 1 if recovering from a bail-out	*/
161  | 
162  | int GM_Became = 0;		/* if GM issued the become command */
163  | 
164  | int has_treasury = 0;		/* Set to 1 if the datafile supplies treasury information */