Date:	Friday June 21, 2002 @ 1:18
Author:	cameron

Update of /home/netrek/cvsroot/Vanilla/tools
In directory swashbuckler.real-time.com:/var/tmp/cvs-serv28377/tools

Modified Files:
	README trimscores.c 
Log Message:
fix trimscores documentation

****************************************

Index: Vanilla/tools/README
diff -u Vanilla/tools/README:1.1 Vanilla/tools/README:1.2
--- Vanilla/tools/README:1.1	Wed Nov 11 20:44:54 1998
+++ Vanilla/tools/README	Fri Jun 21 01:18:31 2002
@@ -39,13 +39,9 @@
   planets - List all planets with some general info about them.
   trimscores - takes the output of "scores A", and trims away players which
 	       no longer seem to be active.  You may specify 1 numerical
-	       argument, which represents how "nice" the program should be
+	       argument, which represents how "harsh" the program should be
 	       when deciding which characters to throw away.  The default is
-	       10.  I use 5 myself.  At 5, it throws away once played
-	       characters after about 50 days of inactivity, and for a 
-	       Captain with 40 hours of play time, it will wait until the 
-	       character has been inactive for over 200 days before throwing
-	       him away.  Output is a list of deleted characters.
+	       10.  Output is a list of deleted characters.
   showgalaxy - a curses (termcap) tool to watch the galaxy.  Good for checking
 	       in on the game over a modem.  Commands are 'm' for message,
 	       'z' for zoom (followed by player number), 'P' for planet
Index: Vanilla/tools/trimscores.c
diff -u Vanilla/tools/trimscores.c:1.5 Vanilla/tools/trimscores.c:1.6
--- Vanilla/tools/trimscores.c:1.5	Wed May 29 17:34:38 2002
+++ Vanilla/tools/trimscores.c	Fri Jun 21 01:18:31 2002
@@ -2,7 +2,7 @@
  *  Kevin P. Smith      12/05/88
  *
  *  Takes the output of scores A and generates the player file.
- *  (Also creates the .GLOBAL file)
+ *  (Also creates the .GLOBAL file, depending on #define's)
  *  This program reads stdin for its data.
  */
 
@@ -54,14 +54,14 @@
 
 #ifdef LTD_STATS
 
-    printf("trimscores: This program does not work with LTD_STATS\n");
+    fprintf(stderr, "trimscores: This program does not work with LTD_STATS\n");
     exit(1);
 
 #else
 
     int fd;
     struct player j;
-    int i;
+    int count, kept;
     char buf[MAXBUFFER];
     int harsh=10;	/* How strict we will be with player trimming */
     const LONG currenttime = time (NULL);
@@ -72,7 +72,8 @@
     }
     if (argc>2) usage();
     getpath();
-    fprintf(stderr,"Warning:  If you do not know how to use this program, break it now!\n");
+    fprintf(stderr,"Warning: if you do not know how to use this program,\n");
+    fprintf(stderr,"         you're about to lose the player database\n");
     status=(struct status *) malloc(sizeof(struct status));
     scanf("%10ld %10d %10d %10d %10d %10lf\n", 
 	&status->time, 
@@ -85,8 +86,8 @@
 #ifdef DOGLOBAL
     fd = open(Global, O_WRONLY|O_CREAT|O_TRUNC, 0600);
     if (fd < 0) {
-	printf("Cannot open the global file!\n");
-	exit(0);
+        fprintf(stderr, "Cannot open the global file!\n");
+        exit(0);
     }
     write(fd, (char *) status, sizeof(struct status));
     close(fd);
@@ -94,10 +95,12 @@
 
     fd = open(PlayerFile, O_WRONLY|O_CREAT|O_TRUNC, 0644);
     if (fd < 0) {
-	printf("Cannot open player file\n");
+        fprintf(stderr,"Cannot open player file\n");
+    } else {
+        fprintf(stderr,"Player database truncated, now reading input\n");
     }
 
-    i=0;
+    count=0;
     while (fgets(buf, MAXBUFFER, stdin)) {
 	if (strlen(buf) > 0) buf[strlen(buf)-1] = '\0';
 	trimblanks2(buf+16);
@@ -138,7 +141,7 @@
 	/* This formula reads:
 	 * If (deadtime - (10 + rank^2 + playtime/2.4)*n days > 0, nuke him.
 	 */
-	if (i!=0 && harsh<100 && ((currenttime - play_entry.stats.st_lastlogin - 864000*harsh) - 
+	if (count!=0 && harsh<100 && ((currenttime - play_entry.stats.st_lastlogin - 864000*harsh) - 
 	    play_entry.stats.st_rank * play_entry.stats.st_rank * harsh * 86400 -
 	    (play_entry.stats.st_tticks + play_entry.stats.st_ticks + 
 	     play_entry.stats.st_sbticks) * harsh > 0)) {
@@ -158,12 +161,15 @@
 	}
 	if (fd>=0) {
 	    write(fd, (char *) &play_entry, sizeof(struct statentry));
+	    kept++;
 	}
-	i++;
+	count++;
     }
     if (fd>=0) {
 	close(fd);
     }
+    fprintf(stderr,"Read %d records from input\n", count);
+    fprintf(stderr,"Wrote %d records to new player database\n", kept);
 
 #endif /* LTD_STATS */
 
@@ -172,14 +178,16 @@
 
 void usage(void)
 {
-    printf("Usage: trimscores n < scoredb\n");
-    printf("This program takes input of the form generated by the 'scores A'\n");
-    printf(" command.  It then recreates the database, throwing away characters\n");
-    printf(" which haven't been used recently.  The n tells it how nice to be\n");
-    printf(" when determining who to throw away.  The default n is 10.\n");
-    printf(" Any character destroyed must have not played for the last n*10 days\n");
-    printf(" and then some consideration is given to how valued he is likely to be.\n");
-    printf("It also outputs a quick description of the characters who were\n");
-    printf(" nuked.\n");
+    printf("Usage: trimscores [n] < scores > dropped\n\
+\n\
+Takes input of the form generated by the 'scores A' command.  But do\n\
+not run it at the same time as 'scores A', because is writes to the\n\
+input files by 'scores'.\n\
+\n\
+It then recreates the database (.players), throwing away characters\n\
+which haven't been used recently.  The n tells it how harsh to be when\n\
+determining who to throw away.  The default n is 10.\n\
+\n\
+For characters dropped, a summary line is written to standard output.\n");
     exit(0);
 }