summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Entities/Player.cpp6
-rw-r--r--src/GroupManager.cpp47
-rw-r--r--src/GroupManager.h2
-rw-r--r--src/Root.cpp4
-rw-r--r--src/Server.cpp4
5 files changed, 61 insertions, 2 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 70ddb3c98..7a3aaf568 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1529,7 +1529,11 @@ void cPlayer::LoadPermissionsFromDisk()
AStringVector Split = StringSplit( Groups, "," );
for( unsigned int i = 0; i < Split.size(); i++ )
{
- AddToGroup( Split[i].c_str() );
+ if (!cRoot::Get()->GetGroupManager()->ExistsGroup(Split[i]))
+ {
+ LOGWARNING("The group %s for player %s was not found!", Split[i].c_str(), m_PlayerName.c_str());
+ }
+ AddToGroup(Split[i].c_str());
}
}
else
diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp
index 723b86f94..5125e7586 100644
--- a/src/GroupManager.cpp
+++ b/src/GroupManager.cpp
@@ -46,6 +46,7 @@ cGroupManager::cGroupManager()
LOGD("-- Loading Groups --");
LoadGroups();
+ CheckUsers();
LOGD("-- Groups Successfully Loaded --");
}
@@ -54,6 +55,42 @@ cGroupManager::cGroupManager()
+void cGroupManager::CheckUsers(void)
+{
+ cIniFile IniFile;
+ if (!IniFile.ReadFile("users.ini"))
+ {
+ LOGWARN("Regenerating users.ini, all users will be reset");
+ IniFile.AddHeaderComment(" This is the file in which the group the player belongs to is stored");
+ IniFile.AddHeaderComment(" The format is: [PlayerName] | Groups=GroupName");
+
+ IniFile.WriteFile("users.ini");
+ return;
+ }
+
+ unsigned int NumKeys = IniFile.GetNumKeys();
+ for (size_t i = 0; i < NumKeys; i++)
+ {
+ AString Player = IniFile.GetKeyName( i );
+ AString Groups = IniFile.GetValue(Player, "Groups", "");
+ if (!Groups.empty())
+ {
+ AStringVector Split = StringSplit( Groups, "," );
+ for( unsigned int i = 0; i < Split.size(); i++ )
+ {
+ if (!ExistsGroup(Split[i]))
+ {
+ LOGWARNING("The group %s for player %s was not found!", Split[i].c_str(), Player.c_str());
+ }
+ }
+ }
+ }
+}
+
+
+
+
+
void cGroupManager::LoadGroups()
{
cIniFile IniFile;
@@ -137,6 +174,16 @@ void cGroupManager::LoadGroups()
+bool cGroupManager::ExistsGroup( const AString & a_Name )
+{
+ GroupMap::iterator itr = m_pState->Groups.find( a_Name );
+ return ( itr != m_pState->Groups.end() );
+}
+
+
+
+
+
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 02a58fe4e..377a54c98 100644
--- a/src/GroupManager.h
+++ b/src/GroupManager.h
@@ -14,8 +14,10 @@ class cGroup;
class cGroupManager
{
public:
+ bool ExistsGroup(const AString & a_Name);
cGroup * GetGroup(const AString & a_Name);
void LoadGroups(void);
+ void CheckUsers(void);
private:
friend class cRoot;
diff --git a/src/Root.cpp b/src/Root.cpp
index 206255916..8680c0082 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -194,7 +194,7 @@ void cRoot::Start(void)
#if !defined(ANDROID_NDK)
LOGD("Starting InputThread...");
m_InputThread = new cThread( InputThread, this, "cRoot::InputThread" );
- m_InputThread->Start( false ); // We should NOT wait? Otherwise we can´t stop the server from other threads than the input thread
+ m_InputThread->Start( false ); // We should NOT wait? Otherwise we can�t stop the server from other threads than the input thread
#endif
long long finishmseconds = Time.GetNowTime();
@@ -536,7 +536,9 @@ void cRoot::SaveAllChunks(void)
void cRoot::ReloadGroups(void)
{
+ LOG("Reload groups ...");
m_GroupManager->LoadGroups();
+ m_GroupManager->CheckUsers();
}
diff --git a/src/Server.cpp b/src/Server.cpp
index ab1458da4..4842c1782 100644
--- a/src/Server.cpp
+++ b/src/Server.cpp
@@ -460,16 +460,20 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac
{
cPluginManager::Get()->ReloadPlugins();
cRoot::Get()->ReloadGroups();
+ a_Output.Finished();
return;
}
if (split[0] == "reloadplugins")
{
cPluginManager::Get()->ReloadPlugins();
+ a_Output.Finished();
return;
}
if (split[0] == "reloadgroups")
{
cRoot::Get()->ReloadGroups();
+ a_Output.Out("Groups reloaded!");
+ a_Output.Finished();
return;
}