Trinity-Bots icon indicating copy to clipboard operation
Trinity-Bots copied to clipboard

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

Open Blandyoung opened this issue 1 year ago • 7 comments

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • [X] 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 avatar Aug 27 '23 05:08 Blandyoung

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.

trickerer avatar Aug 27 '23 06:08 trickerer

We never know how players will play XD

Blandyoung avatar Aug 27 '23 08:08 Blandyoung

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

It seems to be the same problem

Blandyoung avatar Aug 27 '23 14:08 Blandyoung

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);
                        }
                    }
                }
            }
        }

Blandyoung avatar Aug 28 '23 12:08 Blandyoung

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 avatar May 18 '24 03:05 kissingers

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

kissingers avatar May 19 '24 03:05 kissingers

https://github.com/trickerer/AzerothCore-wotlk-with-NPCBots/commit/3c092a797af98058006996e51a6d9e68860481df should be enough to tempfix this but the whole AV wanderer bot routine needs massive adjustments

trickerer avatar May 20 '24 12:05 trickerer