Rev 1805 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1805 | Rev 5123 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #ifndef _HEADER_HISTORY_H |
1 | #ifndef _HEADER_HISTORY_H |
2 | #define _HEADER_HISTORY_H |
2 | #define _HEADER_HISTORY_H |
Line 3... | Line -... | ||
3 | - | ||
4 | #ifndef __MENUET__ |
- | |
5 | #include |
- | |
6 | #include |
- | |
7 | #include |
- | |
8 | #include |
- | |
9 | #endif |
3 | |
10 | #include "position.h" |
4 | #include "position.h" |
11 | #include "hash.h" |
5 | #include "hash.h" |
Line 12... | Line 6... | ||
12 | #include "sysproc.h" |
6 | #include "sysproc.h" |
13 | 7 | ||
14 | class THistory |
8 | class THistory |
15 | { |
9 | { |
16 | #ifndef __MENUET__ |
10 | #ifndef NO_FILES |
17 | public: |
11 | public: |
18 | static char FileName[1024]; |
12 | static char FileName[1024]; |
19 | #endif |
13 | #endif |
Line 25... | Line 19... | ||
25 | 19 | ||
26 | int Start(const Position &pos) const; |
20 | int Start(const Position &pos) const; |
27 | int Move(const Position &pos, const unsigned char mv[], int nmove) const; |
21 | int Move(const Position &pos, const unsigned char mv[], int nmove) const; |
Line 28... | Line 22... | ||
28 | int Play(const PlayWrite &play) const; |
22 | int Play(const PlayWrite &play) const; |
29 | 23 | ||
30 | #ifndef __MENUET__ |
24 | #ifndef NO_FILES |
31 | static int InitHFile(char *dname = 0); |
25 | static int InitHFile(char *dname = 0); |
32 | static int HRead(FILE *f, PlayWrite *&play); |
26 | static int HRead(FILE *f, PlayWrite *&play); |
33 | protected: |
27 | protected: |
Line 117... | Line 111... | ||
117 | TStr str; |
111 | TStr str; |
118 | int k; |
112 | int k; |
119 | }; |
113 | }; |
120 | }; |
114 | }; |
Line 121... | Line 115... | ||
121 | 115 | ||
122 | #ifndef __MENUET__ |
116 | #ifndef NO_FILES |
123 | char THistory::FileName[1024] = "history.che"; |
117 | char THistory::FileName[1024] = "history.che"; |
124 | #endif |
118 | #endif |
Line 125... | Line 119... | ||
125 | int THistory::NHid = 0; |
119 | int THistory::NHid = 0; |
126 | 120 | ||
127 | #ifndef __MENUET__ |
121 | #ifndef NO_FILES |
128 | int THistory::Print(const char *str) const |
122 | int THistory::Print(const char *str) const |
129 | { |
123 | { |
130 | char *line = new char[30 + strlen(str)]; |
124 | char *line = new char[30 + strlen(str)]; |
Line 148... | Line 142... | ||
148 | } |
142 | } |
149 | #endif |
143 | #endif |
Line 150... | Line 144... | ||
150 | 144 | ||
151 | int THistory::Start(const Position &pos) const |
145 | int THistory::Start(const Position &pos) const |
- | 146 | { |
|
152 | { |
147 | #ifndef NO_FILES |
153 | char str[20 + NUM_CELL] = "Start "; |
148 | char str[20 + NUM_CELL] = "Start "; |
154 | if (!pos.Write(str + strlen(str), 1)) return 0; |
- | |
155 | #ifndef __MENUET__ |
149 | if (!pos.Write(str + strlen(str), 1)) return 0; |
156 | if (!Print(str)) return 0; |
150 | if (!Print(str)) return 0; |
157 | #endif |
151 | #endif |
158 | return 1; |
152 | return 1; |
Line 159... | Line 153... | ||
159 | } |
153 | } |
160 | 154 | ||
- | 155 | int THistory::Move(const Position &pos, const unsigned char mv[], int nmove) const |
|
161 | int THistory::Move(const Position &pos, const unsigned char mv[], int nmove) const |
156 | { |
162 | { |
157 | #ifndef NO_FILES |
163 | char *str = new char[15 + pos.GetLenMvEx(mv, 11)]; |
158 | char *str = new char[15 + pos.GetLenMvEx(mv, 11)]; |
164 | if (!str) return 0; |
159 | if (!str) return 0; |
165 | sprintf(str, "%d.%s ", (nmove + 1) / 2, (nmove % 2 == 0) ? ".." : ""); |
- | |
166 | pos.WriteMvEx(mv, str + strlen(str), 11); |
160 | sprintf(str, "%d.%s ", (nmove + 1) / 2, (nmove % 2 == 0) ? ".." : ""); |
167 | #ifndef __MENUET__ |
- | |
168 | if (!Print(str)) {delete[] str; return 0;} |
161 | pos.WriteMvEx(mv, str + strlen(str), 11); |
- | 162 | if (!Print(str)) {delete[] str; return 0;} |
|
169 | #endif |
163 | delete[] str; |
170 | delete[] str; |
164 | #endif |
Line 171... | Line 165... | ||
171 | return 1; |
165 | return 1; |
172 | } |
166 | } |
Line 186... | Line 180... | ||
186 | if (!Move(pos, mv, i)) return 0; |
180 | if (!Move(pos, mv, i)) return 0; |
187 | } |
181 | } |
188 | return 1; |
182 | return 1; |
189 | } |
183 | } |
Line 190... | Line 184... | ||
190 | 184 | ||
191 | #ifndef __MENUET__ |
185 | #ifndef NO_FILES |
192 | int THistory::InitHFile(char *dname) |
186 | int THistory::InitHFile(char *dname) |
193 | { |
187 | { |
194 | if (dname && dname[0]) |
188 | if (dname && dname[0]) |
195 | { |
189 | { |
Line 260... | Line 254... | ||
260 | for (i = 0; *s; i = (i+1) & 15) r += *(s++) * K[i]; |
254 | for (i = 0; *s; i = (i+1) & 15) r += *(s++) * K[i]; |
261 | r &= (1 << m) - 1; |
255 | r &= (1 << m) - 1; |
262 | return r; |
256 | return r; |
263 | } |
257 | } |
Line 264... | Line 258... | ||
264 | 258 | ||
265 | #ifndef __MENUET__ |
259 | #ifndef NO_FILES |
266 | int THistory::HRead(FILE *f, PlayWrite *&play) |
260 | int THistory::HRead(FILE *f, PlayWrite *&play) |
267 | { |
261 | { |
268 | const int MAX_INP_WORD = 100; |
262 | const int MAX_INP_WORD = 100; |
269 | int nplay = 0, mplay = 10; |
263 | int nplay = 0, mplay = 10; |