Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About lambda error handling: addqueryholdercallback (characterdatabase. Delayqueryholder (holder)) #11158

Closed
GoMateoGo opened this issue Mar 26, 2022 · 3 comments

Comments

@GoMateoGo
Copy link

GoMateoGo commented Mar 26, 2022

The purpose is to simulate players logging in to the game, It was normal until it was updated: #5611

Through breakpoint debugging, I can get the account and password normally, but the new lambad callback doesn't work properly

Thank you in advance for your help! I wish you all the best!

Below is my code:

`
bool FakeBot::FakePlayerLogin()
{
SessionMap const& Sessions = sWorld->GetAllSessions();
for (auto const& AccountMap : m_AllAccount)
{
uint32 AccountId = AccountMap.first;
if (Sessions.find(AccountId) != Sessions.end())
continue;

    if (m_BotAccount[AccountId].size() < AccountMax)
    {
        for (auto const& PlayerGuid : AccountMap.second)
        {

            ObjectGuid PGUID = ObjectGuid(HighGuid::Player, PlayerGuid);

            Player* FakeBot = ObjectAccessor::FindPlayer(PGUID);

            if (FakeBot && FakeBot->IsInWorld())
                continue;

            auto const itr = m_BotPlayers.find(PlayerGuid);
            if (itr != m_BotPlayers.end())
                continue;

            WorldSession* FakerSession = new WorldSession(AccountId, "", nullptr, SEC_PLAYER, 2, time(NULL), LOCALE_zhCN, 0, false, true, 0);
            if (!FakerSession)
            {
                delete FakerSession;
                continue;
            }

            FakerSession->SetplayerLoading(true);
           
            std::shared_ptr<LoginQueryHolder> holder = std::make_shared<LoginQueryHolder>(AccountId, PGUID);

            if (!holder->Initialize())
            {
                FakerSession->SetplayerLoading(false);
                continue;
            }

            //The new version is handled, but he has some problems
            FakerSession->AddQueryHolderCallback(CharacterDatabase.DelayQueryHolder(holder)).AfterComplete([FakerSession](SQLQueryHolderBase const& holder)
            {
                    FakerSession->HandlePlayerLoginFromDB(static_cast<LoginQueryHolder const&>(holder));
            });


            //Handling of old versions
            //LoginQueryHolder* holder = new LoginQueryHolder(AccountId, PGUID);
            //if (!holder->Initialize())
            //{
            //    delete holder;
            //    FakerSession->SetplayerLoading(false);
            //    continue;
            //}

            //auto NowLoginCallback = CharacterDatabase.DelayQueryHolder((CharacterDatabaseQueryHolder const&)(Holder));
            //CharacterDatabaseQueryHolder* ParamHolder;
            //NowLoginCallback.get(ParamHolder);
            //FakerSession->HandlePlayerLoginFromDB((LoginQueryHolder&)ParamHolder);

            Player* GameBot = FakerSession->GetPlayer();
            if (!GameBot)
            {
                 LOG_ERROR("Custom Tab","Fakeer << Guid: %u AccId: %u LoadError", PlayerGuid, AccountId);
                FakerSession->LogoutPlayer(false);
                delete FakerSession;
                continue;
            }
            return true;
        }
    }
}

return false;

}`

@Bogir
Copy link
Contributor

Bogir commented Mar 26, 2022

изображение

the methods you need have not changed much

@GoMateoGo
Copy link
Author

изображение

the methods you need have not changed much

You're great. Can you tell me what to do?

@Kitzunu
Copy link
Member

Kitzunu commented Mar 26, 2022

Do not ignore the issue template. Reopen a new issue and follow the template.

@Kitzunu Kitzunu closed this as completed Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants