Script/Commands: Codestyle and cleanups
This commit is contained in:
@@ -60,7 +60,7 @@ public:
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
static bool HandleAccountAddonCommand(ChatHandler* handler, const char* args)
|
||||
static bool HandleAccountAddonCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
{
|
||||
@@ -69,11 +69,11 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
char *szExp = strtok((char*)args, " ");
|
||||
char* exp = strtok((char*)args, " ");
|
||||
|
||||
uint32 account_id = handler->GetSession()->GetAccountId();
|
||||
uint32 accountId = handler->GetSession()->GetAccountId();
|
||||
|
||||
int expansion = atoi(szExp); //get int anyway (0 if error)
|
||||
int expansion = atoi(exp); //get int anyway (0 if error)
|
||||
if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION))
|
||||
{
|
||||
handler->SendSysMessage(LANG_IMPROPER_VALUE);
|
||||
@@ -82,78 +82,74 @@ public:
|
||||
}
|
||||
|
||||
// No SQL injection
|
||||
LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, account_id);
|
||||
LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, accountId);
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_ADDON, expansion);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Create an account
|
||||
static bool HandleAccountCreateCommand(ChatHandler* handler, const char* args)
|
||||
static bool HandleAccountCreateCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
///- %Parse the command line arguments
|
||||
char *szAcc = strtok((char*)args, " ");
|
||||
char *szPassword = strtok(NULL, " ");
|
||||
if (!szAcc || !szPassword)
|
||||
char* accountName = strtok((char*)args, " ");
|
||||
char* password = strtok(NULL, " ");
|
||||
if (!accountName || !password)
|
||||
return false;
|
||||
|
||||
// normalized in AccountMgr::CreateAccount
|
||||
std::string account_name = szAcc;
|
||||
std::string password = szPassword;
|
||||
|
||||
AccountOpResult result = AccountMgr::CreateAccount(account_name, password);
|
||||
AccountOpResult result = AccountMgr::CreateAccount(std::string(accountName), std::string(password));
|
||||
switch (result)
|
||||
{
|
||||
case AOR_OK:
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_CREATED, account_name.c_str());
|
||||
break;
|
||||
case AOR_NAME_TOO_LONG:
|
||||
handler->SendSysMessage(LANG_ACCOUNT_TOO_LONG);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
case AOR_NAME_ALREDY_EXIST:
|
||||
handler->SendSysMessage(LANG_ACCOUNT_ALREADY_EXIST);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
case AOR_DB_INTERNAL_ERROR:
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED_SQL_ERROR, account_name.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
default:
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED, account_name.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
case AOR_OK:
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName);
|
||||
break;
|
||||
case AOR_NAME_TOO_LONG:
|
||||
handler->SendSysMessage(LANG_ACCOUNT_TOO_LONG);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
case AOR_NAME_ALREDY_EXIST:
|
||||
handler->SendSysMessage(LANG_ACCOUNT_ALREADY_EXIST);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
case AOR_DB_INTERNAL_ERROR:
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED_SQL_ERROR, accountName);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
default:
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED, accountName);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Delete a user account and all associated characters in this realm
|
||||
/// \todo This function has to be enhanced to respect the login/realm split (delete char, delete account chars in realm, delete account chars in realm then delete account
|
||||
static bool HandleAccountDeleteCommand(ChatHandler* handler, const char* args)
|
||||
/// \todo This function has to be enhanced to respect the login/realm split (delete char, delete account chars in realm then delete account)
|
||||
static bool HandleAccountDeleteCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
///- Get the account name from the command line
|
||||
char *account_name_str=strtok ((char*)args, " ");
|
||||
if (!account_name_str)
|
||||
char* account = strtok((char*)args, " ");
|
||||
if (!account)
|
||||
return false;
|
||||
|
||||
std::string account_name = account_name_str;
|
||||
if (!AccountMgr::normalizeString(account_name))
|
||||
std::string accountName = account;
|
||||
if (!AccountMgr::normalizeString(accountName))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str());
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 account_id = AccountMgr::GetId(account_name);
|
||||
if (!account_id)
|
||||
uint32 accountId = AccountMgr::GetId(accountName);
|
||||
if (!accountId)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str());
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
@@ -161,34 +157,34 @@ public:
|
||||
/// Commands not recommended call from chat, but support anyway
|
||||
/// can delete only for account with less security
|
||||
/// This is also reject self apply in fact
|
||||
if (handler->HasLowerSecurityAccount (NULL, account_id, true))
|
||||
if (handler->HasLowerSecurityAccount(NULL, accountId, true))
|
||||
return false;
|
||||
|
||||
AccountOpResult result = AccountMgr::DeleteAccount(account_id);
|
||||
AccountOpResult result = AccountMgr::DeleteAccount(accountId);
|
||||
switch (result)
|
||||
{
|
||||
case AOR_OK:
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_DELETED, account_name.c_str());
|
||||
break;
|
||||
case AOR_NAME_NOT_EXIST:
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
case AOR_DB_INTERNAL_ERROR:
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED_SQL_ERROR, account_name.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
default:
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED, account_name.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
case AOR_OK:
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_DELETED, accountName.c_str());
|
||||
break;
|
||||
case AOR_NAME_NOT_EXIST:
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
case AOR_DB_INTERNAL_ERROR:
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED_SQL_ERROR, accountName.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
default:
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED, accountName.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Display info on users currently in the realm
|
||||
static bool HandleAccountOnlineListCommand(ChatHandler* handler, const char* /*args*/)
|
||||
static bool HandleAccountOnlineListCommand(ChatHandler* handler, char const* /*args*/)
|
||||
{
|
||||
///- Get the list of accounts ID logged to the realm
|
||||
QueryResult resultDB = CharacterDatabase.Query("SELECT name, account, map, zone FROM characters WHERE online > 0");
|
||||
@@ -218,6 +214,7 @@ public:
|
||||
"LEFT JOIN account_access aa "
|
||||
"ON (a.id = aa.id) "
|
||||
"WHERE a.id = '%u'", account);
|
||||
|
||||
if (resultLogin)
|
||||
{
|
||||
Field* fieldsLogin = resultLogin->Fetch();
|
||||
@@ -229,13 +226,13 @@ public:
|
||||
else
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_LIST_ERROR, name.c_str());
|
||||
|
||||
}while (resultDB->NextRow());
|
||||
} while (resultDB->NextRow());
|
||||
|
||||
handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleAccountLockCommand(ChatHandler* handler, const char* args)
|
||||
static bool HandleAccountLockCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
{
|
||||
@@ -244,15 +241,15 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string argstr = (char*)args;
|
||||
if (argstr == "on")
|
||||
std::string param = (char*)args;
|
||||
if (param == "on")
|
||||
{
|
||||
LoginDatabase.PExecute("UPDATE account SET locked = '1' WHERE id = '%d'", handler->GetSession()->GetAccountId());
|
||||
handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (argstr == "off")
|
||||
if (param == "off")
|
||||
{
|
||||
LoginDatabase.PExecute("UPDATE account SET locked = '0' WHERE id = '%d'", handler->GetSession()->GetAccountId());
|
||||
handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
|
||||
@@ -264,7 +261,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool HandleAccountPasswordCommand(ChatHandler* handler, const char* args)
|
||||
static bool HandleAccountPasswordCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
{
|
||||
@@ -273,95 +270,95 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
char *old_pass = strtok((char*)args, " ");
|
||||
char *new_pass = strtok(NULL, " ");
|
||||
char *new_pass_c = strtok(NULL, " ");
|
||||
char* oldPassword = strtok((char*)args, " ");
|
||||
char* newPassword = strtok(NULL, " ");
|
||||
char* passwordConfirmation = strtok(NULL, " ");
|
||||
|
||||
if (!old_pass || !new_pass || !new_pass_c)
|
||||
if (!oldPassword || !newPassword || !passwordConfirmation)
|
||||
{
|
||||
handler->SendSysMessage(LANG_CMD_SYNTAX);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!AccountMgr::CheckPassword(handler->GetSession()->GetAccountId(), std::string(old_pass)))
|
||||
if (!AccountMgr::CheckPassword(handler->GetSession()->GetAccountId(), std::string(oldPassword)))
|
||||
{
|
||||
handler->SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strcmp(new_pass, new_pass_c) != 0)
|
||||
if (strcmp(newPassword, passwordConfirmation) != 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
AccountOpResult result = AccountMgr::ChangePassword(handler->GetSession()->GetAccountId(), std::string(new_pass));
|
||||
AccountOpResult result = AccountMgr::ChangePassword(handler->GetSession()->GetAccountId(), std::string(newPassword));
|
||||
switch (result)
|
||||
{
|
||||
case AOR_OK:
|
||||
handler->SendSysMessage(LANG_COMMAND_PASSWORD);
|
||||
break;
|
||||
case AOR_PASS_TOO_LONG:
|
||||
handler->SendSysMessage(LANG_PASSWORD_TOO_LONG);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
default:
|
||||
handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
case AOR_OK:
|
||||
handler->SendSysMessage(LANG_COMMAND_PASSWORD);
|
||||
break;
|
||||
case AOR_PASS_TOO_LONG:
|
||||
handler->SendSysMessage(LANG_PASSWORD_TOO_LONG);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
default:
|
||||
handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleAccountCommand(ChatHandler* handler, const char* /*args*/)
|
||||
static bool HandleAccountCommand(ChatHandler* handler, char const* /*args*/)
|
||||
{
|
||||
AccountTypes gmlevel = handler->GetSession()->GetSecurity();
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_LEVEL, uint32(gmlevel));
|
||||
AccountTypes gmLevel = handler->GetSession()->GetSecurity();
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_LEVEL, uint32(gmLevel));
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Set/Unset the expansion level for an account
|
||||
static bool HandleAccountSetAddonCommand(ChatHandler* handler, const char *args)
|
||||
static bool HandleAccountSetAddonCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
///- Get the command line arguments
|
||||
char *szAcc = strtok((char*)args, " ");
|
||||
char *szExp = strtok(NULL, " ");
|
||||
char* account = strtok((char*)args, " ");
|
||||
char* exp = strtok(NULL, " ");
|
||||
|
||||
if (!szAcc)
|
||||
if (!account)
|
||||
return false;
|
||||
|
||||
std::string account_name;
|
||||
uint32 account_id;
|
||||
std::string accountName;
|
||||
uint32 accountId;
|
||||
|
||||
if (!szExp)
|
||||
if (!exp)
|
||||
{
|
||||
Player* player = handler->getSelectedPlayer();
|
||||
if (!player)
|
||||
return false;
|
||||
|
||||
account_id = player->GetSession()->GetAccountId();
|
||||
AccountMgr::GetName(account_id, account_name);
|
||||
szExp = szAcc;
|
||||
accountId = player->GetSession()->GetAccountId();
|
||||
AccountMgr::GetName(accountId, accountName);
|
||||
exp = account;
|
||||
}
|
||||
else
|
||||
{
|
||||
///- Convert Account name to Upper Format
|
||||
account_name = szAcc;
|
||||
if (!AccountMgr::normalizeString(account_name))
|
||||
accountName = account;
|
||||
if (!AccountMgr::normalizeString(accountName))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str());
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
account_id = AccountMgr::GetId(account_name);
|
||||
if (!account_id)
|
||||
accountId = AccountMgr::GetId(accountName);
|
||||
if (!accountId)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str());
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
@@ -370,21 +367,21 @@ public:
|
||||
|
||||
// Let set addon state only for lesser (strong) security level
|
||||
// or to self account
|
||||
if (handler->GetSession() && handler->GetSession()->GetAccountId () != account_id &&
|
||||
handler->HasLowerSecurityAccount (NULL, account_id, true))
|
||||
if (handler->GetSession() && handler->GetSession()->GetAccountId () != accountId &&
|
||||
handler->HasLowerSecurityAccount(NULL, accountId, true))
|
||||
return false;
|
||||
|
||||
int expansion = atoi(szExp); //get int anyway (0 if error)
|
||||
int expansion = atoi(exp); //get int anyway (0 if error)
|
||||
if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION))
|
||||
return false;
|
||||
|
||||
// No SQL injection
|
||||
LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, account_id);
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_SETADDON, account_name.c_str(), account_id, expansion);
|
||||
LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, accountId);
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_SETADDON, accountName.c_str(), accountId, expansion);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleAccountSetGmLevelCommand(ChatHandler* handler, const char *args)
|
||||
static bool HandleAccountSetGmLevelCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
@@ -433,16 +430,16 @@ public:
|
||||
// handler->getSession() == NULL only for console
|
||||
targetAccountId = (isAccountNameGiven) ? AccountMgr::GetId(targetAccountName) : handler->getSelectedPlayer()->GetSession()->GetAccountId();
|
||||
int32 gmRealmID = (isAccountNameGiven) ? atoi(arg3) : atoi(arg2);
|
||||
uint32 plSecurity;
|
||||
uint32 playerSecurity;
|
||||
if (handler->GetSession())
|
||||
plSecurity = AccountMgr::GetSecurity(handler->GetSession()->GetAccountId(), gmRealmID);
|
||||
playerSecurity = AccountMgr::GetSecurity(handler->GetSession()->GetAccountId(), gmRealmID);
|
||||
else
|
||||
plSecurity = SEC_CONSOLE;
|
||||
playerSecurity = 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 = AccountMgr::GetSecurity(targetAccountId, gmRealmID);
|
||||
if (targetSecurity >= plSecurity || gm >= plSecurity)
|
||||
if (targetSecurity >= playerSecurity || gm >= playerSecurity)
|
||||
{
|
||||
handler->SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
|
||||
handler->SetSentErrorMessage(true);
|
||||
@@ -450,7 +447,7 @@ public:
|
||||
}
|
||||
|
||||
// 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 && !AccountMgr::IsConsoleAccount(plSecurity))
|
||||
if (gmRealmID == -1 && !AccountMgr::IsConsoleAccount(playerSecurity))
|
||||
{
|
||||
QueryResult result = LoginDatabase.PQuery("SELECT * FROM account_access WHERE id = '%u' AND gmlevel > '%d'", targetAccountId, gm);
|
||||
if (result)
|
||||
@@ -477,72 +474,74 @@ public:
|
||||
|
||||
if (gm != 0)
|
||||
LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u', '%d', '%d')", targetAccountId, gm, realmID);
|
||||
|
||||
handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Set password for account
|
||||
static bool HandleAccountSetPasswordCommand(ChatHandler* handler, const char *args)
|
||||
static bool HandleAccountSetPasswordCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
///- Get the command line arguments
|
||||
char *szAccount = strtok ((char*)args, " ");
|
||||
char *szPassword1 = strtok (NULL, " ");
|
||||
char *szPassword2 = strtok (NULL, " ");
|
||||
char* account = strtok((char*)args, " ");
|
||||
char* password = strtok(NULL, " ");
|
||||
char* passwordConfirmation = strtok(NULL, " ");
|
||||
|
||||
if (!szAccount||!szPassword1 || !szPassword2)
|
||||
if (!account || !password || !passwordConfirmation)
|
||||
return false;
|
||||
|
||||
std::string account_name = szAccount;
|
||||
if (!AccountMgr::normalizeString(account_name))
|
||||
std::string accountName = account;
|
||||
if (!AccountMgr::normalizeString(accountName))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str());
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 targetAccountId = AccountMgr::GetId(account_name);
|
||||
uint32 targetAccountId = AccountMgr::GetId(accountName);
|
||||
if (!targetAccountId)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str());
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// can set password only for target with less security
|
||||
/// This is also reject self apply in fact
|
||||
if (handler->HasLowerSecurityAccount (NULL, targetAccountId, true))
|
||||
if (handler->HasLowerSecurityAccount(NULL, targetAccountId, true))
|
||||
return false;
|
||||
|
||||
if (strcmp(szPassword1, szPassword2))
|
||||
if (strcmp(password, passwordConfirmation))
|
||||
{
|
||||
handler->SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH);
|
||||
handler->SetSentErrorMessage (true);
|
||||
handler->SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
AccountOpResult result = AccountMgr::ChangePassword(targetAccountId, szPassword1);
|
||||
AccountOpResult result = AccountMgr::ChangePassword(targetAccountId, password);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case AOR_OK:
|
||||
handler->SendSysMessage(LANG_COMMAND_PASSWORD);
|
||||
break;
|
||||
case AOR_NAME_NOT_EXIST:
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
case AOR_PASS_TOO_LONG:
|
||||
handler->SendSysMessage(LANG_PASSWORD_TOO_LONG);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
default:
|
||||
handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
case AOR_OK:
|
||||
handler->SendSysMessage(LANG_COMMAND_PASSWORD);
|
||||
break;
|
||||
case AOR_NAME_NOT_EXIST:
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
case AOR_PASS_TOO_LONG:
|
||||
handler->SendSysMessage(LANG_PASSWORD_TOO_LONG);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
default:
|
||||
handler->SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user