summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entities/Player.cpp')
-rw-r--r--src/Entities/Player.cpp46
1 files changed, 17 insertions, 29 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 2a62931ab..ccdd151f3 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -847,6 +847,8 @@ 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()));
+
+ m_World->GetScoreBoard().AddPlayerScore(((cPlayer *)a_Killer)->GetName(), cObjective::otPlayerKillCount, 1);
}
else
{
@@ -856,24 +858,7 @@ void cPlayer::KilledBy(cEntity * a_Killer)
GetWorld()->BroadcastChatDeath(Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str()));
}
- class cIncrementCounterCB
- : public cObjectiveCallback
- {
- AString m_Name;
- public:
- cIncrementCounterCB(const AString & a_Name) : m_Name(a_Name) {}
-
- virtual bool Item(cObjective * a_Objective) override
- {
- a_Objective->AddScore(m_Name, 1);
- return true;
- }
- } IncrementCounter (GetName());
-
- cScoreboard & Scoreboard = m_World->GetScoreBoard();
-
- // Update scoreboard objectives
- Scoreboard.ForEachObjectiveWith(cObjective::E_TYPE_DEATH_COUNT, IncrementCounter);
+ m_World->GetScoreBoard().AddPlayerScore(GetName(), cObjective::otDeathCount, 1);
}
@@ -1497,10 +1482,14 @@ void cPlayer::LoadPermissionsFromDisk()
std::string Groups = IniFile.GetValue(m_PlayerName, "Groups", "");
if (!Groups.empty())
{
- AStringVector Split = StringSplit( Groups, "," );
- for( unsigned int i = 0; i < Split.size(); i++ )
+ AStringVector Split = StringSplitAndTrim(Groups, ",");
+ for (AStringVector::const_iterator itr = Split.begin(), end = Split.end(); itr != end; ++itr)
{
- AddToGroup( Split[i].c_str() );
+ if (!cRoot::Get()->GetGroupManager()->ExistsGroup(*itr))
+ {
+ LOGWARNING("The group %s for player %s was not found!", itr->c_str(), m_PlayerName.c_str());
+ }
+ AddToGroup(*itr);
}
}
else
@@ -1508,16 +1497,15 @@ void cPlayer::LoadPermissionsFromDisk()
AddToGroup("Default");
}
- m_Color = IniFile.GetValue(m_PlayerName, "Color", "-")[0];
+ AString Color = IniFile.GetValue(m_PlayerName, "Color", "-");
+ if (!Color.empty())
+ {
+ m_Color = Color[0];
+ }
}
else
{
- LOGWARN("Regenerating users.ini, player %s will be added to the \"Default\" group", m_PlayerName.c_str());
- IniFile.AddHeaderComment(" This is the file in which the group the player belongs to is stored");
- IniFile.AddHeaderComment(" The format is: [PlayerName] | Groups=GroupName");
-
- IniFile.SetValue(m_PlayerName, "Groups", "Default");
- IniFile.WriteFile("users.ini");
+ cGroupManager::GenerateDefaultUsersIni(IniFile);
AddToGroup("Default");
}
ResolvePermissions();
@@ -1884,7 +1872,7 @@ void cPlayer::Detach()
{
for (int z = PosZ - 2; z <= (PosZ + 2); ++z)
{
- if (!g_BlockIsSolid[m_World->GetBlock(x, y, z)] && g_BlockIsSolid[m_World->GetBlock(x, y - 1, z)])
+ if (!cBlockInfo::IsSolid(m_World->GetBlock(x, y, z)) && cBlockInfo::IsSolid(m_World->GetBlock(x, y - 1, z)))
{
TeleportToCoords(x, y, z);
return;