Groups.ini can contain spaces around commas in values.
This includes Permissions, Inherits and Commands. Also fixed an unlikely but possible crash with group colors.
This commit is contained in:
parent
b090547c17
commit
c2c1639af8
@ -69,47 +69,51 @@ cGroupManager::cGroupManager()
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int NumKeys = IniFile.GetNumKeys();
|
unsigned int NumKeys = IniFile.GetNumKeys();
|
||||||
for( unsigned int i = 0; i < NumKeys; i++ )
|
for (size_t i = 0; i < NumKeys; i++)
|
||||||
{
|
{
|
||||||
std::string KeyName = IniFile.GetKeyName( i );
|
std::string KeyName = IniFile.GetKeyName( i );
|
||||||
cGroup* Group = GetGroup( KeyName.c_str() );
|
cGroup* Group = GetGroup( KeyName.c_str() );
|
||||||
|
|
||||||
LOGD("Loading group: %s", KeyName.c_str() );
|
LOGD("Loading group: %s", KeyName.c_str() );
|
||||||
|
|
||||||
Group->SetName( KeyName );
|
Group->SetName(KeyName);
|
||||||
char Color = IniFile.GetValue( KeyName, "Color", "-" )[0];
|
AString Color = IniFile.GetValue(KeyName, "Color", "-");
|
||||||
if( Color != '-' )
|
if ((Color != "-") && (Color.length() >= 1))
|
||||||
Group->SetColor( cChatColor::Color + Color );
|
{
|
||||||
|
Group->SetColor(cChatColor::Color + Color[0]);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Group->SetColor( cChatColor::White );
|
|
||||||
|
|
||||||
AString Commands = IniFile.GetValue( KeyName, "Commands", "" );
|
|
||||||
if( Commands.size() > 0 )
|
|
||||||
{
|
{
|
||||||
AStringVector Split = StringSplit( Commands, "," );
|
Group->SetColor(cChatColor::White);
|
||||||
for( unsigned int i = 0; i < Split.size(); i++)
|
}
|
||||||
|
|
||||||
|
AString Commands = IniFile.GetValue(KeyName, "Commands", "");
|
||||||
|
if (!Commands.empty())
|
||||||
|
{
|
||||||
|
AStringVector Split = StringSplitAndTrim(Commands, ",");
|
||||||
|
for (size_t i = 0; i < Split.size(); i++)
|
||||||
{
|
{
|
||||||
Group->AddCommand( Split[i] );
|
Group->AddCommand(Split[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AString Permissions = IniFile.GetValue( KeyName, "Permissions", "" );
|
AString Permissions = IniFile.GetValue(KeyName, "Permissions", "");
|
||||||
if( Permissions.size() > 0 )
|
if (!Permissions.empty())
|
||||||
{
|
{
|
||||||
AStringVector Split = StringSplit( Permissions, "," );
|
AStringVector Split = StringSplitAndTrim(Permissions, ",");
|
||||||
for( unsigned int i = 0; i < Split.size(); i++)
|
for (size_t i = 0; i < Split.size(); i++)
|
||||||
{
|
{
|
||||||
Group->AddPermission( Split[i] );
|
Group->AddPermission(Split[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Groups = IniFile.GetValue( KeyName, "Inherits", "" );
|
std::string Groups = IniFile.GetValue(KeyName, "Inherits", "");
|
||||||
if( Groups.size() > 0 )
|
if (!Groups.empty())
|
||||||
{
|
{
|
||||||
AStringVector Split = StringSplit( Groups, "," );
|
AStringVector Split = StringSplitAndTrim(Groups, ",");
|
||||||
for( unsigned int i = 0; i < Split.size(); i++)
|
for (size_t i = 0; i < Split.size(); i++)
|
||||||
{
|
{
|
||||||
Group->InheritFrom( GetGroup( Split[i].c_str() ) );
|
Group->InheritFrom(GetGroup(Split[i].c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user