[6982] Implemented gmlevel-based command security

This is just a simple check if target's gmlevel is lesser
than the caller's one. If it is, an error is returned.
Offline checks for some commands are included.

That in simple words means no further .goname to a gmlevel 3 player
from a gmlevel 2 or 1 account, so gmlevel 3 can work in peace.

Signed-off-by: freghar <compmancz@gmail.com>
This commit is contained in:
freghar 2008-12-09 15:04:56 +01:00
parent bc0a840e6a
commit 73ca2b7a54
8 changed files with 229 additions and 1 deletions

View file

@ -31,6 +31,7 @@
#include "MapManager.h"
#include "GridNotifiersImpl.h"
#include "CellImpl.h"
#include "AccountMgr.h"
bool ChatHandler::load_command_table = true;
@ -625,6 +626,38 @@ bool ChatHandler::isAvailable(ChatCommand const& cmd) const
return m_session->GetSecurity() >= cmd.SecurityLevel;
}
bool ChatHandler::HasLowerSecurity(Player* target, uint64 guid)
{
uint32 target_sec;
if (!sWorld.getConfig(CONFIG_GM_LOWER_SECURITY))
return false;
// allow everything from RA console
if (!m_session)
return false;
if (target)
target_sec = target->GetSession()->GetSecurity();
else if (guid)
target_sec = accmgr.GetSecurity(objmgr.GetPlayerAccountIdByGUID(guid));
else
{
SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
return true;
}
if (m_session->GetSecurity() < target_sec)
{
SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
SetSentErrorMessage(true);
return true;
}
return false;
}
bool ChatHandler::hasStringAbbr(const char* name, const char* part)
{
// non "" command