示例#1
0
文件: Level0.cpp 项目: mynew3/server
bool ChatHandler::HandleAccountPasswordCommand(char* args)
{
    // allow use from RA, but not from console (not have associated account id)
    if (!GetAccountId())
    {
        SendSysMessage(LANG_RA_ONLY_COMMAND);
        SetSentErrorMessage(true);
        return false;
    }

    // allow or quoted string with possible spaces or literal without spaces
    char* old_pass = ExtractQuotedOrLiteralArg(&args);
    char* new_pass = ExtractQuotedOrLiteralArg(&args);
    char* new_pass_c = ExtractQuotedOrLiteralArg(&args);

    if (!old_pass || !new_pass || !new_pass_c)
        return false;

    std::string password_old = old_pass;
    std::string password_new = new_pass;
    std::string password_new_c = new_pass_c;

    if (password_new != password_new_c)
    {
        SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH);
        SetSentErrorMessage(true);
        return false;
    }

    if (!sAccountMgr.CheckPassword(GetAccountId(), password_old))
    {
        SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD);
        SetSentErrorMessage(true);
        return false;
    }

    AccountOpResult result = sAccountMgr.ChangePassword(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;
        case AOR_NAME_NOT_EXIST:                            // not possible case, don't want get account name for output
        default:
            SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
            SetSentErrorMessage(true);
            return false;
    }

    // OK, but avoid normal report for hide passwords, but log use command for anyone
    LogCommand(".account password *** *** ***");
    SetSentErrorMessage(true);
    return false;
}
示例#2
0
文件: Level0.cpp 项目: mynew3/server
bool ChatHandler::HandleWorldChatCommand(char* args)
{
    Player* pPlayer = m_session->GetPlayer();
    if (!pPlayer)
        return false;

    char *c_msg = ExtractQuotedOrLiteralArg(&args);
    if (!c_msg)
        return false;

    std::string s_msg = c_msg;
    if (s_msg.empty())
        return false;

    std::string message = BuildWorldChatMsg(s_msg);
    PSendGlobalSysMessage(message.c_str());

    if (m_session->GetSecurity() > SEC_PLAYER)
    {
        WorldPacket data(SMSG_NOTIFICATION, (message.size()+1));
        data << message;
        sWorld.SendGlobalMessage(&data);
    }
    return true;
}
示例#3
0
bool ChatHandler::HandleBGStopCommand(char* args)
{
    Player* pPlayer = m_session->GetPlayer();
    BattleGround* pBattleGround = pPlayer->GetBattleGround();

    Team WinTeam = TEAM_NONE;
    char* StrTeam = ExtractQuotedOrLiteralArg(&args);
    if (!StrTeam)
        WinTeam = pPlayer->GetTeam();
    else
    {
        std::string TeamStr(StrTeam);
        for (auto& i : TeamStr)
            i = std::towlower(i);

        if (TeamStr.find("alliance") != std::string::npos ||
            TeamStr.find("ally") != std::string::npos)
            WinTeam = ALLIANCE;
        else if (TeamStr.find("horde") != std::string::npos)
            WinTeam = HORDE;
        else
            WinTeam = pPlayer->GetTeam();
    }

    if (pPlayer && pBattleGround)
        pBattleGround->EndBattleGround(WinTeam);

    PSendSysMessage("Battleground was stopped instantly.");

    return true;
}
示例#4
0
/// Create an account
bool ChatHandler::HandleAccountCreateCommand(char* args)
{
    ///- %Parse the command line arguments
    char* szAcc = ExtractQuotedOrLiteralArg(&args);
    char* szPassword = ExtractQuotedOrLiteralArg(&args);
    if (!szAcc || !szPassword)
        return false;

    // normalized in accmgr.CreateAccount
    std::string account_name = szAcc;
    std::string password = szPassword;

    AccountOpResult result;
    uint32 expansion = 0;
    if (ExtractUInt32(&args, expansion))
        result = sAccountMgr.CreateAccount(account_name, password, expansion);
    else
        result = sAccountMgr.CreateAccount(account_name, password);
    switch (result)
    {
        case AOR_OK:
            PSendSysMessage(LANG_ACCOUNT_CREATED, account_name.c_str());
            break;
        case AOR_NAME_TOO_LONG:
            SendSysMessage(LANG_ACCOUNT_TOO_LONG);
            SetSentErrorMessage(true);
            return false;
        case AOR_NAME_ALREDY_EXIST:
            SendSysMessage(LANG_ACCOUNT_ALREADY_EXIST);
            SetSentErrorMessage(true);
            return false;
        case AOR_DB_INTERNAL_ERROR:
            PSendSysMessage(LANG_ACCOUNT_NOT_CREATED_SQL_ERROR, account_name.c_str());
            SetSentErrorMessage(true);
            return false;
        default:
            PSendSysMessage(LANG_ACCOUNT_NOT_CREATED, account_name.c_str());
            SetSentErrorMessage(true);
            return false;
    }

    return true;
}