Clean up level0.cpp and return proper errormessages (fix by ogeraisi)
Closes issue #286 --HG-- branch : trunk
This commit is contained in:
@@ -87,7 +87,7 @@ bool ChatHandler::HandleStartCommand(const char* /*args*/)
|
||||
}
|
||||
|
||||
// cast spell Stuck
|
||||
chr->CastSpell(chr,7355,false);
|
||||
chr->CastSpell(chr, 7355, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -103,14 +103,6 @@ bool ChatHandler::HandleServerInfoCommand(const char* /*args*/)
|
||||
uint32 updateTime = sWorld.GetUpdateTime();
|
||||
|
||||
PSendSysMessage(_FULLVERSION);
|
||||
//if (m_session)
|
||||
// full = _FULLVERSION(REVISION_DATE,REVISION_TIME,"|cffffffff|Hurl:" REVISION_ID "|h" REVISION_ID "|h|r");
|
||||
//else
|
||||
// full = _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_ID);
|
||||
|
||||
//SendSysMessage(full);
|
||||
//PSendSysMessage(LANG_USING_WORLD_DB,sWorld.GetDBVersion());
|
||||
//PSendSysMessage(LANG_USING_EVENT_AI,sWorld.GetCreatureEventAIVersion());
|
||||
PSendSysMessage(LANG_CONNECTED_PLAYERS, PlayersNum, MaxPlayersNum);
|
||||
PSendSysMessage(LANG_CONNECTED_USERS, activeClientsNum, maxActiveClientsNum, queuedClientsNum, maxQueuedClientsNum);
|
||||
PSendSysMessage(LANG_UPTIME, uptime.c_str());
|
||||
@@ -143,9 +135,9 @@ bool ChatHandler::HandleDismountCommand(const char* /*args*/)
|
||||
|
||||
bool ChatHandler::HandleSaveCommand(const char* /*args*/)
|
||||
{
|
||||
Player *player=m_session->GetPlayer();
|
||||
Player *player = m_session->GetPlayer();
|
||||
|
||||
// save GM account without delay and output message (testing, etc)
|
||||
// save GM account without delay and output message
|
||||
if (m_session->GetSecurity() > SEC_PLAYER)
|
||||
{
|
||||
player->SaveToDB();
|
||||
@@ -153,7 +145,7 @@ bool ChatHandler::HandleSaveCommand(const char* /*args*/)
|
||||
return true;
|
||||
}
|
||||
|
||||
// save or plan save after 20 sec (logout delay) if current next save time more this value and _not_ output any messages to prevent cheat planning
|
||||
// save if the player has last been saved over 20 seconds ago
|
||||
uint32 save_interval = sWorld.getConfig(CONFIG_INTERVAL_SAVE);
|
||||
if ((save_interval == 0 || save_interval > 20*IN_MILLISECONDS && player->GetSaveTimer() <= save_interval - 20*IN_MILLISECONDS))
|
||||
player->SaveToDB();
|
||||
@@ -192,35 +184,42 @@ bool ChatHandler::HandleGMListIngameCommand(const char* /*args*/)
|
||||
bool ChatHandler::HandleAccountPasswordCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
{
|
||||
SendSysMessage(LANG_CMD_SYNTAX);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char *old_pass = strtok ((char*)args, " ");
|
||||
char *new_pass = strtok (NULL, " ");
|
||||
char *new_pass_c = strtok (NULL, " ");
|
||||
char *old_pass = strtok((char*)args, " ");
|
||||
char *new_pass = strtok(NULL, " ");
|
||||
char *new_pass_c = strtok(NULL, " ");
|
||||
|
||||
if (!old_pass || !new_pass || !new_pass_c)
|
||||
{
|
||||
SendSysMessage(LANG_CMD_SYNTAX);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string password_old = old_pass;
|
||||
std::string password_new = new_pass;
|
||||
std::string password_new_c = new_pass_c;
|
||||
|
||||
if (strcmp(new_pass, new_pass_c) != 0)
|
||||
if (!accmgr.CheckPassword(m_session->GetAccountId(), password_old))
|
||||
{
|
||||
SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH);
|
||||
SetSentErrorMessage (true);
|
||||
SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!accmgr.CheckPassword (m_session->GetAccountId(), password_old))
|
||||
if (strcmp(new_pass, new_pass_c) != 0)
|
||||
{
|
||||
SendSysMessage (LANG_COMMAND_WRONGOLDPASSWORD);
|
||||
SetSentErrorMessage (true);
|
||||
SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
AccountOpResult result = accmgr.ChangePassword(m_session->GetAccountId(), password_new);
|
||||
|
||||
switch(result)
|
||||
{
|
||||
case AOR_OK:
|
||||
@@ -230,7 +229,6 @@ bool ChatHandler::HandleAccountPasswordCommand(const char* args)
|
||||
SendSysMessage(LANG_PASSWORD_TOO_LONG);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
case AOR_NAME_NOT_EXIST: // not possible case, don't want get account name for output
|
||||
default:
|
||||
SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
|
||||
SetSentErrorMessage(true);
|
||||
@@ -243,15 +241,23 @@ bool ChatHandler::HandleAccountPasswordCommand(const char* args)
|
||||
bool ChatHandler::HandleAccountAddonCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
{
|
||||
SendSysMessage(LANG_CMD_SYNTAX);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char *szExp = strtok((char*)args," ");
|
||||
char *szExp = strtok((char*)args, " ");
|
||||
|
||||
uint32 account_id = m_session->GetAccountId();
|
||||
|
||||
int expansion=atoi(szExp); //get int anyway (0 if error)
|
||||
int expansion = atoi(szExp); //get int anyway (0 if error)
|
||||
if (expansion < 0 || expansion > sWorld.getConfig(CONFIG_EXPANSION))
|
||||
return false;
|
||||
{
|
||||
SendSysMessage(LANG_IMPROPER_VALUE);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// No SQL injection
|
||||
LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, account_id);
|
||||
@@ -264,7 +270,8 @@ bool ChatHandler::HandleAccountLockCommand(const char* args)
|
||||
if (!*args)
|
||||
{
|
||||
SendSysMessage(LANG_USE_BOL);
|
||||
return true;
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string argstr = (char*)args;
|
||||
@@ -283,7 +290,8 @@ bool ChatHandler::HandleAccountLockCommand(const char* args)
|
||||
}
|
||||
|
||||
SendSysMessage(LANG_USE_BOL);
|
||||
return true;
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Display the 'Message of the day' for the realm
|
||||
|
||||
@@ -87,7 +87,8 @@ enum TrinityStrings
|
||||
LANG_USING_EVENT_AI = 59,
|
||||
LANG_CONNECTED_PLAYERS = 60,
|
||||
LANG_ACCOUNT_ADDON = 61,
|
||||
// Room for more level 0 62-99 not used
|
||||
LANG_IMPROPER_VALUE = 62,
|
||||
// Room for more level 0 63-99 not used
|
||||
|
||||
// level 1 chat
|
||||
LANG_GLOBAL_NOTIFY = 100,
|
||||
|
||||
Reference in New Issue
Block a user