summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-04-25 19:40:44 +0200
committerMattes D <github@xoft.cz>2015-04-25 21:05:43 +0200
commitb5998873e42eaec90267010557edd47f65af1463 (patch)
treeb2c31a9e263552f40e91bf2a5bc66a13778f7d20 /src/Entities/Player.cpp
parentAdded player restrictions to the DB and API. (diff)
downloadcuberite-b5998873e42eaec90267010557edd47f65af1463.tar
cuberite-b5998873e42eaec90267010557edd47f65af1463.tar.gz
cuberite-b5998873e42eaec90267010557edd47f65af1463.tar.bz2
cuberite-b5998873e42eaec90267010557edd47f65af1463.tar.lz
cuberite-b5998873e42eaec90267010557edd47f65af1463.tar.xz
cuberite-b5998873e42eaec90267010557edd47f65af1463.tar.zst
cuberite-b5998873e42eaec90267010557edd47f65af1463.zip
Diffstat (limited to '')
-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[]
}