*First step of dynamic cell visit. Hope nothing is broken.
--HG-- branch : trunk
This commit is contained in:
@@ -142,6 +142,7 @@ struct TRINITY_DLL_DECL Cell
|
|||||||
} data;
|
} data;
|
||||||
|
|
||||||
template<class LOCK_TYPE, class T, class CONTAINER> void Visit(const CellLock<LOCK_TYPE> &, TypeContainerVisitor<T, CONTAINER> &visitor, Map &) const;
|
template<class LOCK_TYPE, class T, class CONTAINER> void Visit(const CellLock<LOCK_TYPE> &, TypeContainerVisitor<T, CONTAINER> &visitor, Map &) const;
|
||||||
|
template<class LOCK_TYPE, class T, class CONTAINER> void Visit(const CellLock<LOCK_TYPE> &, TypeContainerVisitor<T, CONTAINER> &visitor, Map &, float radius, float x_off, float y_off) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|||||||
@@ -129,4 +129,52 @@ Cell::Visit(const CellLock<LOCK_TYPE> &l, TypeContainerVisitor<T, CONTAINER> &vi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class LOCK_TYPE,class T, class CONTAINER>
|
||||||
|
inline void
|
||||||
|
Cell::Visit(const CellLock<LOCK_TYPE> &l, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, float radius, float x_off, float y_off) const
|
||||||
|
{
|
||||||
|
const CellPair &standing_cell = l.i_cellPair;
|
||||||
|
if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int left = 0, right = 0, upper = 0, lower = 0;
|
||||||
|
|
||||||
|
// Origin = (CENTER_GRID_CELL_OFFSET, CENTER_GRID_CELL_OFFSET)
|
||||||
|
if(CENTER_GRID_CELL_OFFSET - x_off < radius)
|
||||||
|
++right;
|
||||||
|
if(CENTER_GRID_CELL_OFFSET + x_off < radius)
|
||||||
|
++left;
|
||||||
|
if(CENTER_GRID_CELL_OFFSET - y_off < radius)
|
||||||
|
++upper;
|
||||||
|
if(CENTER_GRID_CELL_OFFSET + y_off < radius)
|
||||||
|
++lower;
|
||||||
|
|
||||||
|
if(!left && !right && !upper && !lower)
|
||||||
|
{
|
||||||
|
m.Visit(l, visitor);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CellPair begin_cell = standing_cell;
|
||||||
|
CellPair end_cell = standing_cell;
|
||||||
|
|
||||||
|
begin_cell << left; //note: need change << if left > 1
|
||||||
|
begin_cell -= lower;
|
||||||
|
end_cell >> right;
|
||||||
|
end_cell += upper;
|
||||||
|
|
||||||
|
// loop the cell range
|
||||||
|
for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; x++)
|
||||||
|
{
|
||||||
|
for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; y++)
|
||||||
|
{
|
||||||
|
CellPair cell_pair(x,y);
|
||||||
|
Cell r_zone(cell_pair);
|
||||||
|
r_zone.data.Part.nocreate = l->data.Part.nocreate;
|
||||||
|
CellLock<LOCK_TYPE> lock(r_zone, cell_pair);
|
||||||
|
m.Visit(lock, visitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -150,6 +150,18 @@ namespace Trinity
|
|||||||
return Compute<CellPair, CENTER_GRID_CELL_ID>(x, y, CENTER_GRID_CELL_OFFSET, SIZE_OF_GRID_CELL);
|
return Compute<CellPair, CENTER_GRID_CELL_ID>(x, y, CENTER_GRID_CELL_OFFSET, SIZE_OF_GRID_CELL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline CellPair ComputeCellPair(float x, float y, float &x_off, float &y_off)
|
||||||
|
{
|
||||||
|
double x_offset = (double(x) - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL;
|
||||||
|
double y_offset = (double(y) - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL;
|
||||||
|
|
||||||
|
int x_val = int(x_offset + 0.5);
|
||||||
|
int y_val = int(y_offset + 0.5);
|
||||||
|
x_off = (float(x_offset) - x_val) * SIZE_OF_GRID_CELL;
|
||||||
|
y_off = (float(y_offset) - y_val) * SIZE_OF_GRID_CELL;
|
||||||
|
return CellPair(x_val + CENTER_GRID_CELL_ID, y_val + CENTER_GRID_CELL_ID);
|
||||||
|
}
|
||||||
|
|
||||||
inline void NormalizeMapCoord(float &c)
|
inline void NormalizeMapCoord(float &c)
|
||||||
{
|
{
|
||||||
if(c > MAP_HALFSIZE - 0.5)
|
if(c > MAP_HALFSIZE - 0.5)
|
||||||
|
|||||||
+4
-3
@@ -1470,7 +1470,8 @@ void Spell::SearchAreaTarget(std::list<Unit*> &TagUnitMap, float radius, const u
|
|||||||
y = m_caster->GetPositionY();
|
y = m_caster->GetPositionY();
|
||||||
}
|
}
|
||||||
|
|
||||||
CellPair p(Trinity::ComputeCellPair(x, y));
|
float x_off, y_off;
|
||||||
|
CellPair p(Trinity::ComputeCellPair(x, y, x_off, y_off));
|
||||||
Cell cell(p);
|
Cell cell(p);
|
||||||
cell.data.Part.reserved = ALL_DISTRICT;
|
cell.data.Part.reserved = ALL_DISTRICT;
|
||||||
cell.SetNoCreate();
|
cell.SetNoCreate();
|
||||||
@@ -1481,12 +1482,12 @@ void Spell::SearchAreaTarget(std::list<Unit*> &TagUnitMap, float radius, const u
|
|||||||
//if(TargetType != SPELL_TARGETS_ENTRY)
|
//if(TargetType != SPELL_TARGETS_ENTRY)
|
||||||
{
|
{
|
||||||
TypeContainerVisitor<Trinity::SpellNotifierCreatureAndPlayer, WorldTypeMapContainer > world_object_notifier(notifier);
|
TypeContainerVisitor<Trinity::SpellNotifierCreatureAndPlayer, WorldTypeMapContainer > world_object_notifier(notifier);
|
||||||
cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster));
|
cell_lock->Visit(cell_lock, world_object_notifier, *m_caster->GetMap(), radius, x_off, y_off);
|
||||||
}
|
}
|
||||||
if(!(m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_PLAYERS_ONLY))
|
if(!(m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_PLAYERS_ONLY))
|
||||||
{
|
{
|
||||||
TypeContainerVisitor<Trinity::SpellNotifierCreatureAndPlayer, GridTypeMapContainer > grid_object_notifier(notifier);
|
TypeContainerVisitor<Trinity::SpellNotifierCreatureAndPlayer, GridTypeMapContainer > grid_object_notifier(notifier);
|
||||||
cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster));
|
cell_lock->Visit(cell_lock, grid_object_notifier, *m_caster->GetMap(), radius, x_off, y_off);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user