-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathSaveGame.cpp
More file actions
226 lines (198 loc) · 6.04 KB
/
Copy pathSaveGame.cpp
File metadata and controls
226 lines (198 loc) · 6.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#include "stdafx.h"
#include "data.h"
#include "chess.h"
#include "Resource.h"
#include "pregen.h"
//
//char *
//SavePart(char *str){
// static char buf[MSG_SIZ];
// char *p;
//
// p = strchr(str, ' ');
// if (p == NULL){
// return str;
// }
// //strncpy(buf, str, p - str);
// strncpy_s(buf,MSG_SIZ,str,p-str);
// buf[p - str] = NULLCHAR;
// return buf;
//}
//int /* Save the current game to the given file */
//SaveGameToFile(char *filename,int append){
// FILE *f;
// char buf[MSG_SIZ];
//
// if (strcmp(filename, "-") == 0) {
// return SaveGame(stdout, 0, NULL);
// }
// else {
// //f = fopen(filename, append ? "a" : "w");
// fopen_s(&f,filename,append ? "a" : "w");
// if (f == NULL) {
// // sprintf(buf, "Can't open \"%s\"", filename);
// StringCbPrintf(buf,MSG_SIZ,"Can't open \"%s\"", filename);
// DisplayError(buf, errno);
// return FALSE;
// }
// else {
// return SaveGame(f, 0, NULL);
// }
// }
//}
/* Save game in PGN style and close the file */
int
SaveGamePGN(FILE *f){
return false;
//int i, offset, linelen, newblock;
//time_t tm;
//char *movetext;
//char numtext[32];
//int movelen, numlen, blank;
//tm = time((time_t *) NULL);
//PrintPGNTags(f, &DIS.GGQJ);
//if (DIS.backwardMostMove > 0 || DIS.startedFromSetupPosition) {
// char fen[MSG_SIZ];
// PositionToFEN(fen,DIS.backwardMostMove,DIS.ucci);
// fprintf(f, "[FEN \"%s\"]\n[SetUp \"1\"]\n", fen);
// fprintf(f, "\n{--------------\n");
// PrintPosition(f, DIS.backwardMostMove);
// fprintf(f, "--------------}\n");
// //free(fen);
//}
//else {
// fprintf(f, "\n");
//}
//i = DIS.backwardMostMove;
//offset = DIS.backwardMostMove & (~1L); /* output move numbers start at 1 */
//linelen = 0;
//newblock = TRUE;
//while (i < DIS.forwardMostMove) {
// /* Print comments preceding this move */
// //if (DIS.commentList[i] != NULL) {
// // if (linelen > 0) fprintf(f, "\n");
// // fprintf(f, "{\n%s}\n", DIS.commentList[i]);
// // linelen = 0;
// // newblock = TRUE;
// //}
// /* Format move number */
// if ((i % 2) == 0) {
// //sprintf(numtext, "%d.", (i - offset)/2 + 1);
// StringCbPrintf(numtext,sizeof(numtext),"%d.", (i - offset)/2 + 1);
// }
// else {
// if (newblock) {
// //sprintf(numtext, "%d...", (i - offset)/2 + 1);
// StringCbPrintf(numtext,sizeof(numtext),"%d...", (i - offset)/2 + 1);
// }
// else {
// numtext[0] = NULLCHAR;
// }
// }
// numlen = (int)strlen(numtext);
// newblock = FALSE;
// /* Print move number */
// blank = linelen > 0 && numlen > 0;
// if (linelen + (blank ? 1 : 0) + numlen > PGN_MAX_LINE) {
// fprintf(f, "\n");
// linelen = 0;
// blank = 0;
// }
// if (blank) {
// fprintf(f, " ");
// linelen++;
// }
// fprintf(f, numtext);
// linelen += numlen;
// /* Get move */
// movetext = SavePart(DIS.parseList[i]);
// movelen = (int)strlen(movetext);
// /* Print move */
// blank = linelen > 0 && movelen > 0;
// if (linelen + (blank ? 1 : 0) + movelen > PGN_MAX_LINE) {
// fprintf(f, "\n");
// linelen = 0;
// blank = 0;
// }
// if (blank) {
// fprintf(f, " ");
// linelen++;
// }
// fprintf(f, movetext);
// linelen += movelen;
// i++;
//}
///* Start a new line */
//if (linelen > 0) fprintf(f, "\n");
///* Print comments after last move */
////if (DIS.commentList[i] != NULL) {
//// fprintf(f, "{\n%s}\n", DIS.commentList[i]);
////}
///* Print result */
////if (DIS.gameInfo.resultDetails != NULL &&
//// DIS.gameInfo.resultDetails[0] != NULLCHAR) {
//if(DIS.GGQJ.resultDetails[0] != NULLCHAR){
// fprintf(f, "{%s} %s\n\n", DIS.GGQJ.resultDetails,PGNResult(DIS.GGQJ.cmresult));
//}
//else {
// fprintf(f, "%s\n\n", PGNResult(DIS.GGQJ.cmresult));
//}
//fclose(f);
//return TRUE;
}
/* Save the current game to open file f and close the file */
int
SaveGame(FILE *f,int dummy,char *dummy2){
//if (DIS.gameMode == EditPosition){
// EditPositionDone();
//}
//return SaveGamePGN(f);
return FALSE;
}
/* Save the current position to the given file */
int
SavePositionToFile(char *filename){
//FILE *f;
//char buf[MSG_SIZ];
//if (strcmp(filename, "-") == 0) {
// return SavePosition(stdout, 0, NULL);
//} else {
// //f = fopen(filename, "a");
// fopen_s(&f,filename,"a");
// if (f == NULL) {
// // sprintf(buf, "Can't open \"%s\"", filename);
// StringCbPrintf(buf,MSG_SIZ,"Can't open \"%s\"", filename);
// DisplayError(buf, errno);
// return FALSE;
// } else {
// SavePosition(f, 0, NULL);
// return TRUE;
// }
//}
return FALSE;
}
/* Save the current position to the given open file and close the file */
int
SavePosition(FILE *f,int dummy,char *dummy2){
//time_t tm;
//char fen[MSG_SIZ];
//char buf[MSG_SIZ];
//if (appData.oldSaveStyle) {
// tm = time((time_t *) NULL);
// //fprintf(f, "# %s position file -- %s", DIS.programName, ctime(&tm));
// ctime_s(buf,MSG_SIZ,&tm);
// fprintf(f, "# %s position file -- %s", DIS.programName, buf);
// PrintOpponents(f);
// fprintf(f, "[--------------\n");
// PrintPosition(f, DIS.currentMove);
// fprintf(f, "--------------]\n");
//}
//else {
/*PositionToFEN(fen,DIS.currentMove,UCCI_UCCI);*/
//PositionToFEN(fen,DIS.pos.curStep,UCCI_UCCI162);
//fprintf(f, "%s\n", fen);
////free(fen);
////}
//fclose(f);
return TRUE;
}