From 9e17e0bc2f1af717f39d364ba26ef3a308842e17 Mon Sep 17 00:00:00 2001
From: Samual Lenks <samual@xonotic.org>
Date: Sun, 9 Sep 2012 13:11:12 -0400
Subject: [PATCH] Argh I hate FTEQCC... Fix the bug and recommit from the
 revert (which was WRONG)

---
 qcsrc/server/g_world.qc     |  4 ++--
 qcsrc/server/playerstats.qc | 10 ++++------
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc
index 4b5bc74ad..224f6ce25 100644
--- a/qcsrc/server/g_world.qc
+++ b/qcsrc/server/g_world.qc
@@ -639,6 +639,8 @@ void spawnfunc_worldspawn (void)
 
 	Map_MarkAsRecent(mapname);
 
+	PlayerStats_Init(); // we need this to be initiated before InitGameplayMode
+
 	precache_model ("null"); // we need this one before InitGameplayMode
 	InitGameplayMode();
 	readlevelcvars();
@@ -912,8 +914,6 @@ void spawnfunc_worldspawn (void)
 		cvar_set("sv_curl_serverpackages", substring(s, 1, -1));
 	}
 
-	PlayerStats_Init();
-
 	// MOD AUTHORS: change this, and possibly remove a few of the blocks below to ignore certain changes
 	modname = "Xonotic";
 	// physics/balance/config changes that count as mod
diff --git a/qcsrc/server/playerstats.qc b/qcsrc/server/playerstats.qc
index a63f59403..c94a5f22a 100644
--- a/qcsrc/server/playerstats.qc
+++ b/qcsrc/server/playerstats.qc
@@ -5,7 +5,7 @@ string events_last;
 .float playerstats_addedglobalinfo;
 .string playerstats_id;
 
-void PlayerStats_Init()
+void PlayerStats_Init() // initiated before InitGameplayMode so that scores are added properly
 {
 	string uri;
 	playerstats_db = -1;
@@ -236,7 +236,7 @@ void PlayerStats_ready(entity fh, entity pass, float status)
 	switch(status)
 	{
 		case URL_READY_CANWRITE:
-			url_fputs(fh, "V 3\n");
+			url_fputs(fh, "V 4\n");
 #ifdef WATERMARK
 			url_fputs(fh, sprintf("R %s\n", WATERMARK()));
 #endif
@@ -387,10 +387,8 @@ void PlayerStats_EndMatch(float finished)
 	{
 		//PlayerStats_Accuracy(p); // stats are already written with PlayerStats_AddGlobalInfo(entity), don't double them up.
 		
-		if(g_arena || g_lms || g_ca)
-			if(p.alivetime <= 0) { continue; }
-		else
-			if(p.classname != "player") { continue; }
+		if((g_arena || g_lms || g_ca) && (p.alivetime <= 0)) { continue; }
+		else if(p.classname != "player") { continue; }
 			
 		PlayerScore_PlayerStats(p);
 		PlayerStats_Event(p, PLAYERSTATS_SCOREBOARD_VALID, 1);
-- 
2.39.5