summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-04-25 22:32:13 +0200
committerMattes D <github@xoft.cz>2015-04-25 22:32:13 +0200
commit0de768b56dd4fb8eb89c3ebe4051e2a0681ccd7b (patch)
tree3a675c7945da7c96f9e4629b2e795027a88e8bc8 /src/Entities/Player.cpp
parentMerge pull request #1896 from mc-server/FindAndDoWithPlayerRace (diff)
parentcPlayer now checks restrictions. (diff)
downloadcuberite-0de768b56dd4fb8eb89c3ebe4051e2a0681ccd7b.tar
cuberite-0de768b56dd4fb8eb89c3ebe4051e2a0681ccd7b.tar.gz
cuberite-0de768b56dd4fb8eb89c3ebe4051e2a0681ccd7b.tar.bz2
cuberite-0de768b56dd4fb8eb89c3ebe4051e2a0681ccd7b.tar.lz
cuberite-0de768b56dd4fb8eb89c3ebe4051e2a0681ccd7b.tar.xz
cuberite-0de768b56dd4fb8eb89c3ebe4051e2a0681ccd7b.tar.zst
cuberite-0de768b56dd4fb8eb89c3ebe4051e2a0681ccd7b.zip
Diffstat (limited to 'src/Entities/Player.cpp')
-rw-r--r--src/Entities/Player.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 2549a8481..7f625f5d4 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1414,14 +1414,23 @@ bool cPlayer::HasPermission(const AString & a_Permission)
AStringVector Split = StringSplit(a_Permission, ".");
+ // Iterate over all restrictions; if any matches, then return failure:
+ for (auto & Restriction: m_SplitRestrictions)
+ {
+ if (PermissionMatches(Split, Restriction))
+ {
+ return false;
+ }
+ } // for Restriction - m_SplitRestrictions[]
+
// Iterate over all granted permissions; if any matches, then return success:
- for (AStringVectorVector::const_iterator itr = m_SplitPermissions.begin(), end = m_SplitPermissions.end(); itr != end; ++itr)
+ for (auto & Permission: m_SplitPermissions)
{
- if (PermissionMatches(Split, *itr))
+ if (PermissionMatches(Split, Permission))
{
return true;
}
- } // for itr - m_SplitPermissions[]
+ } // for Permission - m_SplitPermissions[]
// No granted permission matches
return false;
@@ -2169,15 +2178,24 @@ void cPlayer::LoadRank(void)
RankMgr->UpdatePlayerName(m_UUID, m_PlayerName);
}
m_Permissions = RankMgr->GetPlayerPermissions(m_UUID);
+ m_Restrictions = RankMgr->GetPlayerRestrictions(m_UUID);
RankMgr->GetRankVisuals(m_Rank, m_MsgPrefix, m_MsgSuffix, m_MsgNameColorCode);
// Break up the individual permissions on each dot, into m_SplitPermissions:
m_SplitPermissions.clear();
m_SplitPermissions.reserve(m_Permissions.size());
- for (AStringVector::const_iterator itr = m_Permissions.begin(), end = m_Permissions.end(); itr != end; ++itr)
+ for (auto & Permission: m_Permissions)
+ {
+ m_SplitPermissions.push_back(StringSplit(Permission, "."));
+ } // for Permission - m_Permissions[]
+
+ // Break up the individual restrictions on each dot, into m_SplitRestrictions:
+ m_SplitRestrictions.clear();
+ m_SplitRestrictions.reserve(m_Restrictions.size());
+ for (auto & Restriction: m_Restrictions)
{
- m_SplitPermissions.push_back(StringSplit(*itr, "."));
- } // for itr - m_Permissions[]
+ m_SplitRestrictions.push_back(StringSplit(Restriction, "."));
+ } // for itr - m_Restrictions[]
}