summaryrefslogtreecommitdiffstats
path: root/src/GroupManager.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-02-02 22:43:39 +0100
committermadmaxoft <github@xoft.cz>2014-02-03 10:39:09 +0100
commitc2c1639af8f9db9bdd0f720c0e748c98d2835b5c (patch)
tree72f96a4a4a3d7a4c0fefe4d888007efd7e2054f5 /src/GroupManager.cpp
parentMerge pull request #602 from mc-server/improvementsandfixes (diff)
downloadcuberite-c2c1639af8f9db9bdd0f720c0e748c98d2835b5c.tar
cuberite-c2c1639af8f9db9bdd0f720c0e748c98d2835b5c.tar.gz
cuberite-c2c1639af8f9db9bdd0f720c0e748c98d2835b5c.tar.bz2
cuberite-c2c1639af8f9db9bdd0f720c0e748c98d2835b5c.tar.lz
cuberite-c2c1639af8f9db9bdd0f720c0e748c98d2835b5c.tar.xz
cuberite-c2c1639af8f9db9bdd0f720c0e748c98d2835b5c.tar.zst
cuberite-c2c1639af8f9db9bdd0f720c0e748c98d2835b5c.zip
Diffstat (limited to 'src/GroupManager.cpp')
-rw-r--r--src/GroupManager.cpp46
1 files changed, 25 insertions, 21 deletions
diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp
index 497f98c93..d5567d91e 100644
--- a/src/GroupManager.cpp
+++ b/src/GroupManager.cpp
@@ -69,47 +69,51 @@ cGroupManager::cGroupManager()
}
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 );
cGroup* Group = GetGroup( KeyName.c_str() );
LOGD("Loading group: %s", KeyName.c_str() );
- Group->SetName( KeyName );
- char Color = IniFile.GetValue( KeyName, "Color", "-" )[0];
- if( Color != '-' )
- Group->SetColor( cChatColor::Color + Color );
+ Group->SetName(KeyName);
+ AString Color = IniFile.GetValue(KeyName, "Color", "-");
+ if ((Color != "-") && (Color.length() >= 1))
+ {
+ Group->SetColor(cChatColor::Color + Color[0]);
+ }
else
- Group->SetColor( cChatColor::White );
+ {
+ Group->SetColor(cChatColor::White);
+ }
- AString Commands = IniFile.GetValue( KeyName, "Commands", "" );
- if( Commands.size() > 0 )
+ AString Commands = IniFile.GetValue(KeyName, "Commands", "");
+ if (!Commands.empty())
{
- AStringVector Split = StringSplit( Commands, "," );
- for( unsigned int i = 0; i < Split.size(); i++)
+ 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", "" );
- if( Permissions.size() > 0 )
+ AString Permissions = IniFile.GetValue(KeyName, "Permissions", "");
+ if (!Permissions.empty())
{
- AStringVector Split = StringSplit( Permissions, "," );
- for( unsigned int i = 0; i < Split.size(); i++)
+ AStringVector Split = StringSplitAndTrim(Permissions, ",");
+ for (size_t i = 0; i < Split.size(); i++)
{
- Group->AddPermission( Split[i] );
+ Group->AddPermission(Split[i]);
}
}
- std::string Groups = IniFile.GetValue( KeyName, "Inherits", "" );
- if( Groups.size() > 0 )
+ std::string Groups = IniFile.GetValue(KeyName, "Inherits", "");
+ if (!Groups.empty())
{
- AStringVector Split = StringSplit( Groups, "," );
- for( unsigned int i = 0; i < Split.size(); i++)
+ AStringVector Split = StringSplitAndTrim(Groups, ",");
+ for (size_t i = 0; i < Split.size(); i++)
{
- Group->InheritFrom( GetGroup( Split[i].c_str() ) );
+ Group->InheritFrom(GetGroup(Split[i].c_str()));
}
}
}