- New statistics
authorunc0rr
Thu, 24 Apr 2008 20:53:35 +0000
changeset 869 daddcd31ef34
parent 868 4884bce5e5eb
child 870 dd418d9c18c5
- New statistics - Fixes for stats
QTfrontend/hwform.cpp
hedgewars.kdevelop
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uMisc.pas
hedgewars/uStats.pas
--- a/QTfrontend/hwform.cpp	Thu Apr 24 19:55:10 2008 +0000
+++ b/QTfrontend/hwform.cpp	Thu Apr 24 20:53:35 2008 +0000
@@ -578,6 +578,13 @@
 			AddStatText(message);
 			break;
 		}
+		case 'k' : {
+			int i = info.indexOf(' ');
+			QString message = QLabel::tr("<p>The best shot award was won by <b>%1</b> with <b>%2</b> kills.</p>")
+					.arg(info.mid(i + 1), info.left(i));
+			AddStatText(message);
+			break;
+		}
 		case 'K' : {
 			QString message = QLabel::tr("<p>A total of <b>%1</b> Hedgehog(s) were killed during this round.</p>").arg(info);
 			AddStatText(message);
--- a/hedgewars.kdevelop	Thu Apr 24 19:55:10 2008 +0000
+++ b/hedgewars.kdevelop	Thu Apr 24 20:53:35 2008 +0000
@@ -18,20 +18,20 @@
     <projectname>hedgewars</projectname>
     <projectdirectory>.</projectdirectory>
     <absoluteprojectpath>false</absoluteprojectpath>
-    <description/>
+    <description></description>
     <versioncontrol>kdevsubversion</versioncontrol>
-    <defaultencoding/>
+    <defaultencoding></defaultencoding>
   </general>
   <kdevcustomproject>
     <run>
       <directoryradio>executable</directoryradio>
       <customdirectory>/</customdirectory>
-      <mainprogram>bin/hedgewars</mainprogram>
-      <programargs/>
+      <mainprogram></mainprogram>
+      <programargs></programargs>
       <terminal>false</terminal>
       <autocompile>true</autocompile>
       <envvars/>
-      <globaldebugarguments/>
+      <globaldebugarguments></globaldebugarguments>
       <globalcwd>/usr/home/unC0Rr/Sources/Hedgewars/Hedgewars-GNA</globalcwd>
       <useglobalprogram>false</useglobalprogram>
       <autoinstall>false</autoinstall>
@@ -98,16 +98,16 @@
     </general>
     <build>
       <buildtool>make</buildtool>
-      <builddir/>
+      <builddir></builddir>
     </build>
     <make>
       <abortonerror>true</abortonerror>
-      <numberofjobs>1</numberofjobs>
+      <numberofjobs>4</numberofjobs>
       <prio>0</prio>
       <dontact>false</dontact>
-      <makebin/>
-      <defaulttarget/>
-      <makeoptions/>
+      <makebin></makebin>
+      <defaulttarget></defaulttarget>
+      <makeoptions></makeoptions>
       <selectedenvironment>default</selectedenvironment>
       <environments>
         <default/>
@@ -115,9 +115,9 @@
     </make>
     <other>
       <prio>0</prio>
-      <otherbin/>
-      <defaulttarget/>
-      <otheroptions/>
+      <otherbin></otherbin>
+      <defaulttarget></defaulttarget>
+      <otheroptions></otheroptions>
       <selectedenvironment>default</selectedenvironment>
       <environments>
         <default/>
@@ -126,12 +126,12 @@
   </kdevcustomproject>
   <kdevdebugger>
     <general>
-      <dbgshell/>
+      <dbgshell></dbgshell>
       <programargs/>
-      <gdbpath/>
-      <configGdbScript/>
-      <runShellScript/>
-      <runGdbScript/>
+      <gdbpath></gdbpath>
+      <configGdbScript></configGdbScript>
+      <runShellScript></runShellScript>
+      <runGdbScript></runGdbScript>
       <breakonloadinglibs>true</breakonloadinglibs>
       <separatetty>false</separatetty>
       <floatingtoolbar>false</floatingtoolbar>
@@ -237,7 +237,7 @@
       <includeTypedefs>false</includeTypedefs>
     </codecompletion>
     <creategettersetter>
-      <prefixGet/>
+      <prefixGet></prefixGet>
       <prefixSet>set</prefixSet>
       <prefixVariable>m_,_</prefixVariable>
       <parameterName>theValue</parameterName>
@@ -256,7 +256,7 @@
       <hidenonlocation>false</hidenonlocation>
     </groups>
     <tree>
-      <hidepatterns></hidepatterns>
+      <hidepatterns/>
       <hidenonprojectfiles>true</hidenonprojectfiles>
       <showvcsfields>false</showvcsfields>
     </tree>
@@ -269,9 +269,9 @@
   </cppsupportpart>
   <kdevdocumentation>
     <projectdoc>
-      <docsystem/>
-      <docurl/>
-      <usermanualurl/>
+      <docsystem></docsystem>
+      <docurl></docurl>
+      <usermanualurl></usermanualurl>
     </projectdoc>
   </kdevdocumentation>
   <ctagspart>
--- a/hedgewars/uConsts.pas	Thu Apr 24 19:55:10 2008 +0000
+++ b/hedgewars/uConsts.pas	Thu Apr 24 20:53:35 2008 +0000
@@ -74,7 +74,7 @@
 
      TCapGroup  = (capgrpGameState, capgrpAmmoinfo, capgrpNetSay, capgrpVolume);
 
-     TStatInfoType = (siGameResult, siMaxStepDamage, siKilledHHs);
+     TStatInfoType = (siGameResult, siMaxStepDamage, siMaxStepKills, siKilledHHs);
 
      THHFont    = record
                   Handle: PTTF_Font;
--- a/hedgewars/uGears.pas	Thu Apr 24 19:55:10 2008 +0000
+++ b/hedgewars/uGears.pas	Thu Apr 24 20:53:35 2008 +0000
@@ -384,8 +384,8 @@
 
 procedure ProcessGears;
 const delay: LongWord = 0;
-      step: (stDelay, stChDmg, stChWin, stTurnReact,
-             stAfterDelay, stSpawn, stNTurn) = stDelay;
+      step: (stDelay, stChDmg, stTurnReact,
+             stAfterDelay, stChWin, stSpawn, stNTurn) = stDelay;
 var Gear, t: PGear;
 begin
 PrvInactive:= AllInactive;
@@ -410,7 +410,6 @@
                     inc(step)
                  end;
         stChDmg: if CheckNoDamage then inc(step) else step:= stDelay;
-        stChWin: if not CheckForWin then inc(step) else step:= stDelay;
     stTurnReact: begin
                  if not isInMultiShoot then
                     begin
@@ -428,12 +427,12 @@
                  if delay = 0 then
                     inc(step)
                  end;
+        stChWin: if not CheckForWin then inc(step) else step:= stDelay;
         stSpawn: begin
                  if not isInMultiShoot then SpawnBoxOfSmth;
                  inc(step)
                  end;
         stNTurn: begin
-                 //AwareOfExplosion(0, 0, 0);
                  if isInMultiShoot then isInMultiShoot:= false
                     else begin
                     ParseCommand('/nextturn', true);
@@ -451,7 +450,7 @@
    ((GameTicks and $FFFF) = $FFFF) then
    begin
    SendIPCTimeInc;
-   inc(hiTicks) // we do not recieve a message for it
+   inc(hiTicks) // we do not recieve a message for this
    end;
 
 inc(GameTicks)
--- a/hedgewars/uMisc.pas	Thu Apr 24 19:55:10 2008 +0000
+++ b/hedgewars/uMisc.pas	Thu Apr 24 20:53:35 2008 +0000
@@ -234,7 +234,7 @@
 end;
 
 procedure SendStat(sit: TStatInfoType; s: shortstring);
-const stc: array [TStatInfoType] of char = 'rDK';
+const stc: array [TStatInfoType] of char = 'rDkK';
 begin
 SendIPC('i' + stc[sit] + s)
 end;
@@ -290,7 +290,7 @@
 if (surf^.format^.BytesPerPixel = 3) then mode:= GL_RGB else
 if (surf^.format^.BytesPerPixel = 4) then mode:= GL_RGBA else
    begin
-   TryDo(false, 'Surface2Tex: BytePerPixel not in [3, 4]', true);
+   TryDo(false, 'Surface2Tex: BytesPerPixel not in [3, 4]', true);
    Surface2Tex^.id:= 0;
    exit
    end;
--- a/hedgewars/uStats.pas	Thu Apr 24 19:55:10 2008 +0000
+++ b/hedgewars/uStats.pas	Thu Apr 24 20:53:35 2008 +0000
@@ -24,9 +24,11 @@
                    DamageRecv,
                    DamageGiven: Longword;
                    StepDamageRecv,
-                   StepDamageGiven: Longword;
+                   StepDamageGiven,
+                   StepKills: Longword;
                    MaxStepDamageRecv,
-                   MaxStepDamageGiven: Longword;
+                   MaxStepDamageGiven,
+                   MaxStepKills: Longword;
                    FinishedTurns: Longword;
                    end;
 
@@ -55,6 +57,7 @@
 
 if Gear^.Health <= Gear^.Damage then
 	begin
+	inc(CurrentHedgehog^.stats.StepKills);
 	inc(Kills);
 	inc(KillsTotal);
 	if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(KillsClan);
@@ -67,6 +70,7 @@
 
 procedure TurnReaction;
 var Gear: PGear;
+    i, t: LongInt;
 begin
 inc(CurrentHedgehog^.stats.FinishedTurns);
 
@@ -94,21 +98,19 @@
 else if AmmoDamagingUsed then
 	PlaySound(sndMissed, false);
 
-Gear:= GearsList;
-while Gear <> nil do
-  begin
-  if Gear^.Kind = gtHedgehog then
-    with PHedgehog(Gear^.Hedgehog)^.stats do
-      begin
-      inc(DamageRecv, StepDamageRecv);
-      inc(DamageGiven, StepDamageGiven);
-      if StepDamageRecv > MaxStepDamageRecv then MaxStepDamageRecv:= StepDamageRecv;
-      if StepDamageGiven > MaxStepDamageGiven then MaxStepDamageGiven:= StepDamageGiven;
-      StepDamageRecv:= 0;
-      StepDamageGiven:= 0
-      end;
-  Gear:= Gear^.NextGear
-  end;
+for t:= 0 to Pred(TeamsCount) do
+	with TeamsArray[t]^ do
+		for i:= 0 to cMaxHHIndex do
+			with Hedgehogs[i].stats do
+				begin
+				inc(DamageRecv, StepDamageRecv);
+				inc(DamageGiven, StepDamageGiven);
+				if StepDamageRecv > MaxStepDamageRecv then MaxStepDamageRecv:= StepDamageRecv;
+				if StepDamageGiven > MaxStepDamageGiven then MaxStepDamageGiven:= StepDamageGiven;
+				if StepKills > MaxStepKills then MaxStepKills:= StepKills;
+				StepDamageRecv:= 0;
+				StepDamageGiven:= 0
+				end;
 
 Kills:= 0;
 KillsClan:= 0;
@@ -126,21 +128,39 @@
 
 procedure SendStats;
 var i, t: LongInt;
-    msd: Longword; msdhh: PHedgehog;
+    msd, msk: Longword; msdhh, mskhh: PHedgehog;
+    mskcnt: Longword;
 begin
 msd:= 0; msdhh:= nil;
+msk:= 0; mskhh:= nil;
+mskcnt:= 0;
+
 for t:= 0 to Pred(TeamsCount) do
-   with TeamsArray[t]^ do
-      begin
-      for i:= 0 to cMaxHHIndex do
-          if Hedgehogs[i].stats.StepDamageGiven > msd then
-             begin
-             msdhh:= @Hedgehogs[i];
-             msd:= Hedgehogs[i].stats.StepDamageGiven
-             end;
-      end;
-if msdhh <> nil then SendStat(siMaxStepDamage, inttostr(msd) + ' ' +
-                                               msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')');
+	with TeamsArray[t]^ do
+		begin
+		for i:= 0 to cMaxHHIndex do
+			begin
+			if Hedgehogs[i].stats.MaxStepDamageGiven > msd then
+				begin
+				msdhh:= @Hedgehogs[i];
+				msd:= Hedgehogs[i].stats.MaxStepDamageGiven
+				end;
+			if Hedgehogs[i].stats.MaxStepKills >= msk then
+				if Hedgehogs[i].stats.MaxStepKills = msk then
+					inc(mskcnt)
+				else
+					begin
+					mskcnt:= 1;
+					mskhh:= @Hedgehogs[i];
+					msk:= Hedgehogs[i].stats.MaxStepKills
+					end;
+			end
+		end;
+if msdhh <> nil then
+	SendStat(siMaxStepDamage, inttostr(msd) + ' ' + msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')');
+if mskcnt = 1 then
+	SendStat(siMaxStepKills, inttostr(msk) + ' ' + mskhh^.Name + ' (' + mskhh^.Team^.TeamName + ')');
+
 if KilledHHs > 0 then SendStat(siKilledHHs, inttostr(KilledHHs));
 end;