]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_world.qc
Improve reliability by using total damage
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_world.qc
index 8f9578b6b88b77b703e415c9890d38c6cf6a09c3..12118a2ff9b974733b47d74c2a603f5ae64132c4 100644 (file)
@@ -619,7 +619,7 @@ void spawnfunc_worldspawn (void)
 
        Map_MarkAsRecent(mapname);
 
-       PlayerStats_Init(); // we need this to be initiated before InitGameplayMode
+       PlayerStats_GameReport_Init(); // we need this to be initiated before InitGameplayMode
 
        precache_model ("null"); // we need this one before InitGameplayMode
        InitGameplayMode();
@@ -755,6 +755,7 @@ void spawnfunc_worldspawn (void)
        addstat(STAT_WEAPON_CLIPLOAD, AS_INT, clip_load);
        addstat(STAT_WEAPON_CLIPSIZE, AS_INT, clip_size);
        addstat(STAT_LAST_PICKUP, AS_FLOAT, last_pickup);
+       addstat(STAT_HIT_TIME, AS_FLOAT, hit_time);
        addstat(STAT_DAMAGE_DEALT_TOTAL, AS_INT, damage_dealt_total);
        addstat(STAT_TYPEHIT_TIME, AS_FLOAT, typehit_time);
        addstat(STAT_LAYED_MINES, AS_INT, minelayer_mines);
@@ -1499,11 +1500,7 @@ void NextLevel()
        DumpStats(TRUE);
 
        // send statistics
-       entity e;
-       PlayerStats_EndMatch(1);
-       FOR_EACH_CLIENT(e)
-               PlayerStats_AddGlobalInfo(e);
-       PlayerStats_Shutdown();
+       PlayerStats_GameReport(TRUE);
        WeaponStats_Shutdown();
 
        Kill_Notification(NOTIF_ALL, world, MSG_CENTER, 0); // kill all centerprints now
@@ -2207,21 +2204,13 @@ void EndFrame()
        float altime;
        FOR_EACH_REALCLIENT(self)
        {
-               self.damage_dealt_total = 0;
-       
-               if(IS_SPEC(self))
+               entity e = IS_SPEC(self) ? self.enemy : self;
+               if(e.typehitsound)
+                       self.typehit_time = time;
+               else if(e.damage_dealt)
                {
-                       if(self.enemy.typehitsound)
-                               self.typehit_time = time;
-                       else if(self.enemy.damage_dealt)
-                               self.damage_dealt_total = ceil(self.enemy.damage_dealt);
-               }
-               else
-               {
-                       if(self.typehitsound)
-                               self.typehit_time = time;
-                       else if(self.damage_dealt)
-                               self.damage_dealt_total = ceil(self.damage_dealt);
+                       self.hit_time = time;
+                       self.damage_dealt_total += ceil(e.damage_dealt);
                }
        }
        altime = time + frametime * (1 + autocvar_g_antilag_nudge);
@@ -2309,8 +2298,6 @@ void RestoreGame()
 
 void Shutdown()
 {
-       entity e;
-
        gameover = 2;
 
        if(world_initialized > 0)
@@ -2319,10 +2306,8 @@ void Shutdown()
                print("Saving persistent data...\n");
                Ban_SaveBans();
 
-               PlayerStats_EndMatch(0);
-               FOR_EACH_CLIENT(e)
-                       PlayerStats_AddGlobalInfo(e);
-               PlayerStats_Shutdown();
+               // playerstats with unfinished match
+               PlayerStats_GameReport(FALSE);
 
                if(!cheatcount_total)
                {