shithub: choc

Download patch

ref: ac228b3486155a0b4859b885f336769426237761
parent: 40e600b9f4aa8d57ababa3ede02a4e32f56f7c42
parent: 400f9d1930205d350af857cdd1a70f9b0d9ad484
author: Simon Howard <[email protected]>
date: Mon Jan 20 13:16:52 EST 2020

Merge pull request #1243 from chocolate-doom/statdump

improvements to the statdump implementation

--- a/src/doom/statdump.c
+++ b/src/doom/statdump.c
@@ -60,7 +60,7 @@
  * how to format the level name.  Unfortunately, in some cases it is
  * impossible to determine whether this is Doom 1 or Doom 2. */
 
-static void DiscoverGamemode(wbstartstruct_t *stats, int num_stats)
+static void DiscoverGamemode(const wbstartstruct_t *stats, int num_stats)
 {
     int partime;
     int level;
@@ -115,7 +115,7 @@
 
 /* Returns the number of players active in the given stats buffer. */
 
-static int GetNumPlayers(wbstartstruct_t *stats)
+static int GetNumPlayers(const wbstartstruct_t *stats)
 {
     int i;
     int num_players = 0;
@@ -157,10 +157,10 @@
 
 /* Display statistics for a single player. */
 
-static void PrintPlayerStats(FILE *stream, wbstartstruct_t *stats,
+static void PrintPlayerStats(FILE *stream, const wbstartstruct_t *stats,
         int player_num)
 {
-    wbplayerstruct_t *player = &stats->plyr[player_num];
+    const wbplayerstruct_t *player = &stats->plyr[player_num];
 
     fprintf(stream, "Player %i (%s):\n", player_num + 1,
             player_colors[player_num]);
@@ -186,7 +186,7 @@
 
 /* Frags table for multiplayer games. */
 
-static void PrintFragsTable(FILE *stream, wbstartstruct_t *stats)
+static void PrintFragsTable(FILE *stream, const wbstartstruct_t *stats)
 {
     int x, y;
 
@@ -266,7 +266,7 @@
 
 /* Print details of a statistics buffer to the given file. */
 
-static void PrintStats(FILE *stream, wbstartstruct_t *stats)
+static void PrintStats(FILE *stream, const wbstartstruct_t *stats)
 {
     short leveltime, partime;
     int i;
@@ -296,7 +296,7 @@
     fprintf(stream, "\n");
 }
 
-void StatCopy(wbstartstruct_t *stats)
+void StatCopy(const wbstartstruct_t *stats)
 {
     if (M_ParmExists("-statdump") && num_captured_stats < MAX_CAPTURES)
     {
@@ -339,7 +339,7 @@
         }
         else
         {
-            dumpfile = NULL;
+            dumpfile = stdout;
         }
 
         for (i = 0; i < num_captured_stats; ++i)
@@ -347,7 +347,7 @@
             PrintStats(dumpfile, &captured_stats[i]);
         }
 
-        if (dumpfile != NULL)
+        if (dumpfile != stdout)
         {
             fclose(dumpfile);
         }
--- a/src/doom/statdump.h
+++ b/src/doom/statdump.h
@@ -17,7 +17,7 @@
 #ifndef DOOM_STATDUMP_H
 #define DOOM_STATDUMP_H
 
-void StatCopy(wbstartstruct_t *stats);
+void StatCopy(const wbstartstruct_t *stats);
 void StatDump(void);
 
 #endif /* #ifndef DOOM_STATDUMP_H */