summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-02-21 14:53:46 +0100
committerHowaner <franzi.moos@googlemail.com>2014-02-21 14:53:46 +0100
commit21febaf4b342aecd5d797b1e2017591fde208388 (patch)
treebeaf6b0b623a08052932351f64fb9d0924dd6d4d
parentBad UTF-8 o.O (diff)
downloadcuberite-21febaf4b342aecd5d797b1e2017591fde208388.tar
cuberite-21febaf4b342aecd5d797b1e2017591fde208388.tar.gz
cuberite-21febaf4b342aecd5d797b1e2017591fde208388.tar.bz2
cuberite-21febaf4b342aecd5d797b1e2017591fde208388.tar.lz
cuberite-21febaf4b342aecd5d797b1e2017591fde208388.tar.xz
cuberite-21febaf4b342aecd5d797b1e2017591fde208388.tar.zst
cuberite-21febaf4b342aecd5d797b1e2017591fde208388.zip
-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;
}