Core/Scripts: Reinstate commandscripts, now with extra bling and working commands (and yes, we did test it thoroughly this time)

Thanks to Paradox for sorting the commandscripts and chanhandlers out to work as they were intentionally ment to be like.

--HG--
branch : trunk
This commit is contained in:
click
2010-11-12 20:47:03 +01:00
parent 43d8a64232
commit e22426c7c0
14 changed files with 105 additions and 6487 deletions
-148
View File
@@ -52,13 +52,6 @@ bool ChatHandler::HandleCommandsCommand(const char* /*args*/)
return true;
}
bool ChatHandler::HandleAccountCommand(const char* /*args*/)
{
AccountTypes gmlevel = m_session->GetSecurity();
PSendSysMessage(LANG_ACCOUNT_LEVEL, uint32(gmlevel));
return true;
}
bool ChatHandler::HandleStartCommand(const char* /*args*/)
{
Player *chr = m_session->GetPlayer();
@@ -151,147 +144,6 @@ bool ChatHandler::HandleSaveCommand(const char* /*args*/)
return true;
}
bool ChatHandler::HandleGMListIngameCommand(const char* /*args*/)
{
bool first = true;
ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, *HashMapHolder<Player>::GetLock(), true);
HashMapHolder<Player>::MapType &m = sObjectAccessor.GetPlayers();
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
{
AccountTypes itr_sec = itr->second->GetSession()->GetSecurity();
if ((itr->second->isGameMaster() || (itr_sec > SEC_PLAYER && itr_sec <= AccountTypes(sWorld.getIntConfig(CONFIG_GM_LEVEL_IN_GM_LIST)))) &&
(!m_session || itr->second->IsVisibleGloballyFor(m_session->GetPlayer())))
{
if (first)
{
SendSysMessage(LANG_GMS_ON_SRV);
first = false;
}
SendSysMessage(GetNameLink(itr->second).c_str());
}
}
if (first)
SendSysMessage(LANG_GMS_NOT_LOGGED);
return true;
}
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, " ");
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 (!sAccountMgr.CheckPassword(m_session->GetAccountId(), password_old))
{
SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD);
SetSentErrorMessage(true);
return false;
}
if (strcmp(new_pass, new_pass_c) != 0)
{
SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH);
SetSentErrorMessage(true);
return false;
}
AccountOpResult result = sAccountMgr.ChangePassword(m_session->GetAccountId(), password_new);
switch(result)
{
case AOR_OK:
SendSysMessage(LANG_COMMAND_PASSWORD);
break;
case AOR_PASS_TOO_LONG:
SendSysMessage(LANG_PASSWORD_TOO_LONG);
SetSentErrorMessage(true);
return false;
default:
SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
SetSentErrorMessage(true);
return false;
}
return true;
}
bool ChatHandler::HandleAccountAddonCommand(const char* args)
{
if (!*args)
{
SendSysMessage(LANG_CMD_SYNTAX);
SetSentErrorMessage(true);
return false;
}
char *szExp = strtok((char*)args, " ");
uint32 account_id = m_session->GetAccountId();
int expansion = atoi(szExp); //get int anyway (0 if error)
if (expansion < 0 || uint8(expansion) > sWorld.getIntConfig(CONFIG_EXPANSION))
{
SendSysMessage(LANG_IMPROPER_VALUE);
SetSentErrorMessage(true);
return false;
}
// No SQL injection
LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, account_id);
PSendSysMessage(LANG_ACCOUNT_ADDON, expansion);
return true;
}
bool ChatHandler::HandleAccountLockCommand(const char* args)
{
if (!*args)
{
SendSysMessage(LANG_USE_BOL);
SetSentErrorMessage(true);
return false;
}
std::string argstr = (char*)args;
if (argstr == "on")
{
LoginDatabase.PExecute("UPDATE account SET locked = '1' WHERE id = '%d'",m_session->GetAccountId());
PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
return true;
}
if (argstr == "off")
{
LoginDatabase.PExecute("UPDATE account SET locked = '0' WHERE id = '%d'",m_session->GetAccountId());
PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
return true;
}
SendSysMessage(LANG_USE_BOL);
SetSentErrorMessage(true);
return false;
}
/// Display the 'Message of the day' for the realm
bool ChatHandler::HandleServerMotdCommand(const char* /*args*/)
{