| 893 |
893 |
| 894 if (settings.continuepgn) { |
894 if (settings.continuepgn) { |
| 895 FILE *pgnfile = fopen(settings.continuepgn, "r"); |
895 FILE *pgnfile = fopen(settings.continuepgn, "r"); |
| 896 if (pgnfile) { |
896 if (pgnfile) { |
| 897 int result = read_pgn(pgnfile, &gamestate); |
897 int result = read_pgn(pgnfile, &gamestate); |
| 898 long position = ftell(pgnfile); |
|
| 899 fclose(pgnfile); |
898 fclose(pgnfile); |
| 900 if (result) { |
899 if (result) { |
| 901 printw("Invalid PGN file content at position %ld:\n%s\n", |
900 printw("Invalid PGN file content at position %zu:\n%s\n", |
| 902 position, pgn_error_str(result)); |
901 pgn_error_position(), pgn_error_str(result)); |
| 903 gamestate_cleanup(&gamestate); |
902 gamestate_cleanup(&gamestate); |
| 904 return; |
903 return; |
| 905 } |
904 } |
| 906 if (!is_game_running(&gamestate)) { |
905 if (!is_game_running(&gamestate)) { |
| 907 addstr("Game has ended. Use -S to analyze it.\n"); |
906 addstr("Game has ended. Use -S to analyze it.\n"); |
| 1049 /* preload PGN data before handshake */ |
1048 /* preload PGN data before handshake */ |
| 1050 bool cancel = false; |
1049 bool cancel = false; |
| 1051 FILE *pgnfile = fopen(settings.continuepgn, "r"); |
1050 FILE *pgnfile = fopen(settings.continuepgn, "r"); |
| 1052 if (pgnfile) { |
1051 if (pgnfile) { |
| 1053 int result = read_pgn(pgnfile, &gamestate); |
1052 int result = read_pgn(pgnfile, &gamestate); |
| 1054 long position = ftell(pgnfile); |
|
| 1055 fclose(pgnfile); |
1053 fclose(pgnfile); |
| 1056 if (result) { |
1054 if (result) { |
| 1057 printw("Invalid PGN file content at position %ld:\n%s\n", |
1055 printw("Invalid PGN file content at position %zu:\n%s\n", |
| 1058 position, pgn_error_str(result)); |
1056 pgn_error_position(), pgn_error_str(result)); |
| 1059 cancel = true; |
1057 cancel = true; |
| 1060 } else if (!is_game_running(&gamestate)) { |
1058 } else if (!is_game_running(&gamestate)) { |
| 1061 addstr("Game has ended. Use -s to analyze it locally.\n"); |
1059 addstr("Game has ended. Use -s to analyze it locally.\n"); |
| 1062 cancel = true; |
1060 cancel = true; |
| 1063 } |
1061 } |