summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
authorandrew <xdotftw@gmail.com>2014-05-11 13:57:06 +0200
committerandrew <xdotftw@gmail.com>2014-05-11 13:57:06 +0200
commitc7c3724a3ee0e7a77fe9924ad25c36b6ec8fdd14 (patch)
treee26a406f738328936caf2a0b361ff5745510d113 /src/Entities/Player.cpp
parentMerge pull request #992 from mc-server/coverity_fixes (diff)
downloadcuberite-c7c3724a3ee0e7a77fe9924ad25c36b6ec8fdd14.tar
cuberite-c7c3724a3ee0e7a77fe9924ad25c36b6ec8fdd14.tar.gz
cuberite-c7c3724a3ee0e7a77fe9924ad25c36b6ec8fdd14.tar.bz2
cuberite-c7c3724a3ee0e7a77fe9924ad25c36b6ec8fdd14.tar.lz
cuberite-c7c3724a3ee0e7a77fe9924ad25c36b6ec8fdd14.tar.xz
cuberite-c7c3724a3ee0e7a77fe9924ad25c36b6ec8fdd14.tar.zst
cuberite-c7c3724a3ee0e7a77fe9924ad25c36b6ec8fdd14.zip
Diffstat (limited to 'src/Entities/Player.cpp')
-rw-r--r--src/Entities/Player.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 6ac11c270..a42fe89cf 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -16,6 +16,8 @@
#include "../Items/ItemHandler.h"
#include "../Vector3.h"
+#include "../WorldStorage/StatSerializer.h"
+
#include "inifile/iniFile.h"
#include "json/json.h"
@@ -131,6 +133,15 @@ cPlayer::~cPlayer(void)
SaveToDisk();
+#if 0
+ /* Save statistics. */
+ cStatSerializer StatSerializer(m_World->GetName(), m_PlayerName, &m_Stats);
+ if (!StatSerializer.Save())
+ {
+ LOGERROR("Could not save stats for player %s", m_PlayerName.c_str());
+ }
+#endif
+
m_World->RemovePlayer( this );
m_ClientHandle = NULL;
@@ -871,9 +882,13 @@ void cPlayer::KilledBy(cEntity * a_Killer)
}
else if (a_Killer->IsPlayer())
{
- GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), ((cPlayer *)a_Killer)->GetName().c_str()));
+ cPlayer* Killer = (cPlayer*)a_Killer;
- m_World->GetScoreBoard().AddPlayerScore(((cPlayer *)a_Killer)->GetName(), cObjective::otPlayerKillCount, 1);
+ GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), Killer->GetName().c_str()));
+
+ Killer->GetStatManager().AddValue(statPlayerKills);
+
+ m_World->GetScoreBoard().AddPlayerScore(Killer->GetName(), cObjective::otPlayerKillCount, 1);
}
else
{
@@ -883,6 +898,8 @@ void cPlayer::KilledBy(cEntity * a_Killer)
GetWorld()->BroadcastChatDeath(Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str()));
}
+ m_Stats.AddValue(statDeaths);
+
m_World->GetScoreBoard().AddPlayerScore(GetName(), cObjective::otDeathCount, 1);
}