summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Group.cpp31
-rw-r--r--src/Group.h24
-rw-r--r--src/GroupManager.cpp23
-rw-r--r--src/GroupManager.h1
-rw-r--r--src/Root.cpp9
-rw-r--r--src/Root.h3
6 files changed, 69 insertions, 22 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..99befa0ff 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,13 +131,8 @@ cGroupManager::cGroupManager()
}
}
}
- LOGD("-- Groups Successfully Loaded --");
}
-
-
-
-
cGroup* cGroupManager::GetGroup( const AString & a_Name )
{
GroupMap::iterator itr = m_pState->Groups.find( a_Name );
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