]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
weapon profiling. output to a new format
authorRudolf Polzer <divverent@alientrap.org>
Sun, 23 Jan 2011 18:33:41 +0000 (19:33 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Sun, 23 Jan 2011 18:33:41 +0000 (19:33 +0100)
defaultXonotic.cfg
qcsrc/server/autocvars.qh
qcsrc/server/cl_player.qc

index d2e91235e657685c503975d60d8a68c82c28395e..d4bce3e6c0e88fa58031a1460f25fd538d2355e7 100644 (file)
@@ -1884,8 +1884,7 @@ set g_triggerimpulse_radial_multiplier 1 "trigger_impulse radial field multiplie
 seta g_ghost_items 1 "enable ghosted items (when between 0 and 1, overrides the alpha value)"
 seta g_ghost_items_color "-1 -1 -1" "color of ghosted items, 0 0 0 leaves the color unchanged"
 
-set sv_weaponstats_damagefile "" "when set to a file name, per-weapon damage stats get written to that file"
-set sv_weaponstats_killfile "" "when set to a file name, per-weapon kill stats get written to that file"
+set sv_weaponstats_file "" "when set to a file name, per-weapon stats get written to that file"
 
 seta cl_noantilag 0 "turn this on if you believe antilag is bad"
 
index e791e71440ad7e890abb8d57359f7760f1349525..26ea84446d768ac6c49ee89cb9edcaa8818a47b7 100644 (file)
@@ -1180,8 +1180,7 @@ float autocvar_sv_warsowbunny_airforwardaccel;
 float autocvar_sv_warsowbunny_backtosideratio;
 float autocvar_sv_warsowbunny_topspeed;
 float autocvar_sv_warsowbunny_turnaccel;
-string autocvar_sv_weaponstats_damagefile;
-string autocvar_sv_weaponstats_killfile;
+string autocvar_sv_weaponstats_file;
 float autocvar_sys_ticrate;
 float autocvar_teamplay_lockonrestart;
 float autocvar_teamplay_mode;
index 6853031f9217069da21d0bbeb077e8924fcbe39e..9570f6ab5dce132926ece193a6124a727127a2a4 100644 (file)
@@ -2,69 +2,53 @@ float weaponstats_buffer;
 
 void WeaponStats_Init()
 {
-       if(autocvar_sv_weaponstats_killfile != "" || autocvar_sv_weaponstats_damagefile != "")
+       if(autocvar_sv_weaponstats_file != "")
                weaponstats_buffer = buf_create();
        else
                weaponstats_buffer = -1;
 }
 
-#define WEAPONSTATS_GETINDEX(awep,vwep) ((vwep) + (awep) * (WEP_LAST - WEP_FIRST + 1) - (WEP_FIRST + WEP_FIRST * (WEP_LAST - WEP_FIRST + 1)))
+#define WEAPONSTATS_GETINDEX(awep,abot,vwep,vbot) (((vwep) + (awep) * (WEP_LAST - WEP_FIRST + 1) - (WEP_FIRST + WEP_FIRST * (WEP_LAST - WEP_FIRST + 1))) * 4 + (abot) * 2 + (vbot))
 
 void WeaponStats_Shutdown()
 {
-       float i, j, idx, f;
+       float i, j, ibot, jbot, idx;
        float fh;
+       vector v;
        string prefix;
        if(weaponstats_buffer < 0)
                return;
        prefix = strcat(autocvar_hostname, "\t", GetGametype(), "_", GetMapname(), "\t");
-       if(autocvar_sv_weaponstats_killfile != "")
+       if(autocvar_sv_weaponstats_file != "")
        {
-               fh = fopen(autocvar_sv_weaponstats_killfile, FILE_APPEND);
+               fh = fopen(autocvar_sv_weaponstats_file, FILE_APPEND);
                if(fh >= 0)
                {
-                       fputs(fh, "#begin killfile\n");
+                       fputs(fh, "#begin statsfile\n");
                        fputs(fh, strcat("#date ", strftime(TRUE, "%a %b %e %H:%M:%S %Z %Y"), "\n"));
                        fputs(fh, strcat("#config ", ftos(crc16(FALSE, cvar_changes)), "\n"));
-                       for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-                               for(j = WEP_FIRST; j <= WEP_LAST; ++j)
+                       for(i = WEP_FIRST; i <= WEP_LAST; ++i) for(ibot = 0; ibot <= 1; ++ibot)
+                               for(j = WEP_FIRST; j <= WEP_LAST; ++j) for(jbot = 0; jbot <= 1; ++jbot)
                                {
-                                       idx = WEAPONSTATS_GETINDEX(i, j);
-                                       f = stov(bufstr_get(weaponstats_buffer, idx)) * '0 1 0';
-                                       if(f != 0)
-                                               fputs(fh, strcat(prefix, ftos(i), "\t", ftos(j), "\t", ftos(f), "\n"));
-                               }
-                       fputs(fh, "#end\n\n");
-                       fclose(fh);
-                       print("Weapon kill stats written\n");
-               }
-       }
-       if(autocvar_sv_weaponstats_damagefile != "")
-       {
-               fh = fopen(autocvar_sv_weaponstats_damagefile, FILE_APPEND);
-               if(fh >= 0)
-               {
-                       fputs(fh, "#begin damagefile\n");
-                       fputs(fh, strcat("#date ", strftime(TRUE, "%a %b %e %H:%M:%S %Z %Y"), "\n"));
-                       fputs(fh, strcat("#config ", ftos(crc16(FALSE, cvar_changes)), "\n"));
-                       for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-                               for(j = WEP_FIRST; j <= WEP_LAST; ++j)
-                               {
-                                       idx = WEAPONSTATS_GETINDEX(i, j);
-                                       f = stov(bufstr_get(weaponstats_buffer, idx)) * '1 0 0';
-                                       if(f != 0)
-                                               fputs(fh, strcat(prefix, ftos(i), "\t", ftos(j), "\t", ftos(f), "\n"));
+                                       idx = WEAPONSTATS_GETINDEX(i, ibot, j, jbot);
+                                       v = stov(bufstr_get(weaponstats_buffer, idx));
+                                       if(v != '0 0 0')
+                                       {
+                                               //vector is: kills hits damage
+                                               fputs(fh, sprintf("%s%d %d\t%d %d\t", prefix, i, ibot, j, jbot));
+                                               fputs(fh, sprintf("%d %d %g\n", v_x, v_y, v_z));
+                                       }
                                }
                        fputs(fh, "#end\n\n");
                        fclose(fh);
-                       print("Weapon damage stats written\n");
+                       print("Weapon stats written\n");
                }
        }
        buf_del(weaponstats_buffer);
        weaponstats_buffer = -1;
 }
 
-void WeaponStats_LogItem(float awep, float vwep, vector item)
+void WeaponStats_LogItem(float awep, float abot, float vwep, float vbot, vector item)
 {
        float idx;
        if(weaponstats_buffer < 0)
@@ -73,18 +57,18 @@ void WeaponStats_LogItem(float awep, float vwep, vector item)
                return;
        if(awep > WEP_LAST || vwep > WEP_LAST)
                return;
-       idx = WEAPONSTATS_GETINDEX(awep,vwep);
+       idx = WEAPONSTATS_GETINDEX(awep,abot,vwep,vbot);
        bufstr_set(weaponstats_buffer, idx, vtos(stov(bufstr_get(weaponstats_buffer, idx)) + item));
 }
-void WeaponStats_LogDamage(float awep, float vwep, float damage)
+void WeaponStats_LogDamage(float awep, float abot, float vwep, float vbot, float damage)
 {
        if(damage < 0)
                error("negative damage?");
-       WeaponStats_LogItem(awep, vwep, '1 0 0' * damage);
+       WeaponStats_LogItem(awep, abot, vwep, vbot, '0 0 1' * damage + '0 1 0');
 }
-void WeaponStats_LogKill(float awep, float vwep)
+void WeaponStats_LogKill(float awep, float abot, float vwep, float vbot)
 {
-       WeaponStats_LogItem(awep, vwep, '0 1 0');
+       WeaponStats_LogItem(awep, abot, vwep, vbot, '1 0 0');
 }
 
 // changes by LordHavoc on 03/29/04 and 03/30/04 at Vermeulen's request
@@ -553,9 +537,13 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
        else
                self.pushltime = 0;
 
+       float abot, vbot;
+       abot = (clienttype(attacker) == CLIENTTYPE_BOT);
+       vbot = (clienttype(self) == CLIENTTYPE_BOT);
+
        valid_damage_for_weaponstats = 0;
-       if(clienttype(self) == CLIENTTYPE_REAL)
-       if(clienttype(attacker) == CLIENTTYPE_REAL)
+       if(vbot || clienttype(self) == CLIENTTYPE_REAL)
+       if(abot || clienttype(attacker) == CLIENTTYPE_REAL)
        if(self != attacker)
        if(!DEATH_ISSPECIAL(deathtype))
        if(IsDifferentTeam(self, attacker))
@@ -565,7 +553,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
        {
                dh = dh - max(self.health, 0);
                da = da - max(self.armorvalue, 0);
-               WeaponStats_LogDamage(DEATH_WEAPONOF(deathtype), self.weapon, dh + da);
+               WeaponStats_LogDamage(DEATH_WEAPONOF(deathtype), abot, self.weapon, vbot, dh + da);
        }
 
        if (self.health < 1)
@@ -580,7 +568,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
                }
 
                if(valid_damage_for_weaponstats)
-                       WeaponStats_LogKill(DEATH_WEAPONOF(deathtype), self.weapon);
+                       WeaponStats_LogKill(DEATH_WEAPONOF(deathtype), abot, self.weapon, vbot);
 
                if(sv_gentle < 1) // TODO make a "gentle" version?
                if(sound_allowed(MSG_BROADCAST, attacker))