check GM on the gameserver based on station id because it is most readily available to us. see corresponding change to the datatable

This commit is contained in:
DarthArgus
2017-01-02 23:40:52 +00:00
parent c3a4707623
commit f6d82340e2
3 changed files with 27 additions and 3 deletions
@@ -2227,14 +2227,23 @@ float Client::computeDeltaTimeInSeconds(uint32 const syncStampLong) const
bool Client::setGodMode(bool value)
{
// (re?) check god permissions
m_godLevel = AdminAccountManager::isAdminAccount(getStationId());
if (ConfigServerGame::getAdminGodToAll() || (m_godLevel > 0))
{
m_godValidated = true;
if (ConfigServerGame::getAdminGodToAll())
m_godLevel = ConfigServerGame::getAdminGodToAllGodLevel();
}
bool wasInGodMode = m_godMode;
m_godMode = value;
if (value && !m_godValidated)
{
LOG("CustomerService", ("Avatar:%s denied god mode because it wasn't validated.", PlayerObject::getAccountDescription(getCharacterObjectId()).c_str() ));
m_godMode = false;
LOG("CustomerService", ("Avatar:%s denied god mode because it wasn't validated.", PlayerObject::getAccountDescription(getCharacterObjectId()).c_str() ));
m_godMode = false;
}
CreatureObject *primaryControlledObject = safe_cast<CreatureObject*>(m_primaryControlledObject.getObject());
@@ -64,6 +64,20 @@ const std::string & AdminAccountManager::getAdminTagName()
//-----------------------------------------------------------------------
// if they are in the iff and have a level set, return it
int AdminAccountManager::isAdminAccount(int suid)
{
DEBUG_FATAL(!ms_installed, ("AdminAccountManager not installed"));
int columnNumber = ms_adminTable->findColumnNumber("AdminSuid");
DEBUG_FATAL(columnNumber == -1, ("Error loading admin table...no account column"));
int row = ms_adminTable->searchColumnInt(columnNumber, suid);
if (row == -1)
return false;
return (int) ms_adminTable->getIntValue("AdminLevel", row);
}
bool AdminAccountManager::isAdminAccount(const std::string & account, int& level)
{
level = 0;
@@ -19,6 +19,7 @@ public:
static const char *getAdminCommandName();
static const std::string & getAdminTagName();
static int isAdminAccount(int suid);
static bool isAdminAccount(const std::string & account, int& level);
static bool isInternalIp(const std::string & addr);
static void reload();