summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-02-28 15:31:20 +0100
committermadmaxoft <github@xoft.cz>2014-02-28 15:31:20 +0100
commit35def963f06dd46823300aebf09af0009189328b (patch)
treefc0d265c181ccd5025e790b23db0f760eaa85232
parentMerge pull request #709 from Howaner/GlobalFixes (diff)
downloadcuberite-35def963f06dd46823300aebf09af0009189328b.tar
cuberite-35def963f06dd46823300aebf09af0009189328b.tar.gz
cuberite-35def963f06dd46823300aebf09af0009189328b.tar.bz2
cuberite-35def963f06dd46823300aebf09af0009189328b.tar.lz
cuberite-35def963f06dd46823300aebf09af0009189328b.tar.xz
cuberite-35def963f06dd46823300aebf09af0009189328b.tar.zst
cuberite-35def963f06dd46823300aebf09af0009189328b.zip
-rw-r--r--src/Entities/Player.cpp18
-rw-r--r--src/GroupManager.cpp21
-rw-r--r--src/GroupManager.h3
3 files changed, 30 insertions, 12 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index e0f0b9222..f419ee09c 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1529,14 +1529,14 @@ void cPlayer::LoadPermissionsFromDisk()
std::string Groups = IniFile.GetValue(m_PlayerName, "Groups", "");
if (!Groups.empty())
{
- AStringVector Split = StringSplit( Groups, "," );
- for( unsigned int i = 0; i < Split.size(); i++ )
+ AStringVector Split = StringSplitAndTrim(Groups, ",");
+ for (AStringVector::const_iterator itr = Split.begin(), end = Split.end(); itr != end; ++itr)
{
- if (!cRoot::Get()->GetGroupManager()->ExistsGroup(Split[i]))
+ if (!cRoot::Get()->GetGroupManager()->ExistsGroup(*itr))
{
- LOGWARNING("The group %s for player %s was not found!", Split[i].c_str(), m_PlayerName.c_str());
+ LOGWARNING("The group %s for player %s was not found!", itr->c_str(), m_PlayerName.c_str());
}
- AddToGroup(Split[i].c_str());
+ AddToGroup(*itr);
}
}
else
@@ -1544,11 +1544,15 @@ void cPlayer::LoadPermissionsFromDisk()
AddToGroup("Default");
}
- m_Color = IniFile.GetValue(m_PlayerName, "Color", "-")[0];
+ AString Color = IniFile.GetValue(m_PlayerName, "Color", "-");
+ if (!Color.empty())
+ {
+ m_Color = Color[0];
+ }
}
else
{
- cRoot::Get()->GetGroupManager()->CheckUsers();
+ cGroupManager::GenerateDefaultUsersIni(IniFile);
AddToGroup("Default");
}
ResolvePermissions();
diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp
index 5125e7586..33b601e82 100644
--- a/src/GroupManager.cpp
+++ b/src/GroupManager.cpp
@@ -55,16 +55,27 @@ cGroupManager::cGroupManager()
+void cGroupManager::GenerateDefaultUsersIni(cIniFile & a_IniFile)
+{
+ LOGWARN("Regenerating users.ini, all users will be reset");
+ a_IniFile.AddHeaderComment(" This file stores the players' groups.");
+ a_IniFile.AddHeaderComment(" The format is:");
+ a_IniFile.AddHeaderComment(" [PlayerName]");
+ a_IniFile.AddHeaderComment(" Groups = GroupName1, GroupName2, ...");
+
+ a_IniFile.WriteFile("users.ini");
+}
+
+
+
+
+
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");
+ GenerateDefaultUsersIni(IniFile);
return;
}
diff --git a/src/GroupManager.h b/src/GroupManager.h
index 377a54c98..9e1689a76 100644
--- a/src/GroupManager.h
+++ b/src/GroupManager.h
@@ -19,6 +19,9 @@ public:
void LoadGroups(void);
void CheckUsers(void);
+ /** Writes the default header to the specified ini file, and saves it as "users.ini". */
+ static void GenerateDefaultUsersIni(cIniFile & a_IniFile);
+
private:
friend class cRoot;
cGroupManager();