diff --git a/engine/server/library/serverGame/src/shared/core/Client.cpp b/engine/server/library/serverGame/src/shared/core/Client.cpp index 2c4ebd71..00fb39cd 100755 --- a/engine/server/library/serverGame/src/shared/core/Client.cpp +++ b/engine/server/library/serverGame/src/shared/core/Client.cpp @@ -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(m_primaryControlledObject.getObject()); diff --git a/engine/server/library/serverUtility/src/shared/AdminAccountManager.cpp b/engine/server/library/serverUtility/src/shared/AdminAccountManager.cpp index e4075721..92a19391 100755 --- a/engine/server/library/serverUtility/src/shared/AdminAccountManager.cpp +++ b/engine/server/library/serverUtility/src/shared/AdminAccountManager.cpp @@ -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; diff --git a/engine/server/library/serverUtility/src/shared/AdminAccountManager.h b/engine/server/library/serverUtility/src/shared/AdminAccountManager.h index d099b790..378c5893 100755 --- a/engine/server/library/serverUtility/src/shared/AdminAccountManager.h +++ b/engine/server/library/serverUtility/src/shared/AdminAccountManager.h @@ -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();