summaryrefslogtreecommitdiffstats
path: root/source/Player.cpp
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-10-18 23:54:56 +0200
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-10-18 23:54:56 +0200
commit2a197705ac8785e01a48fa1ac5893d3bb876fd0a (patch)
treed0168a1accaab2240dbf8f16880300a27baa7daf /source/Player.cpp
parentFixed a few bugs in fluid placement - fluid into other fluid, fluid into washable blocks. (diff)
downloadcuberite-2a197705ac8785e01a48fa1ac5893d3bb876fd0a.tar
cuberite-2a197705ac8785e01a48fa1ac5893d3bb876fd0a.tar.gz
cuberite-2a197705ac8785e01a48fa1ac5893d3bb876fd0a.tar.bz2
cuberite-2a197705ac8785e01a48fa1ac5893d3bb876fd0a.tar.lz
cuberite-2a197705ac8785e01a48fa1ac5893d3bb876fd0a.tar.xz
cuberite-2a197705ac8785e01a48fa1ac5893d3bb876fd0a.tar.zst
cuberite-2a197705ac8785e01a48fa1ac5893d3bb876fd0a.zip
Diffstat (limited to 'source/Player.cpp')
-rw-r--r--source/Player.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/source/Player.cpp b/source/Player.cpp
index 4ac71b25a..c7784c1b0 100644
--- a/source/Player.cpp
+++ b/source/Player.cpp
@@ -578,11 +578,11 @@ void cPlayer::SetVisible(bool a_bVisible)
-void cPlayer::AddToGroup( const char* a_GroupName )
+void cPlayer::AddToGroup( const AString & a_GroupName )
{
cGroup* Group = cRoot::Get()->GetGroupManager()->GetGroup( a_GroupName );
m_Groups.push_back( Group );
- LOGD("Added %s to group %s", m_PlayerName.c_str(), a_GroupName );
+ LOGD("Added %s to group %s", m_PlayerName.c_str(), a_GroupName.c_str() );
ResolveGroups();
ResolvePermissions();
}
@@ -591,7 +591,36 @@ void cPlayer::AddToGroup( const char* a_GroupName )
-bool cPlayer::CanUseCommand( const char* a_Command )
+void cPlayer::RemoveFromGroup( const AString & a_GroupName )
+{
+ bool bRemoved = false;
+ for( GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr )
+ {
+ if( (*itr)->GetName().compare(a_GroupName ) == 0 )
+ {
+ m_Groups.erase( itr );
+ bRemoved = true;
+ break;
+ }
+ }
+
+ if( bRemoved )
+ {
+ LOGD("Removed %s from group %s", m_PlayerName.c_str(), a_GroupName.c_str() );
+ ResolveGroups();
+ ResolvePermissions();
+ }
+ else
+ {
+ LOGWARN("Tried to remove %s from group %s but was not in that group", m_PlayerName.c_str(), a_GroupName.c_str() );
+ }
+}
+
+
+
+
+
+bool cPlayer::CanUseCommand( const AString & a_Command )
{
for( GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr )
{
@@ -604,7 +633,7 @@ bool cPlayer::CanUseCommand( const char* a_Command )
-bool cPlayer::HasPermission( const char* a_Permission )
+bool cPlayer::HasPermission( const AString & a_Permission )
{
AStringVector Split = StringSplit( a_Permission, "." );
PermissionMap Possibilities = m_ResolvedPermissions;
@@ -640,11 +669,11 @@ bool cPlayer::HasPermission( const char* a_Permission )
-bool cPlayer::IsInGroup( const char* a_Group )
+bool cPlayer::IsInGroup( const AString & a_Group )
{
for( GroupList::iterator itr = m_ResolvedGroups.begin(); itr != m_ResolvedGroups.end(); ++itr )
{
- if( strcmp( a_Group, (*itr)->GetName().c_str() ) == 0 )
+ if( a_Group.compare( (*itr)->GetName().c_str() ) == 0 )
return true;
}
return false;