Create Flightmastercache to handle finding the nearest flight master. (#1979)

Refactor the flightmastercache the bots use for finding the nearest
available flight master.

I made a small change to how the original function worked by storing the
database position for the flightmaster in the cache itself. This allows
us to calculate the distance from bot before accessing the creature
object, should be faster overall.
This commit is contained in:
Keleborn
2026-01-23 11:36:57 -08:00
committed by GitHub
parent bf456ee07f
commit 3e21563669
5 changed files with 74 additions and 24 deletions

View File

@@ -26,6 +26,7 @@
#include "DatabaseEnv.h"
#include "Define.h"
#include "FleeManager.h"
#include "FlightMasterCache.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "GuildMgr.h"
@@ -2002,14 +2003,12 @@ void RandomPlayerbotMgr::PrepareTeleportCache()
bool forAlliance = !(entry->hostileMask & 2);
if (tNpcflag & UNIT_NPC_FLAG_FLIGHTMASTER)
{
WorldPosition pos(mapId, x, y, z, orient);
if (forHorde)
{
hordeFlightMasterCache.push_back(guid);
}
sFlightMasterCache->AddHordeFlightMaster(guid, pos);
if (forAlliance)
{
allianceFlightMasterCache.push_back(guid);
}
sFlightMasterCache->AddAllianceFlightMaster(guid, pos);
}
const AreaTableEntry* area = sAreaTableStore.LookupEntry(map->GetAreaId(PHASEMASK_NORMAL, x, y, z));
uint32 zoneId = area->zone ? area->zone : area->ID;