Professional Documents
Culture Documents
Cell Impl
Cell Impl
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright
information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ACORE_CELLIMPL_H
#define ACORE_CELLIMPL_H
#include "Cell.h"
#include "Map.h"
#include "Object.h"
#include <cmath>
// no jokes here... Actually placing ASSERT() here was good idea, but
// we had some problems with DynamicObjects, which pass radius = 0.0f (DB
issue?)
// maybe it is better to just return when radius <= 0.0f?
if (radius <= 0.0f)
{
map.Visit(*this, visitor);
return;
}
//lets limit the upper value for search radius
if (radius > SIZE_OF_GRIDS)
radius = SIZE_OF_GRIDS;
//ALWAYS visit standing cell first!!! Since we deal with small radiuses
//it is very essential to call visitor for standing cell firstly...
map.Visit(*this, visitor);
// loop the cell range
for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x)
{
for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y)
{
CellCoord cellCoord(x, y);
//lets skip standing cell since we already visited it
if (cellCoord != standing_cell)
{
Cell r_zone(cellCoord);
r_zone.data.Part.nocreate = this->data.Part.nocreate;
map.Visit(r_zone, visitor);
}
}
}
}
//if x_shift == 0 then we have too small cell area, which were already
//visited at previous step, so just return from procedure...
if (x_shift == 0)
return;
template<class T>
inline void Cell::VisitGridObjects(WorldObject const* center_obj, T& visitor, float
radius, bool dont_load /*= true*/)
{
CellCoord p(Acore::ComputeCellCoord(center_obj->GetPositionX(), center_obj-
>GetPositionY()));
Cell cell(p);
if (dont_load)
{
cell.SetNoCreate();
}
template<class T>
inline void Cell::VisitWorldObjects(WorldObject const* center_obj, T& visitor,
float radius, bool dont_load /*= true*/)
{
CellCoord p(Acore::ComputeCellCoord(center_obj->GetPositionX(), center_obj-
>GetPositionY()));
Cell cell(p);
if (dont_load)
{
cell.SetNoCreate();
}
template<class T>
inline void Cell::VisitAllObjects(WorldObject const* center_obj, T& visitor, float
radius, bool dont_load /*= true*/)
{
CellCoord p(Acore::ComputeCellCoord(center_obj->GetPositionX(), center_obj-
>GetPositionY()));
Cell cell(p);
if (dont_load)
{
cell.SetNoCreate();
}
template<class T>
inline void Cell::VisitGridObjects(float x, float y, Map* map, T& visitor, float
radius, bool dont_load /*= true*/)
{
CellCoord p(Acore::ComputeCellCoord(x, y));
Cell cell(p);
if (dont_load)
{
cell.SetNoCreate();
}
template<class T>
inline void Cell::VisitWorldObjects(float x, float y, Map* map, T& visitor, float
radius, bool dont_load /*= true*/)
{
CellCoord p(Acore::ComputeCellCoord(x, y));
Cell cell(p);
if (dont_load)
{
cell.SetNoCreate();
}
template<class T>
inline void Cell::VisitAllObjects(float x, float y, Map* map, T& visitor, float
radius, bool dont_load /*= true*/)
{
CellCoord p(Acore::ComputeCellCoord(x, y));
Cell cell(p);
if (dont_load)
{
cell.SetNoCreate();
}
#endif