refactor: Dead-code sweep — Follow /* */ block + TravelNode 2x /* */ blocks + LastMovement.lastFollow + 6 unused includes

This commit is contained in:
bash 2026-05-31 16:13:45 +02:00
parent e820889965
commit 36a4b2a431
4 changed files with 5 additions and 182 deletions

View File

@ -12,7 +12,6 @@
#include <string>
#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())

View File

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

View File

@ -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<uint32> taxiNodes;
ObjectGuid taxiMaster;
Unit* lastFollow;
uint32 lastAreaTrigger;
time_t lastFlee;
WorldPosition lastMoveShort;

View File

@ -475,111 +475,6 @@ bool TravelNode::cropUselessLinks()
return hasRemoved;
/*
//std::vector<std::pair<TravelNode*, TravelNode*>> 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<TravelNode*, TravelNode*>
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<TravelNode*,
TravelNode*> 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));