mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 10:26:28 +01:00
Added new function "GetSecurity(targetAccountId, gmRealmID);" by ogeraisi.
Fixed command .account set gmlevel Fixed command .ticket assing by Sundark/ogeraisi. Improvements in .modify scale by ogeraisi. Repaired Remote Access by Sundark. The original patch of the access by realms was from ogeraisi/Kudlaty, not ilixiumemu like commit 6710 say. --HG-- branch : trunk
This commit is contained in:
@@ -1412,68 +1412,22 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char *args)
|
||||
char* arg1 = strtok((char*)args, " ");
|
||||
char* arg2 = strtok(NULL, " ");
|
||||
char* arg3 = strtok(NULL, " ");
|
||||
bool isAccountNameGiven = true;
|
||||
|
||||
if (getSelectedPlayer() && arg1 && !arg3)
|
||||
if (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)
|
||||
{
|
||||
SendSysMessage(LANG_BAD_VALUE);
|
||||
SetSentErrorMessage(true);
|
||||
if (!getSelectedPlayer())
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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() ||
|
||||
(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);
|
||||
|
||||
// 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;
|
||||
isAccountNameGiven = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check for second parameter
|
||||
if (!arg2)
|
||||
return false;
|
||||
|
||||
// Check for account
|
||||
// Check for second parameter
|
||||
if (!isAccountNameGiven && !arg2)
|
||||
return false;
|
||||
|
||||
// Check for account
|
||||
if (isAccountNameGiven)
|
||||
{
|
||||
targetAccountName = arg1;
|
||||
if (!AccountMgr::normalizeString(targetAccountName))
|
||||
{
|
||||
@@ -1481,53 +1435,63 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(const char *args)
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for invalid specified GM level.
|
||||
gm = atoi(arg2);
|
||||
if (gm < SEC_PLAYER || gm > SEC_ADMINISTRATOR)
|
||||
{
|
||||
SendSysMessage(LANG_BAD_VALUE);
|
||||
SetSentErrorMessage(true);
|
||||
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;
|
||||
|
||||
/// can set security level only for target with less security and to less security that we have
|
||||
/// This is also reject self apply in fact
|
||||
targetSecurity = accmgr.GetSecurity(targetAccountId);
|
||||
if (targetSecurity >= plSecurity || gm >= plSecurity)
|
||||
// Check for invalid specified GM level.
|
||||
gm = (isAccountNameGiven) ? atoi(arg2) : atoi(arg1);
|
||||
if (gm < SEC_PLAYER)
|
||||
{
|
||||
SendSysMessage(LANG_BAD_VALUE);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// m_session == NULL only for console
|
||||
targetAccountId = (isAccountNameGiven) ? accmgr.GetId(targetAccountName) : getSelectedPlayer()->GetSession()->GetAccountId();
|
||||
int32 gmRealmID = (isAccountNameGiven) ? atoi(arg3) : atoi(arg2);
|
||||
uint32 plSecurity = m_session ? accmgr.GetSecurity(m_session->GetAccountId(), gmRealmID) : SEC_CONSOLE;
|
||||
|
||||
// can set security level only for target with less security and to less security that we have
|
||||
// This is also reject self apply in fact
|
||||
targetSecurity = accmgr.GetSecurity(targetAccountId, gmRealmID);
|
||||
if (targetSecurity >= plSecurity || gm >= plSecurity)
|
||||
{
|
||||
SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check and abort if the target gm has a higher rank on one of the realms and the new realm is -1
|
||||
if (gmRealmID == -1)
|
||||
{
|
||||
QueryResult *result = loginDatabase.PQuery("SELECT * FROM account_access WHERE id = '%u' AND gmlevel > '%d'", targetAccountId, gm);
|
||||
if (result)
|
||||
{
|
||||
delete result;
|
||||
SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm);
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Check if provided realmID has a negative value other than -1
|
||||
if (gmRealmID < -1)
|
||||
{
|
||||
SendSysMessage(LANG_INVALID_REALMID);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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);
|
||||
else
|
||||
loginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u' AND (RealmID = '%d' OR RealmID = '-1')", targetAccountId, realmID);
|
||||
|
||||
if (gm != 0)
|
||||
loginDatabase.PExecute("INSERT INTO account_access VALUES ('%u','%d','%d')", targetAccountId, gm, realmID);
|
||||
PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Set password for account
|
||||
|
||||
Reference in New Issue
Block a user