mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04: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
|
|
@ -289,26 +289,15 @@ void GameObject::Update(uint32 /*p_time*/)
|
|||
}
|
||||
}
|
||||
|
||||
CellPair p(MaNGOS::ComputeCellPair(GetPositionX(),GetPositionY()));
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
|
||||
// Note: this hack with search required until GO casting not implemented
|
||||
// search unfriendly creature
|
||||
if(owner && goInfo->trap.charges > 0) // hunter trap
|
||||
{
|
||||
MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, owner, radius);
|
||||
MaNGOS::UnitSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck> checker(this,ok, u_check);
|
||||
|
||||
TypeContainerVisitor<MaNGOS::UnitSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_object_checker(checker);
|
||||
cell.Visit(p, grid_object_checker, *GetMap(), *this, radius);
|
||||
|
||||
// or unfriendly player/pet
|
||||
Cell::VisitGridObjects(this,checker, radius);
|
||||
if(!ok)
|
||||
{
|
||||
TypeContainerVisitor<MaNGOS::UnitSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_object_checker(checker);
|
||||
cell.Visit(p, world_object_checker, *GetMap(), *this, radius);
|
||||
}
|
||||
Cell::VisitWorldObjects(this,checker, radius);
|
||||
}
|
||||
else // environmental trap
|
||||
{
|
||||
|
|
@ -318,9 +307,7 @@ void GameObject::Update(uint32 /*p_time*/)
|
|||
Player* p_ok = NULL;
|
||||
MaNGOS::AnyPlayerInObjectRangeCheck p_check(this, radius);
|
||||
MaNGOS::PlayerSearcher<MaNGOS::AnyPlayerInObjectRangeCheck> checker(this,p_ok, p_check);
|
||||
|
||||
TypeContainerVisitor<MaNGOS::PlayerSearcher<MaNGOS::AnyPlayerInObjectRangeCheck>, WorldTypeMapContainer > world_object_checker(checker);
|
||||
cell.Visit(p, world_object_checker, *GetMap(), *this, radius);
|
||||
Cell::VisitWorldObjects(this,checker, radius);
|
||||
ok = p_ok;
|
||||
}
|
||||
|
||||
|
|
@ -813,15 +800,10 @@ void GameObject::TriggeringLinkedGameObject( uint32 trapEntry, Unit* target)
|
|||
GameObject* trapGO = NULL;
|
||||
{
|
||||
// using original GO distance
|
||||
CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY()));
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
|
||||
MaNGOS::NearestGameObjectEntryInObjectRangeCheck go_check(*target,trapEntry,range);
|
||||
MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck> checker(this, trapGO,go_check);
|
||||
|
||||
TypeContainerVisitor<MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck>, GridTypeMapContainer > object_checker(checker);
|
||||
cell.Visit(p, object_checker, *GetMap(), *target, range);
|
||||
Cell::VisitGridObjects(this, checker, range);
|
||||
}
|
||||
|
||||
// found correct GO
|
||||
|
|
@ -834,14 +816,9 @@ GameObject* GameObject::LookupFishingHoleAround(float range)
|
|||
{
|
||||
GameObject* ok = NULL;
|
||||
|
||||
CellPair p(MaNGOS::ComputeCellPair(GetPositionX(),GetPositionY()));
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
MaNGOS::NearestGameObjectFishingHole u_check(*this, range);
|
||||
MaNGOS::GameObjectSearcher<MaNGOS::NearestGameObjectFishingHole> checker(this, ok, u_check);
|
||||
|
||||
TypeContainerVisitor<MaNGOS::GameObjectSearcher<MaNGOS::NearestGameObjectFishingHole>, GridTypeMapContainer > grid_object_checker(checker);
|
||||
cell.Visit(p, grid_object_checker, *GetMap(), *this, range);
|
||||
Cell::VisitGridObjects(this,checker, range);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue