summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Bindings/AllToLua.pkg1
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/Entities/Player.cpp2
-rw-r--r--src/Group.cpp41
-rw-r--r--src/Group.h44
-rw-r--r--src/GroupManager.cpp227
-rw-r--r--src/GroupManager.h36
-rw-r--r--src/Root.cpp16
-rw-r--r--src/Root.h6
-rw-r--r--src/Server.cpp26
10 files changed, 8 insertions, 395 deletions
diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg
index 88faa9dfc..37e6aecd2 100644
--- a/src/Bindings/AllToLua.pkg
+++ b/src/Bindings/AllToLua.pkg
@@ -67,7 +67,6 @@ $cfile "../Root.h"
$cfile "../Cuboid.h"
$cfile "../BoundingBox.h"
$cfile "../Tracer.h"
-$cfile "../Group.h"
$cfile "../BlockArea.h"
$cfile "../Generating/ChunkDesc.h"
$cfile "../CraftingRecipes.h"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 738b53537..79baf317d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -33,8 +33,6 @@ SET (SRCS
FastRandom.cpp
FurnaceRecipe.cpp
Globals.cpp
- Group.cpp
- GroupManager.cpp
Inventory.cpp
Item.cpp
ItemGrid.cpp
@@ -98,8 +96,6 @@ SET (HDRS
ForEachChunkProvider.h
FurnaceRecipe.h
Globals.h
- Group.h
- GroupManager.h
Inventory.h
Item.h
ItemGrid.h
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 423ca3317..b6d6fc7b0 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -10,8 +10,6 @@
#include "../Bindings/PluginManager.h"
#include "../BlockEntities/BlockEntity.h"
#include "../BlockEntities/EnderChestEntity.h"
-#include "../GroupManager.h"
-#include "../Group.h"
#include "../Root.h"
#include "../OSSupport/Timer.h"
#include "../Chunk.h"
diff --git a/src/Group.cpp b/src/Group.cpp
deleted file mode 100644
index def585618..000000000
--- a/src/Group.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "Group.h"
-
-
-
-
-
-void cGroup::AddCommand( const AString & a_Command)
-{
- m_Commands[ a_Command ] = true;
-}
-
-
-
-
-
-void cGroup::AddPermission( const AString & a_Permission)
-{
- m_Permissions[ a_Permission ] = true;
-}
-
-
-
-
-
-void cGroup::InheritFrom( cGroup* a_Group)
-{
- m_Inherits.remove( a_Group);
- m_Inherits.push_back( a_Group);
-}
-
-
-
-
-
-void cGroup::ClearPermission()
-{
- m_Permissions.clear();
-}
diff --git a/src/Group.h b/src/Group.h
deleted file mode 100644
index 5816f8a06..000000000
--- a/src/Group.h
+++ /dev/null
@@ -1,44 +0,0 @@
-
-#pragma once
-
-
-
-
-
-// tolua_begin
-class cGroup
-{
-public:
- // tolua_end
- cGroup() {}
- ~cGroup() {}
-
- // tolua_begin
- void SetName( const AString & a_Name) { m_Name = a_Name; }
- const AString & GetName() const { return m_Name; }
- void SetColor( const AString & a_Color) { m_Color = a_Color; }
- void AddCommand( const AString & a_Command);
- void AddPermission( const AString & a_Permission);
- void InheritFrom( cGroup* a_Group);
- // tolua_end
-
- typedef std::map< AString, bool > PermissionMap;
- const PermissionMap & GetPermissions() const { return m_Permissions; }
-
- void ClearPermission(void);
-
- typedef std::map< AString, bool > CommandMap;
- const CommandMap & GetCommands() const { return m_Commands; }
-
- const AString & GetColor() const { return m_Color; } // tolua_export
-
- typedef std::list< cGroup* > GroupList;
- const GroupList & GetInherits() const { return m_Inherits; }
-private:
- AString m_Name;
- AString m_Color;
-
- PermissionMap m_Permissions;
- CommandMap m_Commands;
- GroupList m_Inherits;
-}; // tolua_export
diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp
deleted file mode 100644
index 4c3dfc6f0..000000000
--- a/src/GroupManager.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
-
-#include "GroupManager.h"
-#include "Group.h"
-#include "inifile/iniFile.h"
-#include "ChatColor.h"
-#include "Root.h"
-
-
-
-
-
-typedef std::map< AString, cGroup* > GroupMap;
-
-
-
-
-
-struct cGroupManager::sGroupManagerState
-{
- GroupMap Groups;
-};
-
-
-
-
-
-cGroupManager::~cGroupManager()
-{
- for (GroupMap::iterator itr = m_pState->Groups.begin(); itr != m_pState->Groups.end(); ++itr)
- {
- delete itr->second;
- itr->second = NULL;
- }
- m_pState->Groups.clear();
-
- delete m_pState;
- m_pState = NULL;
-}
-
-
-
-
-
-cGroupManager::cGroupManager()
- : m_pState( new sGroupManagerState)
-{
- LOGD("-- Loading Groups --");
-
- if (!LoadGroups())
- {
- LOGWARNING("ERROR: Groups could not load!");
- }
- if (!CheckUsers())
- {
- LOGWARNING("ERROR: User file could not be found!");
- }
-
- LOGD("-- Groups Successfully Loaded --");
-}
-
-
-
-
-
-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");
-}
-
-
-
-
-
-bool cGroupManager::CheckUsers()
-{
- cIniFile IniFile;
- if (!IniFile.ReadFile("users.ini"))
- {
- GenerateDefaultUsersIni(IniFile);
- return true;
- }
-
- int NumKeys = IniFile.GetNumKeys();
- for (int i = 0; i < NumKeys; i++)
- {
- AString Player = IniFile.GetKeyName(i);
- AString Groups = IniFile.GetValue(Player, "Groups", "");
- if (Groups.empty())
- {
- continue;
- }
- AStringVector Split = StringSplitAndTrim(Groups, ",");
- for (AStringVector::const_iterator itr = Split.begin(), end = Split.end(); itr != end; ++itr)
- {
- if (!ExistsGroup(*itr))
- {
- LOGWARNING("The group %s for player %s was not found!", Split[i].c_str(), Player.c_str());
- }
- } // for itr - Split[]
- } // for i - ini file keys
- // Always return true for now, just but we can handle writefile fails later.
- return true;
-}
-
-
-
-
-
-bool cGroupManager::LoadGroups()
-{
- cIniFile IniFile;
- if (!IniFile.ReadFile("groups.ini"))
- {
- LOGWARNING("Regenerating groups.ini, all groups will be reset");
- IniFile.AddHeaderComment(" This is the MCServer permissions manager groups file");
- IniFile.AddHeaderComment(" It stores all defined groups such as Administrators, Players, or Moderators");
-
- IniFile.SetValue("Owner", "Permissions", "*", true);
- IniFile.SetValue("Owner", "Color", "2", true);
-
- IniFile.SetValue("Moderator", "Permissions", "core.time, core.item, core.tpa, core.tpaccept, core.ban, core.unban, core.save-all, core.toggledownfall");
- IniFile.SetValue("Moderator", "Color", "2", true);
- IniFile.SetValue("Moderator", "Inherits", "Player", true);
-
- IniFile.SetValue("Player", "Permissions", "core.portal", true);
- IniFile.SetValue("Player", "Color", "f", true);
- IniFile.SetValue("Player", "Inherits", "Default", true);
-
- IniFile.SetValue("Default", "Permissions", "core.help, core.plugins, core.spawn, core.worlds, core.back, core.motd, core.build, core.locate, core.viewdistance", true);
- IniFile.SetValue("Default", "Color", "f", true);
-
- IniFile.WriteFile("groups.ini");
- }
-
- int NumKeys = IniFile.GetNumKeys();
- for (int i = 0; i < NumKeys; i++)
- {
- AString KeyName = IniFile.GetKeyName(i);
- cGroup * Group = GetGroup(KeyName.c_str());
-
- Group->ClearPermission(); // Needed in case the groups are reloaded.
-
- LOGD("Loading group %s", KeyName.c_str());
-
- Group->SetName(KeyName);
- AString Color = IniFile.GetValue(KeyName, "Color", "-");
- if ((Color != "-") && (Color.length() >= 1))
- {
- Group->SetColor(AString(cChatColor::Delimiter) + Color[0]);
- }
- else
- {
- Group->SetColor(cChatColor::White);
- }
-
- 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]);
- }
- }
-
- AString Permissions = IniFile.GetValue(KeyName, "Permissions", "");
- if (!Permissions.empty())
- {
- AStringVector Split = StringSplitAndTrim(Permissions, ",");
- for (size_t i = 0; i < Split.size(); i++)
- {
- Group->AddPermission(Split[i]);
- }
- }
-
- AString Groups = IniFile.GetValue(KeyName, "Inherits", "");
- if (!Groups.empty())
- {
- AStringVector Split = StringSplitAndTrim(Groups, ",");
- for (size_t i = 0; i < Split.size(); i++)
- {
- Group->InheritFrom(GetGroup(Split[i].c_str()));
- }
- }
- }
- // Always return true, we can handle writefile fails later.
- return true;
-}
-
-
-
-
-
-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)
-{
- GroupMap::iterator itr = m_pState->Groups.find( a_Name);
- if (itr != m_pState->Groups.end())
- {
- return itr->second;
- }
-
- cGroup* Group = new cGroup();
- m_pState->Groups[a_Name] = Group;
-
- return Group;
-}
-
-
-
-
diff --git a/src/GroupManager.h b/src/GroupManager.h
deleted file mode 100644
index d42b55c4a..000000000
--- a/src/GroupManager.h
+++ /dev/null
@@ -1,36 +0,0 @@
-
-#pragma once
-
-
-
-
-
-class cGroup;
-
-
-
-
-
-class cGroupManager
-{
-public:
- bool ExistsGroup(const AString & a_Name);
- cGroup * GetGroup(const AString & a_Name);
- bool LoadGroups();
- bool CheckUsers();
-
- /** 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();
- ~cGroupManager();
-
- struct sGroupManagerState;
- sGroupManagerState * m_pState;
-} ;
-
-
-
-
diff --git a/src/Root.cpp b/src/Root.cpp
index 333d92de5..18221781d 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -6,7 +6,6 @@
#include "World.h"
#include "WebAdmin.h"
#include "FurnaceRecipe.h"
-#include "GroupManager.h"
#include "CraftingRecipes.h"
#include "Bindings/PluginManager.h"
#include "MonsterConfig.h"
@@ -46,7 +45,6 @@ cRoot::cRoot(void) :
m_InputThread(NULL),
m_Server(NULL),
m_MonsterConfig(NULL),
- m_GroupManager(NULL),
m_CraftingRecipes(NULL),
m_FurnaceRecipe(NULL),
m_WebAdmin(NULL),
@@ -157,7 +155,6 @@ void cRoot::Start(void)
LOGD("Loading settings...");
m_RankManager.Initialize(m_MojangAPI);
- m_GroupManager = new cGroupManager();
m_CraftingRecipes = new cCraftingRecipes;
m_FurnaceRecipe = new cFurnaceRecipe();
@@ -236,8 +233,6 @@ void cRoot::Start(void)
LOGD("Unloading recipes...");
delete m_FurnaceRecipe; m_FurnaceRecipe = NULL;
delete m_CraftingRecipes; m_CraftingRecipes = NULL;
- LOGD("Forgetting groups...");
- delete m_GroupManager; m_GroupManager = NULL;
LOGD("Unloading worlds...");
UnloadWorlds();
@@ -546,17 +541,6 @@ void cRoot::SaveAllChunks(void)
-void cRoot::ReloadGroups(void)
-{
- LOG("Reload groups ...");
- m_GroupManager->LoadGroups();
- m_GroupManager->CheckUsers();
-}
-
-
-
-
-
void cRoot::BroadcastChat(const AString & a_Message, eMessageType a_ChatPrefix)
{
for (WorldMap::iterator itr = m_WorldsByName.begin(), end = m_WorldsByName.end(); itr != end; ++itr)
diff --git a/src/Root.h b/src/Root.h
index 68469c72f..2e870a1ee 100644
--- a/src/Root.h
+++ b/src/Root.h
@@ -14,7 +14,6 @@
// fwd:
class cThread;
class cMonsterConfig;
-class cGroupManager;
class cCraftingRecipes;
class cFurnaceRecipe;
class cWebAdmin;
@@ -79,7 +78,6 @@ public:
cMonsterConfig * GetMonsterConfig(void) { return m_MonsterConfig; }
- cGroupManager * GetGroupManager (void) { return m_GroupManager; } // tolua_export
cCraftingRecipes * GetCraftingRecipes(void) { return m_CraftingRecipes; } // tolua_export
cFurnaceRecipe * GetFurnaceRecipe (void) { return m_FurnaceRecipe; } // Exported in ManualBindings.cpp with quite a different signature
@@ -124,9 +122,6 @@ public:
/// Saves all chunks in all worlds
void SaveAllChunks(void); // tolua_export
- /// Reloads all the groups
- void ReloadGroups(void); // tolua_export
-
/// Calls the callback for each player in all worlds
bool ForEachPlayer(cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
@@ -189,7 +184,6 @@ private:
cServer * m_Server;
cMonsterConfig * m_MonsterConfig;
- cGroupManager * m_GroupManager;
cCraftingRecipes * m_CraftingRecipes;
cFurnaceRecipe * m_FurnaceRecipe;
cWebAdmin * m_WebAdmin;
diff --git a/src/Server.cpp b/src/Server.cpp
index 42ad133f1..012a51883 100644
--- a/src/Server.cpp
+++ b/src/Server.cpp
@@ -11,7 +11,6 @@
#include "World.h"
#include "ChunkDef.h"
#include "Bindings/PluginManager.h"
-#include "GroupManager.h"
#include "ChatColor.h"
#include "Entities/Player.h"
#include "Inventory.h"
@@ -469,25 +468,17 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac
PrintHelp(split, a_Output);
return;
}
- if (split[0] == "reload")
+ else if (split[0] == "reload")
{
cPluginManager::Get()->ReloadPlugins();
- cRoot::Get()->ReloadGroups();
return;
}
- if (split[0] == "reloadplugins")
+ else if (split[0] == "reloadplugins")
{
cPluginManager::Get()->ReloadPlugins();
return;
}
- if (split[0] == "reloadgroups")
- {
- cRoot::Get()->ReloadGroups();
- a_Output.Out("Groups reloaded!");
- a_Output.Finished();
- return;
- }
- if (split[0] == "load")
+ else if (split[0] == "load")
{
if (split.size() > 1)
{
@@ -502,8 +493,7 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac
return;
}
}
-
- if (split[0] == "unload")
+ else if (split[0] == "unload")
{
if (split.size() > 1)
{
@@ -519,21 +509,21 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac
}
// There is currently no way a plugin can do these (and probably won't ever be):
- if (split[0].compare("chunkstats") == 0)
+ else if (split[0].compare("chunkstats") == 0)
{
cRoot::Get()->LogChunkStats(a_Output);
a_Output.Finished();
return;
}
#if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER)
- if (split[0].compare("dumpmem") == 0)
+ else if (split[0].compare("dumpmem") == 0)
{
LeakFinderXmlOutput Output("memdump.xml");
DumpUsedMemory(&Output);
return;
}
- if (split[0].compare("killmem") == 0)
+ else if (split[0].compare("killmem") == 0)
{
for (;;)
{
@@ -542,7 +532,7 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac
}
#endif
- if (cPluginManager::Get()->ExecuteConsoleCommand(split, a_Output))
+ else if (cPluginManager::Get()->ExecuteConsoleCommand(split, a_Output))
{
a_Output.Finished();
return;