Vanilla Netrek Server Development Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[VANILLA-L:1169] Questionable INL stat message hack.




Those of you that recall the summer games might remember that I stated I
had stats working.  This wasn't exactly true.  I thought I could recover
the stats in entirety by extracting the player's game time from the message
logs.  Unfortunately, this information isn't normally stored anywhere in
the server's output - So, I hacked in a small function to death.c that
would send a message containing a player's "vitals" just before he dies.
This method has some problems - namely, there isn't a good way to make sure
the very last ship a player has is collected in the stats.  (This can be
significant when a player in SB lives a very long time - if his last ship
isn't collected, then the stats will be way off.)

I think the summer game would of went off ok, but something went horribly
wrong.  (I believe I ran the server with an old source tree.  :-/ )


Note: I really wouldn't apply this patch - its pretty useless by itself.


**************************  Cut here  **************************

--- death.c	Tue Dec 22 12:01:12 1998
+++ /eng/home/koconnor/Server/ntserv/death.c	Fri Jul 31 16:39:21 1998
@@ -5,13 +5,60 @@
 
 #include <stdio.h>
 #include <signal.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include "defs.h"
 #include "struct.h"
 #include "data.h"
 
 extern int living;
+
+#ifdef ARMYTRACK
+inline void
+messageStats(void)
+{
+    /* HACK!
+     * Output a message containing the player's stats.
+     */
+
+    char addr_str[9] = "WRN->\0\0\0\0";
+    struct stats *s = &me->p_stats;
+
+    static struct {
+	int ticks, kills, losses, bombed, planets;
+	int sb_ticks, sb_kills, sb_losses;
+    } oldvals = {0, 0, 0, 0, 0,
+		 0, 0, 0};
+    int first;
+
+/*    first = oldvals.ticks == 0;*/
+    first = 0;
+
+    strncpy(&addr_str[5], me->p_mapchars, 3);
+
+    oldvals.ticks = s->st_tticks-oldvals.ticks;
+    oldvals.kills = s->st_tkills-oldvals.kills;
+    oldvals.losses = s->st_tlosses-oldvals.losses;
+    oldvals.bombed = s->st_tarmsbomb-oldvals.bombed;
+    oldvals.planets = s->st_tplanets-oldvals.planets;
+    oldvals.sb_ticks = s->st_sbticks-oldvals.sb_ticks;
+    oldvals.sb_kills = s->st_sbkills-oldvals.sb_kills;
+    oldvals.sb_losses = s->st_sblosses-oldvals.sb_losses;
+
+    if (first) {
+	pmessage(0, 0, addr_str,
+		 "t:%d k:%d l:%d b:%d p:%d st:%d sk:%d sl:%d",
+		 0, 0, 0, 0, 0, 0, 0, 0);
+    } else {
+	pmessage(0, MALL, addr_str,
+		 "t:%d k:%d l:%d b:%d p:%d st:%d sk:%d sl:%d",
+		 oldvals.ticks, oldvals.kills, oldvals.losses, oldvals.bombed,
+		 oldvals.planets, oldvals.sb_ticks, oldvals.sb_kills,
+		 oldvals.sb_losses);
+    }
+}
+#endif
+
 
 death()
 {
@@ -19,10 +68,15 @@
 
     me->p_status = POUTFIT;             /* Stop the ghost buster */
 
+    me->p_flags &= ~(PFWAR|PFREFITTING
 #ifdef SB_TRANSWARP
-    me->p_flags &= ~PFTWARP;
+		     |PFTWARP
 #endif
+		     );
 
+#ifdef ARMYTRACK
+    messageStats();
+#endif
 
     switch(me->p_whydead) {
     case KTORP:
@@ -53,9 +107,6 @@
 	break;
     }
 
-    me->p_flags &= ~(PFWAR|PFREFITTING);
-
-
     /* First we check for promotions: */
     if (me->p_stats.st_rank < NUMRANKS-1) {
         float ratingTotals;
@@ -67,12 +118,15 @@
          * (i.e. their 'DI' rating is about rank.hours * rank.ratings ad they
          *  have insufficient time yet).
          */
-        if (defenseRating(me) >= ranks[mystats->st_rank + 1].defense &&
-            ((mystats->st_tticks/36000.0 >= ranks[mystats->st_rank + 1].hours/hourratio &&
-             ratingTotals >= ranks[mystats->st_rank + 1].ratings) ||
-            (mystats->st_tticks/36000.0 < ranks[mystats->st_rank + 1].hours/hourratio &&
-             ratingTotals*(mystats->st_tticks/36000.0) >=
-             ranks[mystats->st_rank+1].hours/hourratio*ranks[mystats->st_rank+1].ratings))
+        if (defenseRating(me) >= ranks[mystats->st_rank + 1].defense
+	    && ((mystats->st_tticks/36000.0
+		 >= ranks[mystats->st_rank + 1].hours/hourratio
+		 && ratingTotals >= ranks[mystats->st_rank + 1].ratings)
+		|| (mystats->st_tticks/36000.0 
+		    < ranks[mystats->st_rank + 1].hours/hourratio
+		    && ratingTotals*(mystats->st_tticks/36000.0) >=
+		    ranks[mystats->st_rank+1].hours
+		    /hourratio*ranks[mystats->st_rank+1].ratings))
 ) {
             mystats->st_rank ++;
         } else if 
@@ -82,7 +136,8 @@
 	    ((defenseRating(me) >= ranks[mystats->st_rank].defense &&
 	      ratingTotals >= ranks[mystats->st_rank].ratings) && 
 	     ratingTotals*(mystats->st_tticks/36000.0) >= 
-	     ranks[mystats->st_rank+1].hours/hourratio*ranks[mystats->st_rank+1].ratings*2) {
+	     ranks[mystats->st_rank+1].hours/hourratio
+	     *ranks[mystats->st_rank+1].ratings*2) {
 	    mystats->st_rank ++;
 	} else if 
 	    /* We also promote if they belong down a rank, but have four
@@ -92,7 +147,8 @@
 	     (defenseRating(me) >= ranks[mystats->st_rank-1].defense &&
 	      ratingTotals >= ranks[mystats->st_rank-1].ratings) &&
 	     ratingTotals*(mystats->st_tticks/36000.0) >=
-	     ranks[mystats->st_rank+1].hours/hourratio*ranks[mystats->st_rank+1].ratings*4) {
+	     ranks[mystats->st_rank+1].hours/hourratio
+	     *ranks[mystats->st_rank+1].ratings*4) {
 	    mystats->st_rank++;
         } else if ( (mystats->st_rank) >=4 ) {
             /* We also promote if they belong down a rank, but have eight


-- 
 ------------------------------------------------------------------------
 | Kevin O'Connor                     "BTW, IMHO we need a FAQ for      |
 | koconnor@cse.buffalo.edu            'IMHO', 'FAQ', 'BTW', etc. !"    |
 ------------------------------------------------------------------------
+
++ Vanilla-l Mailing List ++
To unsubscribe: send "unsubscribe vanilla-l" to majordomo@real-time.com
For more information: http://archives.real-time.com