aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-04-23 19:36:41 +0200
committerMarkus Uhlin <markus@nifty-networks.net>2024-04-23 19:36:41 +0200
commit7dea096ff40e206d2f4cd0e5b8512903481b3c5e (patch)
tree147d0fa4176648959eb7a460058d5a96a6d18152 /FICS
parent804224e92f34999ce883ec412f5ac09ee6aa2038 (diff)
Revised FindHistory2()
Diffstat (limited to 'FICS')
-rw-r--r--FICS/obsproc.c55
1 files changed, 29 insertions, 26 deletions
diff --git a/FICS/obsproc.c b/FICS/obsproc.c
index 6b4921c..cdd2a26 100644
--- a/FICS/obsproc.c
+++ b/FICS/obsproc.c
@@ -778,36 +778,39 @@ PRIVATE char *FindHistory(int p, int p1, int game)
return(fileName);
}
-/* I want to know how game ended */
-
-PRIVATE char *FindHistory2(int p, int p1,int game,char* End)
+PRIVATE char *
+FindHistory2(int p, int p1, int game, char *End)
{
- FILE *fpHist;
- static char fileName[MAX_FILENAME_SIZE];
- int index;
- long when;
+ FILE *fpHist;
+ int index;
+ long int when;
+ static char fileName[MAX_FILENAME_SIZE];
- sprintf(fileName, "%s/player_data/%c/%s.%s", stats_dir,
- parray[p1].login[0], parray[p1].login, STATS_GAMES);
- fpHist = fopen(fileName, "r");
- if (fpHist == NULL) {
- pprintf(p, "No games in history for %s.\n", parray[p1].name);
- return(NULL);
- }
- do {
- fscanf(fpHist, "%d %*c %*d %*c %*d %*s %*s %*d %*d %*d %*d %*s %s %ld",
- &index, End, &when);
- } while (!feof(fpHist) && index != game);
+ msnprintf(fileName, sizeof fileName, "%s/player_data/%c/%s.%s",
+ stats_dir, parray[p1].login[0], parray[p1].login, STATS_GAMES);
- if (feof(fpHist)) {
- pprintf(p, "There is no history game %d for %s.\n", game, parray[p1].name);
- fclose(fpHist);
- return(NULL);
- }
- fclose(fpHist);
+ if ((fpHist = fopen(fileName, "r")) == NULL) {
+ pprintf(p, "No games in history for %s.\n", parray[p1].name);
+ return NULL;
+ }
- sprintf(fileName, "%s/%ld/%ld", hist_dir, when % 100, when);
- return(fileName);
+ do {
+ fscanf(fpHist, "%d %*c %*d %*c %*d %*s %*s %*d %*d %*d %*d "
+ "%*s %s %ld", &index, End, &when);
+ } while (!feof(fpHist) && index != game);
+
+ if (feof(fpHist)) {
+ pprintf(p, "There is no history game %d for %s.\n", game,
+ parray[p1].name);
+ fclose(fpHist);
+ return NULL;
+ }
+
+ fclose(fpHist);
+
+ msnprintf(fileName, sizeof fileName, "%s/%ld/%ld", hist_dir,
+ (when % 100), when);
+ return (&fileName[0]);
}
PRIVATE void