When granting or revoking privileges, notify the target player too

This commit is contained in:
Perttu Ahola 2011-10-16 20:03:43 +03:00
parent 6470743e51
commit 07d000cc54
3 changed files with 27 additions and 2 deletions

@ -4148,6 +4148,14 @@ void Server::saveConfig()
g_settings->updateConfigFile(m_configpath.c_str()); 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) v3f findSpawnPos(ServerMap &map)
{ {
//return v3f(50,50,50)*BS; //return v3f(50,50,50)*BS;

@ -473,6 +473,9 @@ public:
return m_con.GetPeerNoEx(peer_id); 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: private:
// con::PeerHandler implementation. // con::PeerHandler implementation.

@ -97,15 +97,29 @@ void cmd_grantrevoke(std::wostringstream &os,
u64 privs = ctx->server->getPlayerAuthPrivs(playername); u64 privs = ctx->server->getPlayerAuthPrivs(playername);
if(ctx->parms[0] == L"grant"){ if(ctx->parms[0] == L"grant"){
privs |= newprivs;
actionstream<<ctx->player->getName()<<" grants " actionstream<<ctx->player->getName()<<" grants "
<<wide_to_narrow(ctx->parms[2])<<" to " <<wide_to_narrow(ctx->parms[2])<<" to "
<<playername<<std::endl; <<playername<<std::endl;
privs |= newprivs;
std::wstring msg;
msg += narrow_to_wide(ctx->player->getName());
msg += L" granted you the privilege \"";
msg += ctx->parms[2];
msg += L"\"";
ctx->server->notifyPlayer(playername.c_str(), msg);
} else { } else {
privs &= ~newprivs;
actionstream<<ctx->player->getName()<<" revokes " actionstream<<ctx->player->getName()<<" revokes "
<<wide_to_narrow(ctx->parms[2])<<" from " <<wide_to_narrow(ctx->parms[2])<<" from "
<<playername<<std::endl; <<playername<<std::endl;
privs &= ~newprivs;
std::wstring msg;
msg += narrow_to_wide(ctx->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); ctx->server->setPlayerAuthPrivs(playername, privs);