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