From 07d000cc54c26001f9f79e5c0d45c2d3c4f614eb Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 16 Oct 2011 20:03:43 +0300 Subject: [PATCH] When granting or revoking privileges, notify the target player too --- src/server.cpp | 8 ++++++++ src/server.h | 3 +++ src/servercommand.cpp | 18 ++++++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/server.cpp b/src/server.cpp index 3e22a023a..3e1034f50 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -4148,6 +4148,14 @@ void Server::saveConfig() g_settings->updateConfigFile(m_configpath.c_str()); } +void Server::notifyPlayer(const char *name, const std::wstring msg) +{ + Player *player = m_env.getPlayer(name); + if(!player) + return; + SendChatMessage(player->peer_id, std::wstring(L"Server: -!- ")+msg); +} + v3f findSpawnPos(ServerMap &map) { //return v3f(50,50,50)*BS; diff --git a/src/server.h b/src/server.h index f65bd1957..1e7e41c96 100644 --- a/src/server.h +++ b/src/server.h @@ -472,6 +472,9 @@ public: { return m_con.GetPeerNoEx(peer_id); } + + // Envlock and conlock should be locked when calling this + void notifyPlayer(const char *name, const std::wstring msg); private: diff --git a/src/servercommand.cpp b/src/servercommand.cpp index 98777adcc..3c0e6d510 100644 --- a/src/servercommand.cpp +++ b/src/servercommand.cpp @@ -97,15 +97,29 @@ void cmd_grantrevoke(std::wostringstream &os, u64 privs = ctx->server->getPlayerAuthPrivs(playername); if(ctx->parms[0] == L"grant"){ + privs |= newprivs; actionstream<player->getName()<<" grants " <parms[2])<<" to " <player->getName()); + msg += L" granted you the privilege \""; + msg += ctx->parms[2]; + msg += L"\""; + ctx->server->notifyPlayer(playername.c_str(), msg); } else { + privs &= ~newprivs; actionstream<player->getName()<<" revokes " <parms[2])<<" from " <player->getName()); + msg += L" revoked from you the privilege \""; + msg += ctx->parms[2]; + msg += L"\""; + ctx->server->notifyPlayer(playername.c_str(), msg); } ctx->server->setPlayerAuthPrivs(playername, privs); -- 2.25.1