2 Copyright (c) 1993 Richard V. Nash.
3 Copyright (c) 2000 Dan Papasian
4 Copyright (C) Andrew Tridgell 2002
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.
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.
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.
24 support for reading the old player formats
25 thank goodness I don't need to update this any more! It sure was a complex format.
29 /* return 0 if corrupt */
31 static int ReadV1PlayerFmt(int p,struct player *pp, FILE * fp, const char *file, int version)
34 int i,size_cens, size_noplay, size_not, size_gnot, size_chan, len;
36 int bell, pgn, notifiedby, pin, gin, avail, private, jprivate;
37 int open, ropen, rated, tell, kib, shout, cshout, automail, mailmess;
41 char tmp2[MAX_STRING_LENGTH];
43 fgets(tmp2, MAX_STRING_LENGTH, fp);
44 if (strcmp(tmp2,"NONE\n")) {
45 tmp2[strlen(tmp2)-1] = '\0';
46 pp->name = strdup (tmp2);
49 fgets(tmp2, MAX_STRING_LENGTH, fp);
50 if (strcmp(tmp2,"NONE\n")) {
51 tmp2[strlen(tmp2)-1] = '\0';
52 pp->fullName = strdup (tmp2);
55 fgets(tmp2, MAX_STRING_LENGTH, fp);
56 if (strcmp(tmp2,"NONE\n")) {
57 tmp2[strlen(tmp2)-1] = '\0';
58 pp->passwd = strdup (tmp2);
61 fgets(tmp2, MAX_STRING_LENGTH, fp);
62 if (strcmp(tmp2,"NONE\n")) {
63 tmp2[strlen(tmp2)-1] = '\0';
64 pp->emailAddress = strdup (tmp2);
66 pp->emailAddress = NULL;
67 if (fscanf(fp, "%u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %d\n",
69 &pp->s_stats.num, &pp->s_stats.win, &pp->s_stats.los,
70 &pp->s_stats.dra, &pp->s_stats.rating, &ss,
71 &pp->s_stats.ltime, &pp->s_stats.best, &pp->s_stats.whenbest,
73 &pp->b_stats.num, &pp->b_stats.win, &pp->b_stats.los,
74 &pp->b_stats.dra, &pp->b_stats.rating, &bs,
75 &pp->b_stats.ltime, &pp->b_stats.best, &pp->b_stats.whenbest,
77 &pp->w_stats.num, &pp->w_stats.win, &pp->w_stats.los,
78 &pp->w_stats.dra, &pp->w_stats.rating, &ws,
79 &pp->w_stats.ltime, &pp->w_stats.best, &pp->w_stats.whenbest,
81 &pp->l_stats.num, &pp->l_stats.win, &pp->l_stats.los,
82 &pp->l_stats.dra, &pp->l_stats.rating, &ls,
83 &pp->l_stats.ltime, &pp->l_stats.best, &pp->l_stats.whenbest,
85 &pp->bug_stats.num, &pp->bug_stats.win, &pp->bug_stats.los,
86 &pp->bug_stats.dra, &pp->bug_stats.rating, &bugs,
87 &pp->bug_stats.ltime, &pp->bug_stats.best, &pp->bug_stats.whenbest,
88 &pp->lastHost.s_addr) != 46) {
89 d_printf("Player %s is corrupt\n",player_globals.parray[p].name);
92 free(pp->emailAddress);
95 pp->emailAddress = NULL;
99 pp->b_stats.sterr = bs / 10.0;
100 pp->s_stats.sterr = ss / 10.0;
101 pp->w_stats.sterr = ws / 10.0;
102 pp->l_stats.sterr = ls / 10.0;
103 pp->bug_stats.sterr = bugs / 10.0;
105 fgets (tmp2, MAX_STRING_LENGTH, fp);
106 tmp2[strlen(tmp2)-1] = '\0';
107 pp->prompt = strdup(tmp2);
109 if (fscanf (fp, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
110 &open, &rated, &ropen, &pp->timeOfReg,
111 &pp->totalTime, &bell, &pgn, ¬ifiedby,
112 &pin, &gin, &shout, &cshout,
113 &tell, &kib, &private, &jprivate,
114 &automail, &mailmess, &pp->style, &pp->d_time,
115 &pp->d_inc, &pp->d_height, &pp->d_width, &pp->language,
116 &pp->adminLevel, &pp->num_white, &pp->num_black, &pp->highlight,
118 &pp->num_plan, &pp->num_formula,&size_cens,
119 &size_not, &size_noplay,
120 &size_gnot, &numAlias, &size_chan) != 37) {
121 d_printf("Player %s is corrupt.\n",player_globals.parray[p].name);
123 pp->prompt = config_get("DEFAULT_PROMPT");
126 free(pp->emailAddress);
129 pp->emailAddress = NULL;
135 } else if (version == 2) {
136 if (fscanf (fp, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
137 &open, &rated, &ropen, &pp->timeOfReg,
138 &pp->totalTime, &bell, &pgn, ¬ifiedby,
139 &pin, &gin, &avail, &shout, &cshout,
140 &tell, &kib, &private, &jprivate,
141 &automail, &mailmess, &pp->style, &pp->d_time,
142 &pp->d_inc, &pp->d_height, &pp->d_width, &pp->language,
143 &pp->adminLevel, &pp->num_white, &pp->num_black, &pp->highlight,
145 &pp->num_plan, &pp->num_formula,&size_cens,
146 &size_not, &size_noplay,
147 &size_gnot, &numAlias, &size_chan) != 38) {
148 d_printf("Player %s is corrupt.\n",player_globals.parray[p].name);
150 pp->prompt = config_get("DEFAULT_PROMPT");
153 free(pp->emailAddress);
156 pp->emailAddress = NULL;
162 } else if (version > 2) {
163 if (fscanf (fp, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
164 &open, &rated, &ropen, &pp->timeOfReg,
165 &pp->totalTime, &bell, &pgn, ¬ifiedby,
166 &pin, &gin, &avail, &shout, &cshout,
167 &tell, &kib, &private, &jprivate,
168 &automail, &mailmess, &pp->style, &pp->d_time,
169 &pp->d_inc, &pp->d_height, &pp->d_width, &pp->language,
170 &pp->adminLevel, &pp->num_white, &pp->num_black, &pp->highlight,
172 &pp->num_plan, &pp->num_formula,&size_cens,
173 &size_not, &size_noplay,
174 &size_gnot, &numAlias, &size_chan, &pp->availmin, &pp->availmax) != 40) {
175 d_printf("Player %s is corrupt.\n",player_globals.parray[p].name);
177 pp->prompt = config_get("DEFAULT_PROMPT");
180 free(pp->emailAddress);
183 pp->emailAddress = NULL;
190 SetFlag(pp->Flags, PFLAG_OPEN, open);
191 SetFlag(pp->Flags, PFLAG_ROPEN, ropen);
192 SetFlag(pp->Flags, PFLAG_RATED, rated);
193 SetFlag(pp->Flags, PFLAG_BELL, bell);
194 SetFlag(pp->Flags, PFLAG_PGN, pgn);
195 SetFlag(pp->Flags, PFLAG_NOTIFYBY, notifiedby);
196 SetFlag(pp->Flags, PFLAG_PIN, pin);
197 SetFlag(pp->Flags, PFLAG_GIN, gin);
198 SetFlag(pp->Flags, PFLAG_AVAIL, avail);
199 SetFlag(pp->Flags, PFLAG_PRIVATE, private);
200 SetFlag(pp->Flags, PFLAG_JPRIVATE, jprivate);
201 SetFlag(pp->Flags, PFLAG_SHOUT, shout);
202 SetFlag(pp->Flags, PFLAG_CSHOUT, cshout);
203 SetFlag(pp->Flags, PFLAG_TELL, tell);
204 SetFlag(pp->Flags, PFLAG_KIBITZ, kib);
205 SetFlag(pp->Flags, PFLAG_AUTOMAIL, automail);
206 SetFlag(pp->Flags, PFLAG_MAILMESS, mailmess);
209 getc (fp); /* skip a dot */
211 if (pp->num_plan > 0) {
212 for (i = 0; i < pp->num_plan; i++) {
213 fgets(tmp2, MAX_LINE_SIZE, fp);
214 if (!(len = strlen(tmp2))) {
215 d_printf( "CHESSD: Error bad plan in file %s\n", file);
219 tmp2[len - 1] = '\0'; /* Get rid of '\n' */
220 pp->planLines[i] = (len > 1) ? strdup(tmp2) : NULL;
224 if (pp->num_formula > 0) {
225 for (i = 0; i < pp->num_formula; i++) {
226 fgets(tmp2, MAX_LINE_SIZE, fp);
227 if (!(len = strlen(tmp2))) {
228 d_printf( "CHESSD: Error bad formula in file %s\n", file);
232 tmp2[len - 1] = '\0'; /* Get rid of '\n' */
233 pp->formulaLines[i] = (len > 1) ? strdup(tmp2) : NULL;
237 fgets(tmp2, MAX_LINE_SIZE, fp);
238 tmp2[strlen(tmp2) - 1] = '\0';
239 if (!strcmp (tmp2,"NONE"))
242 pp->formula = strdup(tmp2);
245 for (i = 0; i < numAlias; i++) {
246 fgets(tmp2, MAX_LINE_SIZE, fp);
247 if (!(len = strlen(tmp2))) {
248 d_printf( "CHESSD: Error bad alias in file %s\n", file);
251 tmp2[len - 1] = '\0'; /* Get rid of '\n' */
257 alias_add(p, tmp2, tmp);
262 while (size_cens--) {
263 fscanf(fp,"%s",tmp2);
264 list_add(p, L_CENSOR, tmp2);
268 fscanf(fp,"%s",tmp2);
269 list_add(p, L_NOTIFY, tmp2);
272 while(size_noplay--) {
273 fscanf(fp,"%s",tmp2);
274 list_add(p, L_NOPLAY, tmp2);
278 fscanf(fp,"%s",tmp2);
279 list_add(p, L_GNOTIFY, tmp2);
283 fscanf(fp,"%s",tmp2);
284 list_add(p, L_CHANNEL, tmp2);
289 static int got_attr_value_player(int p, char *attr, char *value, FILE * fp, const char *file)
292 char tmp[MAX_LINE_SIZE], *tmp1;
295 if (!strcmp(attr, "name:")) {
296 player_globals.parray[p].name = strdup(value);
297 } else if (!strcmp(attr, "password:")) {
298 player_globals.parray[p].passwd = strdup(value);
299 } else if (!strcmp(attr, "fullname:")) {
300 player_globals.parray[p].fullName = strdup(value);
301 } else if (!strcmp(attr, "email:")) {
302 player_globals.parray[p].emailAddress = strdup(value);
303 } else if (!strcmp(attr, "prompt:")) {
304 player_globals.parray[p].prompt = strdup(value);
305 } else if (!strcmp(attr, "s_num:")) {
306 player_globals.parray[p].s_stats.num = atoi(value);
307 } else if (!strcmp(attr, "s_win:")) {
308 player_globals.parray[p].s_stats.win = atoi(value);
309 } else if (!strcmp(attr, "s_loss:")) {
310 player_globals.parray[p].s_stats.los = atoi(value);
311 } else if (!strcmp(attr, "s_draw:")) {
312 player_globals.parray[p].s_stats.dra = atoi(value);
313 } else if (!strcmp(attr, "s_rating:")) {
314 player_globals.parray[p].s_stats.rating = atoi(value);
315 } else if (!strcmp(attr, "s_sterr:")) {
316 player_globals.parray[p].s_stats.sterr = (atoi(value) / 10.0);
317 } else if (!strcmp(attr, "s_ltime:")) {
318 player_globals.parray[p].s_stats.ltime = atoi(value);
319 } else if (!strcmp(attr, "s_best:")) {
320 player_globals.parray[p].s_stats.best = atoi(value);
321 } else if (!strcmp(attr, "s_wbest:")) {
322 player_globals.parray[p].s_stats.whenbest = atoi(value);
323 } else if (!strcmp(attr, "b_num:")) {
324 player_globals.parray[p].b_stats.num = atoi(value);
325 } else if (!strcmp(attr, "b_win:")) {
326 player_globals.parray[p].b_stats.win = atoi(value);
327 } else if (!strcmp(attr, "b_loss:")) {
328 player_globals.parray[p].b_stats.los = atoi(value);
329 } else if (!strcmp(attr, "b_draw:")) {
330 player_globals.parray[p].b_stats.dra = atoi(value);
331 } else if (!strcmp(attr, "b_rating:")) {
332 player_globals.parray[p].b_stats.rating = atoi(value);
333 } else if (!strcmp(attr, "b_sterr:")) {
334 player_globals.parray[p].b_stats.sterr = (atoi(value) / 10.0);
335 } else if (!strcmp(attr, "b_ltime:")) {
336 player_globals.parray[p].b_stats.ltime = atoi(value);
337 } else if (!strcmp(attr, "b_best:")) {
338 player_globals.parray[p].b_stats.best = atoi(value);
339 } else if (!strcmp(attr, "b_wbest:")) {
340 player_globals.parray[p].b_stats.whenbest = atoi(value);
341 } else if (!strcmp(attr, "w_num:")) {
342 player_globals.parray[p].w_stats.num = atoi(value);
343 } else if (!strcmp(attr, "w_win:")) {
344 player_globals.parray[p].w_stats.win = atoi(value);
345 } else if (!strcmp(attr, "w_loss:")) {
346 player_globals.parray[p].w_stats.los = atoi(value);
347 } else if (!strcmp(attr, "w_draw:")) {
348 player_globals.parray[p].w_stats.dra = atoi(value);
349 } else if (!strcmp(attr, "w_rating:")) {
350 player_globals.parray[p].w_stats.rating = atoi(value);
351 } else if (!strcmp(attr, "w_sterr:")) {
352 player_globals.parray[p].w_stats.sterr = (atoi(value) / 10.0);
353 } else if (!strcmp(attr, "w_ltime:")) {
354 player_globals.parray[p].w_stats.ltime = atoi(value);
355 } else if (!strcmp(attr, "w_best:")) {
356 player_globals.parray[p].w_stats.best = atoi(value);
357 } else if (!strcmp(attr, "w_wbest:")) {
358 player_globals.parray[p].w_stats.whenbest = atoi(value);
359 } else if (!strcmp(attr, "open:")) {
360 SetPFlag(p, PFLAG_OPEN, atoi(value));
361 } else if (!strcmp(attr, "rated:")) {
362 SetPFlag(p, PFLAG_RATED, atoi(value));
363 } else if (!strcmp(attr, "ropen:")) {
364 SetPFlag(p, PFLAG_ROPEN, atoi(value));
365 } else if (!strcmp(attr, "bell:")) {
366 SetPFlag(p, PFLAG_BELL, atoi(value));
367 } else if (!strcmp(attr, "pgn:")) {
368 SetPFlag(p, PFLAG_PGN, atoi(value));
369 } else if (!strcmp(attr, "timeofreg:")) {
370 player_globals.parray[p].timeOfReg = atoi(value);
371 } else if (!strcmp(attr, "totaltime:")) {
372 player_globals.parray[p].totalTime = atoi(value);
373 } else if (!strcmp(attr, "notifiedby:")) {
374 SetPFlag(p, PFLAG_NOTIFYBY, atoi(value));
375 } else if (!strcmp(attr, "i_login:")) {
376 SetPFlag(p, PFLAG_PIN, atoi(value));
377 } else if (!strcmp(attr, "i_game:")) {
378 SetPFlag(p, PFLAG_GIN, atoi(value));
379 } else if (!strcmp(attr, "i_shout:")) {
380 SetPFlag(p, PFLAG_SHOUT, atoi(value));
381 } else if (!strcmp(attr, "i_cshout:")) {
382 SetPFlag(p, PFLAG_CSHOUT, atoi(value));
383 } else if (!strcmp(attr, "i_tell:")) {
384 SetPFlag(p, PFLAG_TELL, atoi(value));
385 } else if (!strcmp(attr, "i_kibitz:")) {
386 SetPFlag(p, PFLAG_KIBITZ, atoi(value));
387 } else if (!strcmp(attr, "kiblevel:")) {
388 player_globals.parray[p].kiblevel = atoi(value);
389 } else if (!strcmp(attr, "private:")) {
390 SetPFlag(p, PFLAG_PRIVATE, atoi(value));
391 } else if (!strcmp(attr, "jprivate:")) {
392 SetPFlag(p, PFLAG_JPRIVATE, atoi(value));
393 } else if (!strcmp(attr, "automail:")) {
394 SetPFlag(p, PFLAG_AUTOMAIL, atoi(value));
395 } else if (!strcmp(attr, "i_mailmess:")) {
396 SetPFlag(p, PFLAG_MAILMESS, atoi(value));
397 } else if (!strcmp(attr, "style:")) {
398 player_globals.parray[p].style = atoi(value);
399 } else if (!strcmp(attr, "d_time:")) {
400 player_globals.parray[p].d_time = atoi(value);
401 } else if (!strcmp(attr, "d_inc:")) {
402 player_globals.parray[p].d_inc = atoi(value);
403 } else if (!strcmp(attr, "d_height:")) {
404 player_globals.parray[p].d_height = atoi(value);
405 } else if (!strcmp(attr, "d_width:")) {
406 player_globals.parray[p].d_width = atoi(value);
407 } else if (!strcmp(attr, "language:")) {
408 player_globals.parray[p].language = atoi(value);
409 } else if (!strcmp(attr, "admin_level:")) {
410 player_globals.parray[p].adminLevel = atoi(value);
411 if (player_globals.parray[p].adminLevel >= ADMIN_ADMIN)
412 PFlagON(p, PFLAG_ADMINLIGHT);
413 } else if (!strcmp(attr, "i_admin:")) {
414 /* player_globals.parray[p].i_admin = atoi(value); */
415 } else if (!strcmp(attr, "computer:")) {
416 /* player_globals.parray[p].computer = atoi(value); */
417 } else if (!strcmp(attr, "black_games:")) {
418 player_globals.parray[p].num_black = atoi(value);
419 } else if (!strcmp(attr, "white_games:")) {
420 player_globals.parray[p].num_white = atoi(value);
421 } else if (!strcmp(attr, "uscf:")) {
422 /* player_globals.parray[p].uscfRating = atoi(value); */
423 } else if (!strcmp(attr, "muzzled:")) { /* ignore these: obsolete */
424 } else if (!strcmp(attr, "cmuzzled:")) { /* ignore these: obsolete */
425 } else if (!strcmp(attr, "highlight:")) {
426 player_globals.parray[p].highlight = atoi(value);
427 } else if (!strcmp(attr, "network:")) {
428 /* player_globals.parray[p].network_player = atoi(value); */
429 } else if (!strcmp(attr, "lasthost:")) {
430 player_globals.parray[p].lastHost.s_addr = atoi(value);
431 } else if (!strcmp(attr, "channel:")) {
432 list_addsub(p,"channel",value, 1);
433 } else if (!strcmp(attr, "num_comments:")) {
434 player_globals.parray[p].num_comments = atoi(value);
435 } else if (!strcmp(attr, "num_plan:")) {
436 player_globals.parray[p].num_plan = atoi(value);
437 if (player_globals.parray[p].num_plan > 0) {
438 for (i = 0; i < player_globals.parray[p].num_plan; i++) {
439 fgets(tmp, MAX_LINE_SIZE, fp);
440 if (!(len = strlen(tmp))) {
441 d_printf( "CHESSD: Error bad plan in file %s\n", file);
443 player_globals.parray[p].num_plan--;
445 tmp[len - 1] = '\0'; /* Get rid of '\n' */
446 player_globals.parray[p].planLines[i] = (len > 1) ? strdup(tmp) : NULL;
450 } else if (!strcmp(attr, "num_formula:")) {
451 player_globals.parray[p].num_formula = atoi(value);
452 if (player_globals.parray[p].num_formula > 0) {
453 for (i = 0; i < player_globals.parray[p].num_formula; i++) {
454 fgets(tmp, MAX_LINE_SIZE, fp);
455 if (!(len = strlen(tmp))) {
456 d_printf( "CHESSD: Error bad formula in file %s\n", file);
458 player_globals.parray[p].num_formula--;
460 tmp[len - 1] = '\0'; /* Get rid of '\n' */
461 player_globals.parray[p].formulaLines[i] = (len > 1) ? strdup(tmp) : NULL;
465 } else if (!strcmp(attr, "formula:")) {
466 player_globals.parray[p].formula = strdup(value);
467 } else if (!strcmp(attr, "num_alias:")) {
468 numAlias = atoi(value);
470 for (i = 0; i < numAlias; i++) {
471 fgets(tmp, MAX_LINE_SIZE, fp);
472 if (!(len = strlen(tmp))) {
473 d_printf( "CHESSD: Error bad alias in file %s\n", file);
476 tmp[len - 1] = '\0'; /* Get rid of '\n' */
478 tmp1 = eatword(tmp1);
481 tmp1 = eatwhite(tmp1);
482 alias_add(p, tmp, tmp1);
485 player_globals.parray[p].alias_list[i].comm_name = NULL;
487 } else if (!strcmp(attr, "num_censor:")) {
490 fgets(tmp, MAX_LINE_SIZE, fp);
491 if ((!(len = strlen(tmp))) || (len == 1)) { /* blank lines do occur!! */
492 d_printf( "CHESSD: Error bad censor in file %s\n", file);
494 tmp[len - 1] = '\0'; /* Get rid of '\n' */
495 list_add(p, L_CENSOR, tmp);
498 } else if (!strcmp(attr, "num_notify:")) {
501 fgets(tmp, MAX_LINE_SIZE, fp);
502 if ((!(len = strlen(tmp))) || (len == 1)) { /* blank lines do occur!! */
503 d_printf( "CHESSD: Error bad notify in file %s\n", file);
505 tmp[len - 1] = '\0'; /* Get rid of '\n' */
506 list_add(p, L_NOTIFY, tmp);
509 } else if (!strcmp(attr, "num_noplay:")) {
512 fgets(tmp, MAX_LINE_SIZE, fp);
513 if ((!(len = strlen(tmp))) || (len == 1)) { /* blank lines do occur!! */
514 d_printf( "CHESSD: Error bad noplay in file %s\n", file);
516 tmp[len - 1] = '\0'; /* Get rid of '\n' */
517 list_add(p, L_NOPLAY, tmp);
520 } else if (!strcmp(attr, "num_gnotify:")) {
523 fgets(tmp, MAX_LINE_SIZE, fp);
524 if ((!(len = strlen(tmp))) || (len == 1)) { /* blank lines do occur!! */
525 d_printf( "CHESSD: Error bad gnotify in file %s\n", file);
527 tmp[len - 1] = '\0'; /* Get rid of '\n' */
528 list_add(p, L_GNOTIFY, tmp);
531 } else if (!strcmp(attr, "num_follow:")) {
534 fgets(tmp, MAX_LINE_SIZE, fp);
535 if ((!(len = strlen(tmp))) || (len == 1)) { /* blank lines do occur!! */
536 d_printf( "CHESSD: Error bad follow in file %s\n", file);
538 tmp[len - 1] = '\0'; /* Get rid of '\n' */
539 list_add(p, L_FOLLOW, tmp);
543 d_printf( "CHESSD: Error bad attribute >%s< from file %s\n", attr, file);
551 int player_read_old(int p, FILE *fp, const char *pname, const char *fname, int version)
553 char line[MAX_LINE_SIZE];
557 if (version > 4) { /* eg if two version of code running at diff sites */
558 pprintf(p, "Your account's version number is newer than that of the version running.\n");
559 pprintf(p, "Please see an admin.\n");
560 d_printf("Player %s's version number is incorrect for this version.\n",player_globals.parray[p].name);
561 PFlagOFF(p, PFLAG_REG);
562 player_globals.parray[p].name = strdup(pname);
566 if (!ReadV1PlayerFmt(p,&player_globals.parray[p], fp, fname, version)) {/* Quick method */
567 /* error in reading; make unreg */
568 PFlagOFF(p, PFLAG_REG);
569 PFlagOFF(p, PFLAG_RATED);
570 pprintf(p, "\n*** WARNING: Your Data file is corrupt. Please tell an admin ***\n");
571 return -1; /* other data has already been freed */
574 /* do it the old SLOW way */
578 if ((len = strlen(line)) <= 1)
580 line[len - 1] = '\0';
581 attr = eatwhite(line);
583 continue; /* Comment */
584 value = eatword(attr);
586 d_printf( "CHESSD: Error reading file %s\n", fname);
591 value = eatwhite(value);
593 got_attr_value_player(p, attr, value, fp, fname);
594 fgets(line, MAX_LINE_SIZE, fp);
598 if (!player_globals.parray[p].name) {
599 player_globals.parray[p].name = strdup(pname);
600 pprintf(p, "\n*** WARNING: Your Data file is corrupt. Please tell an admin ***\n");
608 /* the old and tedious way of writing the player data */
609 static void WritePlayerFile_old(FILE* fp, int p)
612 struct player *pp = &player_globals.parray[p];
614 fprintf (fp, "v %d\n", 4);
615 if (pp->name == NULL) /* This should never happen! */
616 fprintf (fp,"NONE\n");
618 fprintf(fp, "%s\n", pp->name);
619 if (pp->fullName == NULL)
620 fprintf (fp,"NONE\n");
622 fprintf(fp, "%s\n", pp->fullName);
623 if (pp->passwd == NULL)
624 fprintf (fp,"NONE\n");
626 fprintf(fp, "%s\n", pp->passwd);
627 if (pp->emailAddress == NULL)
628 fprintf (fp,"NONE\n");
630 fprintf(fp, "%s\n", pp->emailAddress);
631 fprintf(fp, "%u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %u %d\n",
633 pp->s_stats.num, pp->s_stats.win, pp->s_stats.los,
634 pp->s_stats.dra, pp->s_stats.rating, (int) (pp->s_stats.sterr * 10.0),
635 pp->s_stats.ltime, pp->s_stats.best, pp->s_stats.whenbest,
637 pp->b_stats.num, pp->b_stats.win, pp->b_stats.los,
638 pp->b_stats.dra, pp->b_stats.rating, (int) (pp->b_stats.sterr * 10.0),
639 pp->b_stats.ltime, pp->b_stats.best, pp->b_stats.whenbest,
641 pp->w_stats.num, pp->w_stats.win, pp->w_stats.los,
642 pp->w_stats.dra, pp->w_stats.rating, (int) (pp->w_stats.sterr * 10.0),
643 pp->w_stats.ltime, pp->w_stats.best, pp->w_stats.whenbest,
645 pp->l_stats.num, pp->l_stats.win, pp->l_stats.los,
646 pp->l_stats.dra, pp->l_stats.rating, (int) (pp->l_stats.sterr * 10.0),
647 pp->l_stats.ltime, pp->l_stats.best, pp->l_stats.whenbest,
649 pp->bug_stats.num, pp->bug_stats.win, pp->bug_stats.los,
650 pp->bug_stats.dra, pp->bug_stats.rating, (int) (pp->bug_stats.sterr * 10.0),
651 pp->bug_stats.ltime, pp->bug_stats.best, pp->bug_stats.whenbest,
654 fprintf (fp, "%s\n", pp->prompt);
655 fprintf (fp, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
656 BoolCheckPFlag(p, PFLAG_OPEN), BoolCheckPFlag(p, PFLAG_RATED),
657 BoolCheckPFlag(p, PFLAG_ROPEN), pp->timeOfReg,
658 pp->totalTime, BoolCheckPFlag(p, PFLAG_BELL),
659 BoolCheckPFlag(p, PFLAG_PGN), BoolCheckPFlag(p, PFLAG_NOTIFYBY),
660 BoolCheckPFlag(p, PFLAG_PIN), BoolCheckPFlag(p, PFLAG_GIN),
661 BoolCheckPFlag(p, PFLAG_AVAIL), BoolCheckPFlag(p, PFLAG_SHOUT),
662 BoolCheckPFlag(p, PFLAG_CSHOUT), BoolCheckPFlag(p, PFLAG_TELL),
663 BoolCheckPFlag(p, PFLAG_KIBITZ), BoolCheckPFlag(p, PFLAG_PRIVATE),
664 BoolCheckPFlag(p, PFLAG_JPRIVATE), BoolCheckPFlag(p, PFLAG_AUTOMAIL),
665 BoolCheckPFlag(p, PFLAG_MAILMESS), pp->style,
666 pp->d_time, pp->d_inc, pp->d_height, pp->d_width, pp->language,
667 pp->adminLevel, pp->num_white, pp->num_black, pp->highlight,
669 pp->num_plan, pp->num_formula,list_size(p, L_CENSOR),
670 list_size(p, L_NOTIFY), list_size(p, L_NOPLAY),
671 list_size(p, L_GNOTIFY), pp->numAlias, list_size(p, L_CHANNEL ), pp->availmin, pp->availmax);
673 fprintf (fp,"."); /* Dot before plan - stop ill affects of scanf */
675 for (i = 0; i < pp->num_plan; i++)
676 fprintf(fp, "%s\n", (pp->planLines[i] ? pp->planLines[i] : ""));
677 for (i = 0; i < pp->num_formula; i++)
678 fprintf(fp, "%s\n", (pp->formulaLines[i] ? pp->formulaLines[i] : ""));
679 if (player_globals.parray[p].formula != NULL)
680 fprintf(fp, "%s\n", pp->formula);
682 fprintf(fp, "NONE\n");
683 for (i = 0; i < pp->numAlias; i++)
684 fprintf(fp, "%s %s\n", pp->alias_list[i].comm_name,
685 pp->alias_list[i].alias);
687 list_print(fp, p, L_CENSOR);
688 list_print(fp, p, L_NOTIFY);
689 list_print(fp, p, L_NOPLAY);
690 list_print(fp, p, L_GNOTIFY);
691 list_print(fp, p, L_CHANNEL);