However, when dozens are games are trying to be saved to a single file it will error.
lines 10775-10796 in backend.c
Code: Select all
/* Save the current game to the given file */
int
SaveGameToFile(filename, append)
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");
if (f == NULL) {
snprintf(buf, sizeof(buf), _("Can't open \"%s\""), filename);
DisplayError(buf, errno);
return FALSE;
} else {
return SaveGame(f, 0, NULL);
}
}
}
1) Store game into an error file, e.g., errno.pgn. This way we know it had an error, but still managed to store the game.
2) Create a multiple attempt to SaveGameToFile. Instead of just giving up right away and throwing a pop_up NULL error, why not try again after a little bit?
a) Random timer to save game. Pick a number between a range 1-10000 milliseconds, and save the game after Sleep(i).
b) Counter of attempts with a pause or Sleep(i) between attempts.
Like this:
Code: Select all
/* Save the current game to the given file */
int SaveGameToFile(filename, append)
char *filename;
int append;
{
FILE *f;
char buf[MSG_SIZ];
// Start of Joshua Haglund
int i, min, max, range;
time_t start,end;
time (&start);
for(i = 15; i <= max;)
{
max = 3000;
min = 1;
range = max - min;
i = i + 1;
}
i = 15+rand()% range;
Sleep(i);
if (strcmp(filename, "-") == 0) {
return SaveGame(stdout, 0, NULL);
} else {
i = 15+rand()% range;
Sleep(i);
// End of Joshua Haglund
f = fopen(filename, append ? "a" : "w");
if (f == NULL) {
snprintf(buf, sizeof(buf), _("Can't open \"%s\""), filename);
DisplayError(buf, errno);
return FALSE;
} else {
return SaveGame(f, 0, NULL);
}
}
}
Thoughts

Joshua D. Haglund