diff options
| author | p0wer <none@none> | 2009-12-21 21:08:29 -0600 |
|---|---|---|
| committer | p0wer <none@none> | 2009-12-21 21:08:29 -0600 |
| commit | 75904791863494b213c5b8ae2a864910a5d4ca35 (patch) | |
| tree | ad36a802e978f42a1730cdb1bb20f9e3271b6aea /src/game/Level3.cpp | |
| parent | cad203e680f1f40585880ef32e210fdc02316ff9 (diff) | |
* Add support for different gmlevel's for different realms.
*
* Using the value -1 will add the same value for all realms.
* Make sure to apply the updates.
* Information regarding this patch will be posted on the database forums soon.
*
* Thanks to Sundark and the Ilixiuemu team(for original patch)
--HG--
branch : trunk
Diffstat (limited to 'src/game/Level3.cpp')
| -rw-r--r-- | src/game/Level3.cpp | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index e29c21c0bb2..624fc1d14ea 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -1411,13 +1411,15 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char *args) uint32 gm = 0; char* arg1 = strtok((char*)args, " "); char* arg2 = strtok(NULL, " "); + char* arg3 = strtok(NULL, " "); - if (getSelectedPlayer() && arg1 && !arg2) + if (getSelectedPlayer() && arg1 && !arg3) { targetAccountId = getSelectedPlayer()->GetSession()->GetAccountId(); accmgr.GetName(targetAccountId, targetAccountName); Player* targetPlayer = getSelectedPlayer(); gm = atoi(arg1); + uint32 gmRealmID = arg2 ? atoi(arg2) : realmID; // Check for invalid specified GM level. if (gm < SEC_PLAYER || gm > SEC_ADMINISTRATOR) @@ -1429,20 +1431,40 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char *args) // Check if targets GM level and specified GM level is not higher than current gm level targetSecurity = targetPlayer->GetSession()->GetSecurity(); - if (targetSecurity >= m_session->GetSecurity() || gm >= m_session->GetSecurity()) + if (targetSecurity >= m_session->GetSecurity() || + gm >= m_session->GetSecurity() || + (gmRealmID != realmID && m_session->GetSecurity() < SEC_CONSOLE)) { SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); SetSentErrorMessage(true); return false; } + // Check if provided realmID is not current realmID, or isn't -1 + if (gmRealmID != realmID && gmRealmID != -1) + { + SendSysMessage(LANG_INVALID_REALMID); + SetSentErrorMessage(true); + return false; + } + // Decide which string to show if (m_session->GetPlayer() != targetPlayer) PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm); else PSendSysMessage(LANG_YOURS_SECURITY_CHANGED, m_session->GetPlayer()->GetName(), gm); - loginDatabase.PExecute("UPDATE account SET gmlevel = '%d' WHERE id = '%u'", gm, targetAccountId); + // If gmRealmID is -1, delete all values for the account id, else, insert values for the specific realmID + if (gmRealmID == -1) + { + loginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u'", targetAccountId); + loginDatabase.PExecute("INSERT INTO account_access VALUES ('%u', '%d', -1)", targetAccountId, gm); + } + else + { + loginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u' AND RealmID = '%d'", targetAccountId, realmID); + loginDatabase.PExecute("INSERT INTO account_access VALUES ('%u','%d','%d')", targetAccountId, gm, realmID); + } return true; } else @@ -1469,6 +1491,15 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char *args) return false; } + uint32 gmRealmID = arg3 ? atoi(arg3) : realmID; + // Check if provided realmID is not current realmID, or isn't -1 + if (gmRealmID != realmID && gmRealmID != -1) + { + SendSysMessage(LANG_INVALID_REALMID); + SetSentErrorMessage(true); + return false; + } + targetAccountId = accmgr.GetId(arg1); /// m_session==NULL only for console uint32 plSecurity = m_session ? m_session->GetSecurity() : SEC_CONSOLE; @@ -1484,7 +1515,17 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char *args) } PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm); - loginDatabase.PExecute("UPDATE account SET gmlevel = '%d' WHERE id = '%u'", gm, targetAccountId); + // If gmRealmID is -1, delete all values for the account id, else, insert values for the specific realmID + if (gmRealmID == -1) + { + loginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u'", targetAccountId); + loginDatabase.PExecute("INSERT INTO account_access VALUES ('%u', '%d', -1)", targetAccountId, gm); + } + else + { + loginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u' AND RealmID = '%d'", targetAccountId, realmID); + loginDatabase.PExecute("INSERT INTO account_access VALUES ('%u','%d','%d')", targetAccountId, gm, realmID); + } return true; } } @@ -6915,7 +6956,7 @@ bool ChatHandler::HandleInstanceSaveDataCommand(const char * /*args*/) bool ChatHandler::HandleGMListFullCommand(const char* /*args*/) { ///- Get the accounts with GM Level >0 - QueryResult *result = loginDatabase.Query( "SELECT username,gmlevel FROM account WHERE gmlevel > 0" ); + QueryResult *result = loginDatabase.Query("SELECT a.username,aa.gmlevel FROM account a, account_access aa WHERE a.id=aa.id AND aa.gmlevel > 0"); if(result) { SendSysMessage(LANG_GMLIST); |
