summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-09-28 15:16:11 +0200
committerHowaner <franzi.moos@googlemail.com>2014-09-28 15:16:11 +0200
commit63c53a8e23776cc3011fd0260857bd22274e2c62 (patch)
tree014d4498cffa77ce5bf504abe96e7d23832c9d5b /src
parentUpdated api documentation. (diff)
downloadcuberite-63c53a8e23776cc3011fd0260857bd22274e2c62.tar
cuberite-63c53a8e23776cc3011fd0260857bd22274e2c62.tar.gz
cuberite-63c53a8e23776cc3011fd0260857bd22274e2c62.tar.bz2
cuberite-63c53a8e23776cc3011fd0260857bd22274e2c62.tar.lz
cuberite-63c53a8e23776cc3011fd0260857bd22274e2c62.tar.xz
cuberite-63c53a8e23776cc3011fd0260857bd22274e2c62.tar.zst
cuberite-63c53a8e23776cc3011fd0260857bd22274e2c62.zip
Diffstat (limited to 'src')
-rw-r--r--src/Bindings/ManualBindings_RankManager.cpp22
-rw-r--r--src/RankManager.cpp19
-rw-r--r--src/RankManager.h4
3 files changed, 45 insertions, 0 deletions
diff --git a/src/Bindings/ManualBindings_RankManager.cpp b/src/Bindings/ManualBindings_RankManager.cpp
index b43cd9ef2..cddf1ec2e 100644
--- a/src/Bindings/ManualBindings_RankManager.cpp
+++ b/src/Bindings/ManualBindings_RankManager.cpp
@@ -129,6 +129,27 @@ static int tolua_cRankManager_AddRank(lua_State * L)
+/** Binds cRankManager::ClearPlayerRanks */
+static int tolua_cRankManager_ClearPlayerRanks(lua_State * L)
+{
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamEnd(2)
+ )
+ {
+ return 0;
+ }
+
+ // Remove all players:
+ cRoot::Get()->GetRankManager().ClearPlayerRanks();
+ return 1;
+}
+
+
+
+
+
/** Binds cRankManager::GetAllGroups */
static int tolua_cRankManager_GetAllGroups(lua_State * L)
{
@@ -1031,6 +1052,7 @@ void ManualBindings::BindRankManager(lua_State * tolua_S)
tolua_function(tolua_S, "AddGroupToRank", tolua_cRankManager_AddGroupToRank);
tolua_function(tolua_S, "AddPermissionToGroup", tolua_cRankManager_AddPermissionToGroup);
tolua_function(tolua_S, "AddRank", tolua_cRankManager_AddRank);
+ tolua_function(tolua_S, "ClearPlayerRanks", tolua_cRankManager_ClearPlayerRanks);
tolua_function(tolua_S, "GetAllGroups", tolua_cRankManager_GetAllGroups);
tolua_function(tolua_S, "GetAllPermissions", tolua_cRankManager_GetAllPermissions);
tolua_function(tolua_S, "GetAllPlayers", tolua_cRankManager_GetAllPlayers);
diff --git a/src/RankManager.cpp b/src/RankManager.cpp
index 0f267473a..fd5e58025 100644
--- a/src/RankManager.cpp
+++ b/src/RankManager.cpp
@@ -1817,6 +1817,25 @@ bool cRankManager::SetDefaultRank(const AString & a_RankName)
+void cRankManager::ClearPlayerRanks(void)
+{
+ ASSERT(m_IsInitialized);
+ cCSLock Lock(m_CS);
+
+ try {
+ SQLite::Statement stmt(m_DB, "DELETE FROM PlayerRank");
+ stmt.exec();
+ }
+ catch (SQLite::Exception & ex)
+ {
+ LOGWARNING("%s: Failed to remove/clear all players: %s", __FUNCTION__, ex.what());
+ }
+}
+
+
+
+
+
bool cRankManager::UpdatePlayerName(const AString & a_PlayerUUID, const AString & a_NewPlayerName)
{
ASSERT(m_IsInitialized);
diff --git a/src/RankManager.h b/src/RankManager.h
index b577fad05..acfcdb01d 100644
--- a/src/RankManager.h
+++ b/src/RankManager.h
@@ -217,6 +217,10 @@ public:
/** Returns the name of the default rank. */
const AString & GetDefaultRank(void) const { return m_DefaultRank; }
+
+ /** Removes all player ranks from the database. Note that this doesn't change the cPlayer instances
+ for the already connected players, you need to update all the instances manually. */
+ void ClearPlayerRanks(void);
/** Updates the playername that is saved with this uuid. Returns false if a error occurred */
bool UpdatePlayerName(const AString & a_PlayerUUID, const AString & a_NewPlayerName);