From 36a4b2a431cdb9f2112ecf469f834d1f7398fb75 Mon Sep 17 00:00:00 2001 From: bash Date: Sun, 31 May 2026 16:13:45 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20Dead-code=20sweep=20=E2=80=94=20Fol?= =?UTF-8?q?low=20/*=20*/=20block=20+=20TravelNode=202x=20/*=20*/=20blocks?= =?UTF-8?q?=20+=20LastMovement.lastFollow=20+=206=20unused=20includes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Ai/Base/Actions/MovementActions.cpp | 60 +------------ src/Ai/Base/Value/LastMovementValue.cpp | 10 +-- src/Ai/Base/Value/LastMovementValue.h | 2 - src/Mgr/Travel/TravelNode.cpp | 115 ------------------------ 4 files changed, 5 insertions(+), 182 deletions(-) diff --git a/src/Ai/Base/Actions/MovementActions.cpp b/src/Ai/Base/Actions/MovementActions.cpp index e366cd9bc..46ae0b938 100644 --- a/src/Ai/Base/Actions/MovementActions.cpp +++ b/src/Ai/Base/Actions/MovementActions.cpp @@ -12,7 +12,6 @@ #include #include "Corpse.h" -#include "DBCStores.h" #include "Event.h" #include "FleeManager.h" #include "G3D/Vector3.h" @@ -20,11 +19,8 @@ #include "LastMovementValue.h" #include "LootObjectStack.h" #include "Map.h" -#include "ModelIgnoreFlags.h" #include "MotionMaster.h" -#include "MoveSpline.h" #include "MoveSplineInitArgs.h" -#include "TravelNode.h" #include "MovementGenerator.h" #include "ObjectDefines.h" #include "ObjectGuid.h" @@ -33,15 +29,13 @@ #include "PlayerbotAIConfig.h" #include "Playerbots.h" #include "Position.h" -#include "PositionValue.h" #include "Random.h" #include "ServerFacade.h" #include "SharedDefines.h" -#include "SpellAuraEffects.h" #include "SpellInfo.h" -#include "Stances.h" #include "Timer.h" #include "Transport.h" +#include "TravelNode.h" #include "Unit.h" #include "WaypointMovementGenerator.h" @@ -719,58 +713,6 @@ bool MovementAction::Follow(Unit* target, float distance, float angle) return false; } - /* - if (!bot->InBattleground() - && ServerFacade::instance().IsDistanceLessOrEqualThan(ServerFacade::instance().GetDistance2d(bot, target->GetPositionX(), - target->GetPositionY()), sPlayerbotAIConfig.sightDistance) - && abs(bot->GetPositionZ() - target->GetPositionZ()) >= sPlayerbotAIConfig.spellDistance && - botAI->HasRealPlayerMaster() - && (target->GetMapId() && bot->GetMapId() != target->GetMapId())) - { - bot->StopMoving(); - bot->GetMotionMaster()->Clear(); - - float x = bot->GetPositionX(); - float y = bot->GetPositionY(); - float z = target->GetPositionZ(); - if (target->GetMapId() && bot->GetMapId() != target->GetMapId()) - { - if ((target->GetMap() && target->GetMap()->IsBattlegroundOrArena()) || (bot->GetMap() && - bot->GetMap()->IsBattlegroundOrArena())) return false; - - bot->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TELEPORTED | AURA_INTERRUPT_FLAG_CHANGE_MAP); - bot->TeleportTo(target->GetMapId(), x, y, z, bot->GetOrientation()); - } - else - { - bot->Relocate(x, y, z, bot->GetOrientation()); - } - - AI_VALUE(LastMovement&, "last movement").Set(target); - ClearIdleState(); - return true; - } - - if (!IsMovingAllowed(target) && botAI->HasRealPlayerMaster()) - { - if ((target->GetMap() && target->GetMap()->IsBattlegroundOrArena()) || (bot->GetMap() && - bot->GetMap()->IsBattlegroundOrArena())) return false; - - if (bot->isDead() && botAI->GetMaster()->IsAlive()) - { - bot->ResurrectPlayer(1.0f, false); - botAI->TellMasterNoFacing("I live, again!"); - } - else - botAI->TellError("I am stuck while following"); - - bot->CombatStop(true); - botAI->TellMasterNoFacing("I will there soon."); - bot->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TELEPORTED | AURA_INTERRUPT_FLAG_CHANGE_MAP); - bot->TeleportTo(target->GetMapId(), target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), - target->GetOrientation()); return false; - } - */ // Move to target corpse if alive. if (!target->IsAlive() && bot->IsAlive() && target->GetGUID().IsPlayer()) diff --git a/src/Ai/Base/Value/LastMovementValue.cpp b/src/Ai/Base/Value/LastMovementValue.cpp index bc0ec8fce..39810abff 100644 --- a/src/Ai/Base/Value/LastMovementValue.cpp +++ b/src/Ai/Base/Value/LastMovementValue.cpp @@ -12,7 +12,6 @@ LastMovement::LastMovement() { clear(); } LastMovement::LastMovement(LastMovement& other) : taxiNodes(other.taxiNodes), taxiMaster(other.taxiMaster), - lastFollow(other.lastFollow), lastAreaTrigger(other.lastAreaTrigger), lastFlee(other.lastFlee) { @@ -27,7 +26,6 @@ void LastMovement::clear() { lastMoveShort = WorldPosition(); lastPath.clear(); - lastFollow = nullptr; lastAreaTrigger = 0; lastFlee = 0; nextTeleport = 0; @@ -36,17 +34,18 @@ void LastMovement::clear() lastTransportEntry = 0; } -void LastMovement::Set(Unit* follow) +void LastMovement::Set([[maybe_unused]] Unit* follow) { + // Legacy signature — `follow` is ignored (lastFollow field removed). + // The function still serves callers that want a soft-reset: + // clears short + path, resets msTime/priority via the chain below. Set(0, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); setShort(WorldPosition()); setPath(TravelPath()); - lastFollow = follow; } void LastMovement::Set(uint32 mapId, float x, float y, float z, float ori, float delayTime, MovementPriority pri) { - lastFollow = nullptr; lastMoveShort = WorldPosition(mapId, x, y, z, ori); msTime = getMSTime(); priority = pri; @@ -55,7 +54,6 @@ void LastMovement::Set(uint32 mapId, float x, float y, float z, float ori, float void LastMovement::setShort(WorldPosition point) { lastMoveShort = point; - lastFollow = nullptr; } void LastMovement::setPath(TravelPath path) { lastPath = path; } diff --git a/src/Ai/Base/Value/LastMovementValue.h b/src/Ai/Base/Value/LastMovementValue.h index c116dd729..9141a04e6 100644 --- a/src/Ai/Base/Value/LastMovementValue.h +++ b/src/Ai/Base/Value/LastMovementValue.h @@ -33,7 +33,6 @@ public: { taxiNodes = other.taxiNodes; taxiMaster = other.taxiMaster; - lastFollow = other.lastFollow; lastAreaTrigger = other.lastAreaTrigger; lastMoveShort = other.lastMoveShort; lastPath = other.lastPath; @@ -53,7 +52,6 @@ public: std::vector taxiNodes; ObjectGuid taxiMaster; - Unit* lastFollow; uint32 lastAreaTrigger; time_t lastFlee; WorldPosition lastMoveShort; diff --git a/src/Mgr/Travel/TravelNode.cpp b/src/Mgr/Travel/TravelNode.cpp index eb12857d0..8c5cf90ba 100644 --- a/src/Mgr/Travel/TravelNode.cpp +++ b/src/Mgr/Travel/TravelNode.cpp @@ -475,111 +475,6 @@ bool TravelNode::cropUselessLinks() return hasRemoved; - /* - - //std::vector> toRemove; - for (auto& firstLink : getLinks()) - { - - TravelNode* firstNode = firstLink.first; - float firstLength = firstLink.second.getDistance(); - for (auto& secondLink : getLinks()) - { - TravelNode* secondNode = secondLink.first; - float secondLength = secondLink.second.getDistance(); - - if (firstNode == secondNode) - continue; - - if (std::find(toRemove.begin(), toRemove.end(), [firstNode, secondNode](std::pair - pair) {return pair.first == firstNode || pair.first == secondNode;}) != toRemove.end()) continue; - - if (firstNode->hasLinkTo(secondNode)) - { - //Is it quicker to go past first node to reach second node instead of going directly? - if (firstLength + firstNode->linkLengthTo(secondNode) < secondLength * 1.1) - { - if (secondNode->hasLinkTo(this) && !firstNode->hasLinkTo(this)) - continue; - - toRemove.push_back(make_pair(this, secondNode)); - } - } - else - { - TravelNodeRoute route = TravelNodeMap::instance().GetNodeRoute(firstNode, secondNode, nullptr); - - if (route.isEmpty()) - continue; - - if (route.hasNode(this)) - continue; - - //Is it quicker to go past first (and multiple) nodes to reach the second node instead of going - directly? if (firstLength + route.getLength() < secondLength * 1.1) - { - if (secondNode->hasLinkTo(this) && !firstNode->hasLinkTo(this)) - continue; - - toRemove.push_back(make_pair(this, secondNode)); - } - } - } - - //Reverse cleanup. This is needed when we add a node in an existing map. - if (firstNode->hasLinkTo(this)) - { - firstLength = firstNode->getPathTo(this)->getDistance(); - - for (auto& secondLink : firstNode->getLinks()) - { - TravelNode* secondNode = secondLink.first; - float secondLength = secondLink.second.getDistance(); - - if (this == secondNode) - continue; - - if (std::find(toRemove.begin(), toRemove.end(), [firstNode, secondNode](std::pair pair) {return pair.first == firstNode || pair.first == secondNode; }) != toRemove.end()) continue; - - if (firstNode->hasLinkTo(secondNode)) - { - //Is it quicker to go past first node to reach second node instead of going directly? - if (firstLength + firstNode->linkLengthTo(secondNode) < secondLength * 1.1) - { - if (secondNode->hasLinkTo(this) && !firstNode->hasLinkTo(this)) - continue; - - toRemove.push_back(make_pair(this, secondNode)); - } - } - else - { - TravelNodeRoute route = TravelNodeMap::instance().GetNodeRoute(firstNode, secondNode, nullptr); - - if (route.isEmpty()) - continue; - - if (route.hasNode(this)) - continue; - - //Is it quicker to go past first (and multiple) nodes to reach the second node instead of going - directly? if (firstLength + route.getLength() < secondLength * 1.1) - { - if (secondNode->hasLinkTo(this) && !firstNode->hasLinkTo(this)) - continue; - - toRemove.push_back(make_pair(this, secondNode)); - } - } - } - } - - } - - for (auto& nodePair : toRemove) - nodePair.first->unlinkNode(nodePair.second, false); - */ } bool TravelNode::isEqual(TravelNode* compareNode) @@ -2319,16 +2214,6 @@ void TravelNodeMap::printNodeStore() out << "," << (node->isTransport() ? "true" : "false") << "," << node->getTransportId(); out << "});"; - /* - out << std::fixed << std::setprecision(2) << " nodes[" << i << "] = - TravelNodeMap::instance().addNode(&WorldPosition(" << node->GetMapId() << "," << node->getX() << "f," << node->getY() - << "f," << node->getZ() << "f,"<< node->getO() <<"f), \"" - << name << "\", " << (node->isImportant() ? "true" : "false") << ", true"; - if (node->isTransport()) - out << "," << (node->isTransport() ? "true" : "false") << "," << node->getTransportId(); - - out << ");"; - */ sPlayerbotAIConfig.log(nodeStore, out.str().c_str()); saveNodes.insert(std::make_pair(node, i));