Clean up level0.cpp and return proper errormessages (fix by ogeraisi)
Closes issue #286 --HG-- branch : trunk
This commit is contained in:
@@ -14636,7 +14636,7 @@ INSERT INTO `trinity_string` (`entry`,`content_default`,`content_loc1`,`content_
|
|||||||
(24, 'You used it recently.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
(24, 'You used it recently.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||||
(25, 'Password not changed (unknown error)!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
(25, 'Password not changed (unknown error)!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||||
(26, 'The password was changed', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
(26, 'The password was changed', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||||
(27, 'The new passwords do not match or the old password is wrong', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
(27, 'The old password is wrong', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||||
(28, 'Your account is now locked.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
(28, 'Your account is now locked.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||||
(29, 'Your account is now unlocked.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
(29, 'Your account is now unlocked.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||||
(30, ', rank ', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
(30, ', rank ', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||||
@@ -14671,6 +14671,7 @@ INSERT INTO `trinity_string` (`entry`,`content_default`,`content_loc1`,`content_
|
|||||||
(59, 'Using creature EventAI: %s', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
(59, 'Using creature EventAI: %s', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||||
(60, 'Online players: %u (max: %u)', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
(60, 'Online players: %u (max: %u)', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||||
(61, 'Up to %u expansion allowed now.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
(61, 'Up to %u expansion allowed now.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||||
|
(62, 'One on more parameters have incorrect values', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||||
(100, 'Global notify: ', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
(100, 'Global notify: ', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||||
(101, 'Map: %u (%s) Zone: %u (%s) Area: %u (%s) Phase: %u\nX: %f Y: %f Z: %f Orientation: %f\ngrid[%u,%u]cell[%u,%u] InstanceID: %u\n ZoneX: %f ZoneY: %f\nGroundZ: %f FloorZ: %f Have height data (Map: %u VMap: %u)', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
(101, 'Map: %u (%s) Zone: %u (%s) Area: %u (%s) Phase: %u\nX: %f Y: %f Z: %f Orientation: %f\ngrid[%u,%u]cell[%u,%u] InstanceID: %u\n ZoneX: %f ZoneY: %f\nGroundZ: %f FloorZ: %f Have height data (Map: %u VMap: %u)', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||||
(102, '%s is already being teleported.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
(102, '%s is already being teleported.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
-- UPDATE so we don't kill customized locale strings if user has any
|
||||||
|
UPDATE `trinity_string` SET `content_default`='The old password is wrong' WHERE `entry`=27;
|
||||||
|
-- INSERT as this string has not been used before
|
||||||
|
INSERT INTO `trinity_string` VALUES (62, 'One on more parameters have incorrect values', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
@@ -87,7 +87,7 @@ bool ChatHandler::HandleStartCommand(const char* /*args*/)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// cast spell Stuck
|
// cast spell Stuck
|
||||||
chr->CastSpell(chr,7355,false);
|
chr->CastSpell(chr, 7355, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,14 +103,6 @@ bool ChatHandler::HandleServerInfoCommand(const char* /*args*/)
|
|||||||
uint32 updateTime = sWorld.GetUpdateTime();
|
uint32 updateTime = sWorld.GetUpdateTime();
|
||||||
|
|
||||||
PSendSysMessage(_FULLVERSION);
|
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_PLAYERS, PlayersNum, MaxPlayersNum);
|
||||||
PSendSysMessage(LANG_CONNECTED_USERS, activeClientsNum, maxActiveClientsNum, queuedClientsNum, maxQueuedClientsNum);
|
PSendSysMessage(LANG_CONNECTED_USERS, activeClientsNum, maxActiveClientsNum, queuedClientsNum, maxQueuedClientsNum);
|
||||||
PSendSysMessage(LANG_UPTIME, uptime.c_str());
|
PSendSysMessage(LANG_UPTIME, uptime.c_str());
|
||||||
@@ -143,9 +135,9 @@ bool ChatHandler::HandleDismountCommand(const char* /*args*/)
|
|||||||
|
|
||||||
bool ChatHandler::HandleSaveCommand(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)
|
if (m_session->GetSecurity() > SEC_PLAYER)
|
||||||
{
|
{
|
||||||
player->SaveToDB();
|
player->SaveToDB();
|
||||||
@@ -153,7 +145,7 @@ bool ChatHandler::HandleSaveCommand(const char* /*args*/)
|
|||||||
return true;
|
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);
|
uint32 save_interval = sWorld.getConfig(CONFIG_INTERVAL_SAVE);
|
||||||
if ((save_interval == 0 || save_interval > 20*IN_MILLISECONDS && player->GetSaveTimer() <= save_interval - 20*IN_MILLISECONDS))
|
if ((save_interval == 0 || save_interval > 20*IN_MILLISECONDS && player->GetSaveTimer() <= save_interval - 20*IN_MILLISECONDS))
|
||||||
player->SaveToDB();
|
player->SaveToDB();
|
||||||
@@ -192,35 +184,42 @@ bool ChatHandler::HandleGMListIngameCommand(const char* /*args*/)
|
|||||||
bool ChatHandler::HandleAccountPasswordCommand(const char* args)
|
bool ChatHandler::HandleAccountPasswordCommand(const char* args)
|
||||||
{
|
{
|
||||||
if (!*args)
|
if (!*args)
|
||||||
|
{
|
||||||
|
SendSysMessage(LANG_CMD_SYNTAX);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
char *old_pass = strtok ((char*)args, " ");
|
char *old_pass = strtok((char*)args, " ");
|
||||||
char *new_pass = strtok (NULL, " ");
|
char *new_pass = strtok(NULL, " ");
|
||||||
char *new_pass_c = strtok (NULL, " ");
|
char *new_pass_c = strtok(NULL, " ");
|
||||||
|
|
||||||
if (!old_pass || !new_pass || !new_pass_c)
|
if (!old_pass || !new_pass || !new_pass_c)
|
||||||
|
{
|
||||||
|
SendSysMessage(LANG_CMD_SYNTAX);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::string password_old = old_pass;
|
std::string password_old = old_pass;
|
||||||
std::string password_new = new_pass;
|
std::string password_new = new_pass;
|
||||||
std::string password_new_c = new_pass_c;
|
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);
|
SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD);
|
||||||
SetSentErrorMessage (true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!accmgr.CheckPassword (m_session->GetAccountId(), password_old))
|
if (strcmp(new_pass, new_pass_c) != 0)
|
||||||
{
|
{
|
||||||
SendSysMessage (LANG_COMMAND_WRONGOLDPASSWORD);
|
SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH);
|
||||||
SetSentErrorMessage (true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountOpResult result = accmgr.ChangePassword(m_session->GetAccountId(), password_new);
|
AccountOpResult result = accmgr.ChangePassword(m_session->GetAccountId(), password_new);
|
||||||
|
|
||||||
switch(result)
|
switch(result)
|
||||||
{
|
{
|
||||||
case AOR_OK:
|
case AOR_OK:
|
||||||
@@ -230,7 +229,6 @@ bool ChatHandler::HandleAccountPasswordCommand(const char* args)
|
|||||||
SendSysMessage(LANG_PASSWORD_TOO_LONG);
|
SendSysMessage(LANG_PASSWORD_TOO_LONG);
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
case AOR_NAME_NOT_EXIST: // not possible case, don't want get account name for output
|
|
||||||
default:
|
default:
|
||||||
SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
|
SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
@@ -243,15 +241,23 @@ bool ChatHandler::HandleAccountPasswordCommand(const char* args)
|
|||||||
bool ChatHandler::HandleAccountAddonCommand(const char* args)
|
bool ChatHandler::HandleAccountAddonCommand(const char* args)
|
||||||
{
|
{
|
||||||
if (!*args)
|
if (!*args)
|
||||||
|
{
|
||||||
|
SendSysMessage(LANG_CMD_SYNTAX);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
char *szExp = strtok((char*)args," ");
|
char *szExp = strtok((char*)args, " ");
|
||||||
|
|
||||||
uint32 account_id = m_session->GetAccountId();
|
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))
|
if (expansion < 0 || expansion > sWorld.getConfig(CONFIG_EXPANSION))
|
||||||
return false;
|
{
|
||||||
|
SendSysMessage(LANG_IMPROPER_VALUE);
|
||||||
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// No SQL injection
|
// 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, account_id);
|
||||||
@@ -264,7 +270,8 @@ bool ChatHandler::HandleAccountLockCommand(const char* args)
|
|||||||
if (!*args)
|
if (!*args)
|
||||||
{
|
{
|
||||||
SendSysMessage(LANG_USE_BOL);
|
SendSysMessage(LANG_USE_BOL);
|
||||||
return true;
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string argstr = (char*)args;
|
std::string argstr = (char*)args;
|
||||||
@@ -283,7 +290,8 @@ bool ChatHandler::HandleAccountLockCommand(const char* args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SendSysMessage(LANG_USE_BOL);
|
SendSysMessage(LANG_USE_BOL);
|
||||||
return true;
|
SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Display the 'Message of the day' for the realm
|
/// Display the 'Message of the day' for the realm
|
||||||
|
|||||||
@@ -87,7 +87,8 @@ enum TrinityStrings
|
|||||||
LANG_USING_EVENT_AI = 59,
|
LANG_USING_EVENT_AI = 59,
|
||||||
LANG_CONNECTED_PLAYERS = 60,
|
LANG_CONNECTED_PLAYERS = 60,
|
||||||
LANG_ACCOUNT_ADDON = 61,
|
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
|
// level 1 chat
|
||||||
LANG_GLOBAL_NOTIFY = 100,
|
LANG_GLOBAL_NOTIFY = 100,
|
||||||
|
|||||||
Reference in New Issue
Block a user