mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 01:37:00 +00:00
[9736] Added more usable interface for grid visits
(based on SilverIce's repo commit f20f01e) Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
9a0de445b8
commit
e3f3f3410a
19 changed files with 88 additions and 406 deletions
|
|
@ -569,16 +569,9 @@ void Creature::DoFleeToGetAssistance()
|
|||
{
|
||||
Creature* pCreature = NULL;
|
||||
|
||||
CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY()));
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
MaNGOS::NearestAssistCreatureInCreatureRangeCheck u_check(this, getVictim(), radius);
|
||||
MaNGOS::CreatureLastSearcher<MaNGOS::NearestAssistCreatureInCreatureRangeCheck> searcher(this, pCreature, u_check);
|
||||
|
||||
TypeContainerVisitor<MaNGOS::CreatureLastSearcher<MaNGOS::NearestAssistCreatureInCreatureRangeCheck>, GridTypeMapContainer > grid_creature_searcher(searcher);
|
||||
|
||||
cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius);
|
||||
Cell::VisitGridObjects(this, searcher, radius);
|
||||
|
||||
SetNoSearchAssistance(true);
|
||||
UpdateSpeed(MOVE_RUN, false);
|
||||
|
|
@ -1546,17 +1539,9 @@ void Creature::CallAssistance()
|
|||
std::list<Creature*> assistList;
|
||||
|
||||
{
|
||||
CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY()));
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
|
||||
MaNGOS::AnyAssistCreatureInRangeCheck u_check(this, getVictim(), radius);
|
||||
MaNGOS::CreatureListSearcher<MaNGOS::AnyAssistCreatureInRangeCheck> searcher(this, assistList, u_check);
|
||||
|
||||
TypeContainerVisitor<MaNGOS::CreatureListSearcher<MaNGOS::AnyAssistCreatureInRangeCheck>, GridTypeMapContainer > grid_creature_searcher(searcher);
|
||||
|
||||
cell.Visit(p, grid_creature_searcher, *GetMap(), *this, radius);
|
||||
Cell::VisitGridObjects(this,searcher, radius);
|
||||
}
|
||||
|
||||
if (!assistList.empty())
|
||||
|
|
@ -1579,17 +1564,9 @@ void Creature::CallForHelp(float fRadius)
|
|||
if (fRadius <= 0.0f || !getVictim() || isPet() || isCharmed())
|
||||
return;
|
||||
|
||||
CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY()));
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
|
||||
MaNGOS::CallOfHelpCreatureInRangeDo u_do(this, getVictim(), fRadius);
|
||||
MaNGOS::CreatureWorker<MaNGOS::CallOfHelpCreatureInRangeDo> worker(this, u_do);
|
||||
|
||||
TypeContainerVisitor<MaNGOS::CreatureWorker<MaNGOS::CallOfHelpCreatureInRangeDo>, GridTypeMapContainer > grid_creature_searcher(worker);
|
||||
|
||||
cell.Visit(p, grid_creature_searcher, *GetMap(), *this, fRadius);
|
||||
Cell::VisitGridObjects(this,worker, fRadius);
|
||||
}
|
||||
|
||||
bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const
|
||||
|
|
@ -2099,19 +2076,7 @@ void Creature::SendAreaSpiritHealerQueryOpcode(Player *pl)
|
|||
|
||||
void Creature::RelocationNotify()
|
||||
{
|
||||
CellPair new_val = MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY());
|
||||
Cell cell(new_val);
|
||||
CellPair cellpair = cell.cellPair();
|
||||
|
||||
MaNGOS::CreatureRelocationNotifier relocationNotifier(*this);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate(); // not trigger load unloaded grids at notifier call
|
||||
|
||||
TypeContainerVisitor<MaNGOS::CreatureRelocationNotifier, WorldTypeMapContainer > c2world_relocation(relocationNotifier);
|
||||
TypeContainerVisitor<MaNGOS::CreatureRelocationNotifier, GridTypeMapContainer > c2grid_relocation(relocationNotifier);
|
||||
|
||||
float radius = MAX_CREATURE_ATTACK_RADIUS * sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO);
|
||||
|
||||
cell.Visit(cellpair, c2world_relocation, *GetMap(), *this, radius);
|
||||
cell.Visit(cellpair, c2grid_relocation, *GetMap(), *this, radius);
|
||||
Cell::VisitAllObjects(this, relocationNotifier, radius);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue