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

[AC][Crash] another crash in GetNextBGTravelNode() #616

Open
1 task done
Blandyoung opened this issue Aug 27, 2023 · 7 comments
Open
1 task done

[AC][Crash] another crash in GetNextBGTravelNode() #616

Blandyoung opened this issue Aug 27, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@Blandyoung
Copy link

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that my issue may get closed without notice if I intentionally remove or skip any mandatory* field

Current behaviour

It is still a problem during the attack phase of the AV boss

Possible causes of errors

  1. There is no available path between the curNode node and the mineWP node, which makes it impossible to calculate the shortest path.

  2. There is an available path between the curNode node and the mineWP node, but the calculated shortest path is empty due to some reasons.

Expected behaviour

No response

Crashlog

https://gist.github.com/Blandyoung/81048c1c8734684875a9e4fa0f38a3ca

Steps to reproduce the problem

I am not sure about the steps to reproduce, but theoretically, they will appear in the final stage of the battle in the Alterac Valley

TrinityCore or AzerothCore

AzerothCore

Core rev. hash/commit

AzerothCore 2023-2-27

Operating system

winserver2019

@Blandyoung Blandyoung added the bug Something isn't working label Aug 27, 2023
@trickerer
Copy link
Owner

It looks like someone did manage to lure the mine boss to a different area id (out of the mine or maybe under the textures somewhere), so mineWP was never found (assertion failed).
This is going to be a tricky one.

P.S.
Didn't expect this to happen, that's for sure. Err... But did throw in an assertion there anyway, just in case I guess.

@Blandyoung
Copy link
Author

We never know how players will play XD

@Blandyoung
Copy link
Author

https://gist.github.com/Blandyoung/b7b18797ef66b56482595c9cec7d72ae

It seems to be the same problem

@Blandyoung
Copy link
Author

This is my temporary solution

Remove the following code located in bot_ai.cpp

//Last thing: try to capture the mines (2 people at most)
for (auto const& p : { std::pair{TEAM_ALLIANCE, std::array{AV_CPLACE_MINE_N_3, AV_CPLACE_MINE_S_3}}, std::pair{TEAM_HORDE, std::array{AV_CPLACE_MINE_S_3, AV_CPLACE_MINE_N_3}} })
{
if (myTeamId != p.first)
continue;

            static const std::function mine_pred = [](WanderNode const* wp) { return wp->HasFlag(BotWPFlags::BOTWP_FLAG_BG_MISC_OBJECTIVE_1); };

            for (BG_AV_CreaturePlace sptype : p.second)
            {
                Creature const* mboss = ASSERT_NOTNULL(av->GetBGCreature(uint32(sptype)));
                if (mboss->IsAlive() && !mboss->IsInCombat() && me->IsWithinDist2d(mboss, SIZE_OF_GRIDS * 0.75f))
                {
                    WanderNode const* mineWP = ASSERT_NOTNULL(WanderNode::FindInAreaWPs(mboss->GetAreaId(), mine_pred));
                    WanderNode const* mineLink = mineWP->GetLinks().front();
                    NodeList mlinks = curNode->GetShortestPathLinks(mineWP, links);
                    if (!mlinks.empty())
                    {
                        uint32 attackers_count = 0;
                        for (Unit const* member : team_members)
                        {
                            if (member == me || !member->IsAlive() || !member->IsNPCBot())
                                continue;
                            WanderNode const* mwp = member->ToCreature()->GetBotAI()->_travel_node_cur;
                            if (!mwp)
                                continue;
                            if (mwp == mineWP || mwp == mineLink || member->GetVictim() == mboss ||
                                std::find(mlinks.cbegin(), mlinks.cend(), mwp) != mlinks.cend() ||
                                (!mwp->GetLinks().empty() && std::find(mwp->GetLinks().cbegin(), mwp->GetLinks().cend(), mineLink) != mwp->GetLinks().cend()))
                                ++attackers_count;
                        }
                        if (attackers_count <= 1)
                        {
                            LOG_DEBUG("npcbots", "Bot {} {} team {} goes for a mine! Cur node: {} {}",
                                me->GetName().c_str(), me->GetEntry(), uint32(myTeamId), curNode->GetWPId(), curNode->GetName().c_str());
                            return mlinks.size() == 1u ? mlinks.front() : Acore::Containers::SelectRandomContainerElement(mlinks);
                        }
                    }
                }
            }
        }

@kissingers
Copy link

kissingers commented May 18, 2024

It seems FindInAreaWPs might return nullptr, so if not find, might need need skip ones?

WanderNode* WanderNode::FindInAreaWPs(uint32 areaId, node_check_ftype_c const& pred)
{
lock_type lock(*GetLock());
auto cim = ALL_WPS_PER_AREA.find(areaId);
if (cim == ALL_WPS_PER_AREA.cend())
return nullptr;
auto ci = std::find_if(ALL_WPS_PER_AREA.at(areaId).cbegin(), ALL_WPS_PER_AREA.at(areaId).cend(), pred);
return ci == ALL_WPS_PER_AREA.at(areaId).cend() ? nullptr : *ci;
}

@kissingers
Copy link

I add all if (!bossWP) return or if (bossWP && other) judge after call FindInAreaWPs, till now no crash ,I will test more time and feedback

@trickerer
Copy link
Owner

trickerer/AzerothCore-wotlk-with-NPCBots@3c092a7 should be enough to tempfix this but the whole AV wanderer bot routine needs massive adjustments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants