summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-02-05 19:58:02 +0100
committerMattes D <github@xoft.cz>2014-02-05 19:58:02 +0100
commit694fa5d54188012a4fa727bbbe82ff92ca289d79 (patch)
treefcd2ccb8b83f34ff032fa35171e494e7bfd65b85 /src
parentMerge pull request #647 from worktycho/runMCServer (diff)
parentForgot extra lines. (diff)
downloadcuberite-694fa5d54188012a4fa727bbbe82ff92ca289d79.tar
cuberite-694fa5d54188012a4fa727bbbe82ff92ca289d79.tar.gz
cuberite-694fa5d54188012a4fa727bbbe82ff92ca289d79.tar.bz2
cuberite-694fa5d54188012a4fa727bbbe82ff92ca289d79.tar.lz
cuberite-694fa5d54188012a4fa727bbbe82ff92ca289d79.tar.xz
cuberite-694fa5d54188012a4fa727bbbe82ff92ca289d79.tar.zst
cuberite-694fa5d54188012a4fa727bbbe82ff92ca289d79.zip
Diffstat (limited to '')
-rw-r--r--src/Group.cpp31
-rw-r--r--src/Group.h24
-rw-r--r--src/GroupManager.cpp19
-rw-r--r--src/GroupManager.h1
-rw-r--r--src/Root.cpp9
-rw-r--r--src/Root.h3
6 files changed, 69 insertions, 18 deletions
diff --git a/src/Group.cpp b/src/Group.cpp
index 448d29d87..cc42c55a1 100644
--- a/src/Group.cpp
+++ b/src/Group.cpp
@@ -3,19 +3,34 @@
#include "Group.h"
-void cGroup::AddCommand( std::string a_Command )
+
+
+
+
+void cGroup::AddCommand( AString a_Command )
{
m_Commands[ a_Command ] = true;
}
-void cGroup::AddPermission( std::string a_Permission )
+
+
+
+
+void cGroup::AddPermission( AString a_Permission )
{
m_Permissions[ a_Permission ] = true;
}
-bool cGroup::HasCommand( std::string a_Command )
+
+
+
+
+bool cGroup::HasCommand( AString a_Command )
{
- if( m_Commands.find("*") != m_Commands.end() ) return true;
+ if( m_Commands.find("*") != m_Commands.end() )
+ {
+ return true;
+ }
CommandMap::iterator itr = m_Commands.find( a_Command );
if( itr != m_Commands.end() )
@@ -34,4 +49,12 @@ void cGroup::InheritFrom( cGroup* a_Group )
{
m_Inherits.remove( a_Group );
m_Inherits.push_back( a_Group );
+}
+
+
+
+
+void cGroup::ClearPermission()
+{
+ m_Permissions.clear();
} \ No newline at end of file
diff --git a/src/Group.h b/src/Group.h
index 65ee1a60a..3299aecbc 100644
--- a/src/Group.h
+++ b/src/Group.h
@@ -11,19 +11,21 @@ public: // tolua_export
cGroup() {}
~cGroup() {}
- void SetName( std::string a_Name ) { m_Name = a_Name; } // tolua_export
- const std::string & GetName() const { return m_Name; } // tolua_export
- void SetColor( std::string a_Color ) { m_Color = a_Color; } // tolua_export
- void AddCommand( std::string a_Command ); // tolua_export
- void AddPermission( std::string a_Permission ); // tolua_export
- void InheritFrom( cGroup* a_Group ); // tolua_export
+ void SetName( AString a_Name ) { m_Name = a_Name; } // tolua_export
+ const AString & GetName() const { return m_Name; } // tolua_export
+ void SetColor( AString a_Color ) { m_Color = a_Color; } // tolua_export
+ void AddCommand( AString a_Command ); // tolua_export
+ void AddPermission( AString a_Permission ); // tolua_export
+ void InheritFrom( cGroup* a_Group ); // tolua_export
- bool HasCommand( std::string a_Command ); // tolua_export
+ bool HasCommand( AString a_Command ); // tolua_export
- typedef std::map< std::string, bool > PermissionMap;
+ typedef std::map< AString, bool > PermissionMap;
const PermissionMap & GetPermissions() const { return m_Permissions; }
- typedef std::map< std::string, bool > CommandMap;
+ void ClearPermission(void);
+
+ typedef std::map< AString, bool > CommandMap;
const CommandMap & GetCommands() const { return m_Commands; }
const AString & GetColor() const { return m_Color; } // tolua_export
@@ -31,8 +33,8 @@ public: // tolua_export
typedef std::list< cGroup* > GroupList;
const GroupList & GetInherits() const { return m_Inherits; }
private:
- std::string m_Name;
- std::string m_Color;
+ AString m_Name;
+ AString m_Color;
PermissionMap m_Permissions;
CommandMap m_Commands;
diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp
index d5567d91e..723b86f94 100644
--- a/src/GroupManager.cpp
+++ b/src/GroupManager.cpp
@@ -44,6 +44,18 @@ cGroupManager::cGroupManager()
: m_pState( new sGroupManagerState )
{
LOGD("-- Loading Groups --");
+
+ LoadGroups();
+
+ LOGD("-- Groups Successfully Loaded --");
+}
+
+
+
+
+
+void cGroupManager::LoadGroups()
+{
cIniFile IniFile;
if (!IniFile.ReadFile("groups.ini"))
{
@@ -71,8 +83,10 @@ cGroupManager::cGroupManager()
unsigned int NumKeys = IniFile.GetNumKeys();
for (size_t i = 0; i < NumKeys; i++)
{
- std::string KeyName = IniFile.GetKeyName( i );
+ AString KeyName = IniFile.GetKeyName( i );
cGroup* Group = GetGroup( KeyName.c_str() );
+
+ Group->ClearPermission(); // Needed in case the groups are reloaded.
LOGD("Loading group: %s", KeyName.c_str() );
@@ -107,7 +121,7 @@ cGroupManager::cGroupManager()
}
}
- std::string Groups = IniFile.GetValue(KeyName, "Inherits", "");
+ AString Groups = IniFile.GetValue(KeyName, "Inherits", "");
if (!Groups.empty())
{
AStringVector Split = StringSplitAndTrim(Groups, ",");
@@ -117,7 +131,6 @@ cGroupManager::cGroupManager()
}
}
}
- LOGD("-- Groups Successfully Loaded --");
}
diff --git a/src/GroupManager.h b/src/GroupManager.h
index d911f976c..02a58fe4e 100644
--- a/src/GroupManager.h
+++ b/src/GroupManager.h
@@ -15,6 +15,7 @@ class cGroupManager
{
public:
cGroup * GetGroup(const AString & a_Name);
+ void LoadGroups(void);
private:
friend class cRoot;
diff --git a/src/Root.cpp b/src/Root.cpp
index 883bfe76e..5d1b2ebe2 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -536,6 +536,15 @@ void cRoot::SaveAllChunks(void)
+void cRoot::ReloadGroups(void)
+{
+ m_GroupManager->LoadGroups();
+}
+
+
+
+
+
void cRoot::BroadcastChat(const AString & a_Message)
{
for (WorldMap::iterator itr = m_WorldsByName.begin(), end = m_WorldsByName.end(); itr != end; ++itr)
diff --git a/src/Root.h b/src/Root.h
index c59afc810..71ee2e671 100644
--- a/src/Root.h
+++ b/src/Root.h
@@ -98,6 +98,9 @@ public:
/// Saves all chunks in all worlds
void SaveAllChunks(void); // tolua_export
+ /// Reloads all the groups
+ void ReloadGroups(void); // tolua_export
+
/// Sends a chat message to all connected clients (in all worlds)
void BroadcastChat(const AString & a_Message); // tolua_export