711700c39d48c48c7b6c6c0a6652af30e50f7a16
[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};
40
41 #define NUM_GAMETYPES 7 
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 };
73
74 struct journal {
75   char slot;
76   char WhiteName[MAX_LOGIN_NAME];
77   int WhiteRating;
78   char BlackName[MAX_LOGIN_NAME];
79   int BlackRating;
80   char type[4];
81   int t;
82   int i;
83   char eco[4];
84   char ending[4];
85   char result[8];
86 };
87
88
89 GENSTRUCT struct game {
90         /* Not saved in game file */
91         int revertHalfMove;
92         int totalHalfMoves;
93         int white;
94         int black;
95         int link;
96         enum gamestatus status;
97         int examHalfMoves;
98         int examMoveListSize;  
99         struct move_t *examMoveList; _LEN(examMoveListSize)    /* extra movelist for examine */
100
101         unsigned startTime;    /* The relative time the game started  */
102         unsigned lastMoveTime; /* Last time a move was made */
103         unsigned lastDecTime;  /* Last time a players clock was decremented */
104         int flag_pending;
105         int wTimeWhenReceivedMove;
106         int wTimeWhenMoved;
107         int bTimeWhenReceivedMove;
108         int bTimeWhenMoved;
109         int wLastRealTime;
110         int wRealTime;
111         int bLastRealTime;
112         int bRealTime;
113
114         /* this is a dummy variable used to tell which bits are saved in the structure */
115         unsigned not_saved_marker;
116   
117         /* Saved in the game file */
118         enum gameend result;
119         int winner;
120         int wInitTime, wIncrement;
121         int bInitTime, bIncrement;
122         time_t timeOfStart;
123         unsigned flag_check_time;
124         int wTime;
125         int bTime;
126         int clockStopped;
127         int rated;
128         int private;
129         enum gametype type;
130         int passes; /* For simul's */
131         int numHalfMoves;
132         int moveListSize; /* Total allocated in *moveList */
133         struct move_t *moveList; _LEN(moveListSize)      /* primary movelist */
134         char FENstartPos[74]; _NULLTERM   /* Save the starting position. */
135         struct game_state_t game_state;
136         
137         char white_name[MAX_LOGIN_NAME]; _NULLTERM   /* to hold the playername even after he disconnects */        
138         char black_name[MAX_LOGIN_NAME]; _NULLTERM   
139         int white_rating;
140         int black_rating;
141 };
142
143 extern const char *TypeStrings[NUM_GAMETYPES];
144 extern const char *TypeChars[NUM_GAMETYPES];
145
146 #endif
147