예제 #1
0
파일: Player.cpp 프로젝트: Kortak/MCServer
void cPlayer::LoadPermissionsFromDisk()
{
	m_Groups.clear();
	m_Permissions.clear();

	cIniFile IniFile;
	if (IniFile.ReadFile("users.ini"))
	{
		AString Groups = IniFile.GetValueSet(GetName(), "Groups", "Default");
		AStringVector Split = StringSplitAndTrim(Groups, ",");

		for (AStringVector::const_iterator itr = Split.begin(), end = Split.end(); itr != end; ++itr)
		{
			if (!cRoot::Get()->GetGroupManager()->ExistsGroup(*itr))
			{
				LOGWARNING("The group %s for player %s was not found!", itr->c_str(), GetName().c_str());
			}
			AddToGroup(*itr);
		}

		AString Color = IniFile.GetValue(GetName(), "Color", "-");
		if (!Color.empty())
		{
			m_Color = Color[0];
		}
	}
	else
	{
		cGroupManager::GenerateDefaultUsersIni(IniFile);
		IniFile.AddValue("Groups", GetName(), "Default");
		AddToGroup("Default");
	}
	IniFile.WriteFile("users.ini");
	ResolvePermissions();
}
예제 #2
0
void cPlayer::LoadPermissionsFromDisk()
{
    m_Groups.clear();
    m_Permissions.clear();

    cIniFile IniFile;
    if (IniFile.ReadFile("users.ini"))
    {
        std::string Groups = IniFile.GetValue(m_PlayerName, "Groups", "");
        if (!Groups.empty())
        {
            AStringVector Split = StringSplit( Groups, "," );
            for( unsigned int i = 0; i < Split.size(); i++ )
            {
                AddToGroup( Split[i].c_str() );
            }
        }
        else
        {
            AddToGroup("Default");
        }

        m_Color = IniFile.GetValue(m_PlayerName, "Color", "-")[0];
    }
    else
    {
        LOGWARN("Failed to read the users.ini file. The player will be added only to the Default group.");
        AddToGroup("Default");
    }
    ResolvePermissions();
}
예제 #3
0
파일: Player.cpp 프로젝트: Kortak/MCServer
void cPlayer::AddToGroup( const AString & a_GroupName )
{
	cGroup* Group = cRoot::Get()->GetGroupManager()->GetGroup( a_GroupName );
	m_Groups.push_back( Group );
	LOGD("Added %s to group %s", GetName().c_str(), a_GroupName.c_str() );
	ResolveGroups();
	ResolvePermissions();
}
예제 #4
0
파일: Player.cpp 프로젝트: Kortak/MCServer
void cPlayer::RemoveFromGroup( const AString & a_GroupName )
{
	bool bRemoved = false;
	for( GroupList::iterator itr = m_Groups.begin(); itr != m_Groups.end(); ++itr )
	{
		if( (*itr)->GetName().compare(a_GroupName ) == 0 )
		{
			m_Groups.erase( itr );
			bRemoved = true;
			break;
		}
	}

	if( bRemoved )
	{
		LOGD("Removed %s from group %s", GetName().c_str(), a_GroupName.c_str() );
		ResolveGroups();
		ResolvePermissions();
	}
	else
	{
		LOGWARN("Tried to remove %s from group %s but was not in that group", GetName().c_str(), a_GroupName.c_str() );
	}
}