Implement test for perpetual checking
[capablanca.git] / lasker-2.2.3 / src / gamedb.h
1 /*
2    Copyright (c) 1993 Richard V. Nash.
3    Copyright (c) 2000 Dan Papasian
4    Copyright (C) Andrew Tridgell 2002
5    
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #ifndef _GAMEDB_H
22 #define _GAMEDB_H
23
24 extern const char *bstr[];
25 extern const char *rstr[];
26
27 #define GAMEFILE_VERSION 5 
28 #define MAX_GLINE_SIZE 1024
29
30 #define REL_GAME 0
31 #define REL_SPOS 1
32 #define REL_REFRESH 2
33 #define REL_EXAMINE 3
34
35 GENSTRUCT enum gamestatus {GAME_EMPTY, GAME_NEW, GAME_ACTIVE, GAME_EXAMINE, GAME_SETUP};
36
37 /* Do not change the order of these - DAV */
38 GENSTRUCT enum gametype {TYPE_UNTIMED, TYPE_BLITZ, TYPE_STAND, TYPE_NONSTANDARD,
39                TYPE_WILD, TYPE_LIGHT, TYPE_BUGHOUSE, TYPE_GOTHIC, TYPE_KNIGHTMATE, TYPE_CAPABLANCA};
40
41 #define NUM_GAMETYPES 10 
42
43 /* OK, DAV, I'll try it another way. -- hersco */
44 enum ratetype {RATE_STAND, RATE_BLITZ, RATE_WILD, RATE_LIGHT, RATE_BUGHOUSE};
45 #define NUM_RATEDTYPE 5
46
47 #define FLAG_CHECKING -1
48 #define FLAG_NONE 0
49 #define FLAG_CALLED 1
50 #define FLAG_ABORT 2
51
52 GENSTRUCT enum gameend {
53         END_CHECKMATE = 0,
54         END_RESIGN,
55         END_FLAG,
56         END_AGREEDDRAW,
57         END_REPETITION,
58         END_50MOVERULE,
59         END_ADJOURN,
60         END_LOSTCONNECTION,
61         END_ABORT,
62         END_STALEMATE,
63         END_NOTENDED,
64         END_COURTESY,
65         END_BOTHFLAG,
66         END_NOMATERIAL,
67         END_FLAGNOMATERIAL,
68         END_ADJDRAW,
69         END_ADJWIN,
70         END_ADJABORT,
71         END_COURTESYADJOURN,
72         END_PERPETUAL,
73         END_BARE                // [HGM] bare king
74 };
75
76 struct journal {
77   char slot;
78   char WhiteName[MAX_LOGIN_NAME];
79   int WhiteRating;
80   char BlackName[MAX_LOGIN_NAME];
81   int BlackRating;
82   char type[4];
83   int t;
84   int i;
85   char eco[4];
86   char ending[4];
87   char result[8];
88 };
89
90
91 GENSTRUCT struct game {
92         /* Not saved in game file */
93         int revertHalfMove;
94         int totalHalfMoves;
95         int white;
96         int black;
97         int link;
98         enum gamestatus status;
99         int examHalfMoves;
100         int examMoveListSize;  
101         struct move_t *examMoveList; _LEN(examMoveListSize)    /* extra movelist for examine */
102
103         unsigned startTime;    /* The relative time the game started  */
104         unsigned lastMoveTime; /* Last time a move was made */
105         unsigned lastDecTime;  /* Last time a players clock was decremented */
106         int flag_pending;
107         int wTimeWhenReceivedMove;
108         int wTimeWhenMoved;
109         int bTimeWhenReceivedMove;
110         int bTimeWhenMoved;
111         int wLastRealTime;
112         int wRealTime;
113         int bLastRealTime;
114         int bRealTime;
115
116         /* this is a dummy variable used to tell which bits are saved in the structure */
117         unsigned not_saved_marker;
118   
119         /* Saved in the game file */
120         enum gameend result;
121         int winner;
122         int wInitTime, wIncrement;
123         int bInitTime, bIncrement;
124         time_t timeOfStart;
125         unsigned flag_check_time;
126         int wTime;
127         int bTime;
128         int clockStopped;
129         int rated;
130         int private;
131         enum gametype type;
132         int passes; /* For simul's */
133         int numHalfMoves;
134         int moveListSize; /* Total allocated in *moveList */
135         struct move_t *moveList; _LEN(moveListSize)      /* primary movelist */
136         char FENstartPos[74]; _NULLTERM   /* Save the starting position. */
137         struct game_state_t game_state;
138         
139         char white_name[MAX_LOGIN_NAME]; _NULLTERM   /* to hold the playername even after he disconnects */        
140         char black_name[MAX_LOGIN_NAME]; _NULLTERM   
141         int white_rating;
142         int black_rating;
143         char variant[80]; // [HGM] arbitrary variant name for sending to interface, derived from load-directory name
144 };
145
146 extern const char *TypeStrings[NUM_GAMETYPES];
147 extern const char *TypeChars[NUM_GAMETYPES];
148
149 #endif
150