Add 'Group not found', when the Server load the users.ini and add auto generate from users.ini
This commit is contained in:
parent
337c4e5cd4
commit
21febaf4b3
@ -1529,7 +1529,11 @@ void cPlayer::LoadPermissionsFromDisk()
|
|||||||
AStringVector Split = StringSplit( Groups, "," );
|
AStringVector Split = StringSplit( Groups, "," );
|
||||||
for( unsigned int i = 0; i < Split.size(); i++ )
|
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
|
else
|
||||||
|
@ -46,6 +46,7 @@ cGroupManager::cGroupManager()
|
|||||||
LOGD("-- Loading Groups --");
|
LOGD("-- Loading Groups --");
|
||||||
|
|
||||||
LoadGroups();
|
LoadGroups();
|
||||||
|
CheckUsers();
|
||||||
|
|
||||||
LOGD("-- Groups Successfully Loaded --");
|
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()
|
void cGroupManager::LoadGroups()
|
||||||
{
|
{
|
||||||
cIniFile IniFile;
|
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 )
|
cGroup* cGroupManager::GetGroup( const AString & a_Name )
|
||||||
{
|
{
|
||||||
GroupMap::iterator itr = m_pState->Groups.find( a_Name );
|
GroupMap::iterator itr = m_pState->Groups.find( a_Name );
|
||||||
|
@ -14,8 +14,10 @@ class cGroup;
|
|||||||
class cGroupManager
|
class cGroupManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
bool ExistsGroup(const AString & a_Name);
|
||||||
cGroup * GetGroup(const AString & a_Name);
|
cGroup * GetGroup(const AString & a_Name);
|
||||||
void LoadGroups(void);
|
void LoadGroups(void);
|
||||||
|
void CheckUsers(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class cRoot;
|
friend class cRoot;
|
||||||
|
@ -194,7 +194,7 @@ void cRoot::Start(void)
|
|||||||
#if !defined(ANDROID_NDK)
|
#if !defined(ANDROID_NDK)
|
||||||
LOGD("Starting InputThread...");
|
LOGD("Starting InputThread...");
|
||||||
m_InputThread = new cThread( InputThread, this, "cRoot::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<EFBFBD>t stop the server from other threads than the input thread
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
long long finishmseconds = Time.GetNowTime();
|
long long finishmseconds = Time.GetNowTime();
|
||||||
@ -536,7 +536,9 @@ void cRoot::SaveAllChunks(void)
|
|||||||
|
|
||||||
void cRoot::ReloadGroups(void)
|
void cRoot::ReloadGroups(void)
|
||||||
{
|
{
|
||||||
|
LOG("Reload groups ...");
|
||||||
m_GroupManager->LoadGroups();
|
m_GroupManager->LoadGroups();
|
||||||
|
m_GroupManager->CheckUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -460,16 +460,20 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac
|
|||||||
{
|
{
|
||||||
cPluginManager::Get()->ReloadPlugins();
|
cPluginManager::Get()->ReloadPlugins();
|
||||||
cRoot::Get()->ReloadGroups();
|
cRoot::Get()->ReloadGroups();
|
||||||
|
a_Output.Finished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (split[0] == "reloadplugins")
|
if (split[0] == "reloadplugins")
|
||||||
{
|
{
|
||||||
cPluginManager::Get()->ReloadPlugins();
|
cPluginManager::Get()->ReloadPlugins();
|
||||||
|
a_Output.Finished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (split[0] == "reloadgroups")
|
if (split[0] == "reloadgroups")
|
||||||
{
|
{
|
||||||
cRoot::Get()->ReloadGroups();
|
cRoot::Get()->ReloadGroups();
|
||||||
|
a_Output.Out("Groups reloaded!");
|
||||||
|
a_Output.Finished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user