Check-in Lasker-2.2.3 tar ball from samba.org
[capablanca.git] / lasker-2.2.3 / src / playerdb.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 _PLAYERDB_H
22 #define _PLAYERDB_H
23
24 #define MAX_OBSERVE 30          /* max # of games one person can observe */
25 #define MAX_PLAN 10
26 #define MAX_FORMULA 9
27 #define MAX_CENSOR 50
28 #define MAX_NOTIFY 80
29 #define MAX_SIMUL 100
30 #define MAX_MESSAGES 40
31 #define MAX_INCHANNELS 16
32
33 #define PLAYER_EMPTY 0
34 #define PLAYER_NEW 1
35 #define PLAYER_INQUEUE 2
36 #define PLAYER_LOGIN 3
37 #define PLAYER_PASSWORD 4
38 #define PLAYER_PROMPT 5
39
40 #define P_LOGIN 0
41 #define P_LOGOUT 1
42
43 #define SORT_BLITZ 0
44 #define SORT_STAND 1
45 #define SORT_ALPHA 2
46 #define SORT_WILD 3
47
48 GENSTRUCT struct statistics {
49         int num, win, los, dra, rating, ltime, best, whenbest;
50         double sterr;
51 };
52
53 GENSTRUCT struct simul_info_t {
54         int numBoards;
55         int onBoard;
56         int num_wins, num_draws, num_losses;
57         int boards[MAX_SIMUL];
58 };
59
60 #define PFLAG_REG 0x1
61 #define PFLAG_OPEN 0x2
62 #define PFLAG_ROPEN 0x4
63 #define PFLAG_SIMOPEN 0x8
64 #define PFLAG_FLIP 0x10
65 #define PFLAG_ADMINLIGHT 0x20
66 #define PFLAG_RATED 0x40
67 #define PFLAG_BLACKSIDE 0x80  /* not done; replacing side. */
68 #define PFLAG_LASTBLACK 0x100
69 #define PFLAG_PIN 0x200
70 #define PFLAG_GIN 0x400
71 #define PFLAG_AVAIL 0x800 /* to be informed about who is available for games*/
72 #define PFLAG_PRIVATE 0x1000
73 #define PFLAG_JPRIVATE 0x2000
74 #define PFLAG_AUTOMAIL 0x4000
75 #define PFLAG_MAILMESS 0x8000
76 #define PFLAG_SHOUT 0x10000
77 #define PFLAG_CSHOUT 0x20000
78 #define PFLAG_TELL 0x40000
79 #define PFLAG_KIBITZ 0x80000
80 #define PFLAG_NOTIFYBY 0x100000
81 #define PFLAG_PGN 0x200000
82 #define PFLAG_BELL 0x400000
83 #define PFLAG_HIDEINFO 0x800000
84 #define PFLAG_TOURNEY 0x1000000  /* Not coded yet. */
85 #define PFLAG_ADS 0x2000000
86 /* Note: we're starting the last byte, assuming a long int has 4 bytes;
87    If we run out, we probably should make a Flag1 and a Flag2. */
88
89 #define PFLAG_DEFAULT (PFLAG_OPEN | PFLAG_ROPEN | PFLAG_SHOUT \
90                 | PFLAG_CSHOUT | PFLAG_KIBITZ \
91                 | PFLAG_ADMINLIGHT)
92
93 /* PFLAG_SAVED will make a good mask. */
94 #define PFLAG_SAVED  (PFLAG_OPEN | PFLAG_ROPEN | PFLAG_RATED | PFLAG_BELL \
95                       | PFLAG_PIN | PFLAG_GIN | PFLAG_AVAIL | PFLAG_PRIVATE \
96                       | PFLAG_JPRIVATE | PFLAG_AUTOMAIL | PFLAG_MAILMESS \
97                       | PFLAG_MAILMESS | PFLAG_SHOUT | PFLAG_CSHOUT \
98                       | PFLAG_TELL | PFLAG_KIBITZ | PFLAG_NOTIFYBY | PFLAG_PGN)
99
100 GENSTRUCT struct player {
101         /* This first block is not saved between logins */
102         char *login;
103         int socket;
104         int status;
105         int game;
106         int opponent; /* Only valid if game is >= 0 */
107         int side;     /* Only valid if game is >= 0 */
108         int timeOfReg;
109         int totalTime;
110         int ftell; /* Are you forwarding tells?  -1 if not else who from */
111         int logon_time;
112         int last_command_time;
113         int num_observe;
114         int observe_list[MAX_OBSERVE];
115         struct in_addr thisHost;
116         int lastshout_a;
117         int lastshout_b;
118         struct simul_info_t *simul_info;
119         int num_comments; /* number of lines in comments file */
120         int partner;
121         char *more_text;
122         int kiblevel;
123         int number_pend_from; /* not really necessary but are used to cut down */
124         int number_pend_to;   /*   search - DAV */
125         struct ivariables ivariables;
126         char *interface;
127
128         /* this is a dummy variable used to tell which bits are saved in the structure */
129         unsigned not_saved_marker;
130
131         unsigned Flags;
132         char *name;
133         char *passwd;
134         char *fullName;
135         char *emailAddress;
136         const char *prompt;
137         char *busy;
138         char *last_tell;
139         int last_channel;
140         char *last_opponent;
141         struct statistics s_stats;
142         struct statistics b_stats;
143         struct statistics w_stats;
144         struct statistics l_stats;
145         struct statistics bug_stats;
146         int d_time;
147         int d_inc;
148         int d_height;
149         int d_width;
150         int language;
151         int style;
152         int promote;
153         int adminLevel;
154         int availmin;
155         int availmax;
156         int num_plan;
157         char *planLines[MAX_PLAN];
158         int num_formula;
159         char *formulaLines[MAX_FORMULA];
160         char *formula;
161         int num_white;
162         int num_black;
163         struct in_addr lastHost;
164         int numAlias;
165         struct alias_type *alias_list; _LEN(numAlias)
166         int highlight;
167         struct List *lists;
168         int latest_news;
169         int admin_latest_news;
170 };
171
172 typedef struct textlist {
173         char *text;
174         int index;
175         struct textlist *next;
176 } textlist;
177
178 #endif /* _PLAYERDB_H */
179