mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[7808] Move corpse search code in function with template arg for class-check.
This let reuse code for other similar near corpse target selection spells. Also provided currently not used class-checks for 2 spells Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
1feff6365f
commit
09046df744
6 changed files with 86 additions and 33 deletions
|
|
@ -423,6 +423,36 @@ Spell::~Spell()
|
|||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
WorldObject* Spell::FindCorpseUsing()
|
||||
{
|
||||
// non-standard target selection
|
||||
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex);
|
||||
float max_range = GetSpellMaxRange(srange);
|
||||
|
||||
CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY()));
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
|
||||
WorldObject* result = NULL;
|
||||
|
||||
T u_check(m_caster, max_range);
|
||||
MaNGOS::WorldObjectSearcher<T> searcher(m_caster, result, u_check);
|
||||
|
||||
TypeContainerVisitor<MaNGOS::WorldObjectSearcher<T>, GridTypeMapContainer > grid_searcher(searcher);
|
||||
CellLock<GridReadGuard> cell_lock(cell, p);
|
||||
cell_lock->Visit(cell_lock, grid_searcher, *m_caster->GetMap());
|
||||
|
||||
if (!result)
|
||||
{
|
||||
TypeContainerVisitor<MaNGOS::WorldObjectSearcher<T>, WorldTypeMapContainer > world_searcher(searcher);
|
||||
cell_lock->Visit(cell_lock, world_searcher, *m_caster->GetMap());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void Spell::FillTargetMap()
|
||||
{
|
||||
// TODO: ADD the correct target FILLS!!!!!!
|
||||
|
|
@ -537,29 +567,7 @@ void Spell::FillTargetMap()
|
|||
{
|
||||
case 20577: // Cannibalize
|
||||
{
|
||||
// non-standard target selection
|
||||
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex);
|
||||
float max_range = GetSpellMaxRange(srange);
|
||||
|
||||
CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY()));
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
|
||||
WorldObject* result = NULL;
|
||||
|
||||
MaNGOS::CannibalizeObjectCheck u_check(m_caster, max_range);
|
||||
MaNGOS::WorldObjectSearcher<MaNGOS::CannibalizeObjectCheck > searcher(m_caster, result, u_check);
|
||||
|
||||
TypeContainerVisitor<MaNGOS::WorldObjectSearcher<MaNGOS::CannibalizeObjectCheck >, GridTypeMapContainer > grid_searcher(searcher);
|
||||
CellLock<GridReadGuard> cell_lock(cell, p);
|
||||
cell_lock->Visit(cell_lock, grid_searcher, *m_caster->GetMap());
|
||||
|
||||
if(!result)
|
||||
{
|
||||
TypeContainerVisitor<MaNGOS::WorldObjectSearcher<MaNGOS::CannibalizeObjectCheck >, WorldTypeMapContainer > world_searcher(searcher);
|
||||
cell_lock->Visit(cell_lock, world_searcher, *m_caster->GetMap());
|
||||
}
|
||||
WorldObject* result = FindCorpseUsing<MaNGOS::CannibalizeObjectCheck> ();
|
||||
|
||||
if(result)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue