18#ifndef TRINITY_GRIDDEFINES_H
19#define TRINITY_GRIDDEFINES_H
34#define MAX_NUMBER_OF_CELLS 8
36#define MAX_NUMBER_OF_GRIDS 64
38#define SIZE_OF_GRIDS 533.3333f
39#define CENTER_GRID_ID (MAX_NUMBER_OF_GRIDS/2)
41#define CENTER_GRID_OFFSET (SIZE_OF_GRIDS/2)
43#define MIN_GRID_DELAY (MINUTE*IN_MILLISECONDS)
44#define MIN_MAP_UPDATE_DELAY 1
46#define SIZE_OF_GRID_CELL (SIZE_OF_GRIDS/MAX_NUMBER_OF_CELLS)
48#define CENTER_GRID_CELL_ID (MAX_NUMBER_OF_CELLS*MAX_NUMBER_OF_GRIDS/2)
49#define CENTER_GRID_CELL_OFFSET (SIZE_OF_GRID_CELL/2)
51#define TOTAL_NUMBER_OF_CELLS_PER_MAP (MAX_NUMBER_OF_GRIDS*MAX_NUMBER_OF_CELLS)
53#define MAP_RESOLUTION 128
55#define MAP_SIZE (SIZE_OF_GRIDS*MAX_NUMBER_OF_GRIDS)
56#define MAP_HALFSIZE (MAP_SIZE/2)
95 : x_coord(x), y_coord(y)
99 : x_coord(obj.x_coord), y_coord(obj.y_coord)
119 if (x_coord + val < LIMIT)
135 if (y_coord + val < LIMIT)
143 return x_coord < LIMIT && y_coord < LIMIT;
148 x_coord = std::min(x_coord, LIMIT - 1);
149 y_coord = std::min(y_coord, LIMIT - 1);
155 return y_coord * LIMIT + x_coord;
169 template<
class RET_TYPE,
int CENTER_VAL>
170 inline RET_TYPE
Compute(
float x,
float y,
float center_offset,
float size)
173 double x_offset = (double(x) - center_offset)/size;
174 double y_offset = (double(y) - center_offset)/size;
176 int x_val = int(x_offset + CENTER_VAL + 0.5);
177 int y_val = int(y_offset + CENTER_VAL + 0.5);
178 return RET_TYPE(x_val, y_val);
220 return std::isfinite(c) && (std::fabs(c) <=
MAP_HALFSIZE - 0.5f);
GridRefManager< Corpse > CorpseMapType
GridRefManager< DynamicObject > DynamicObjectMapType
GridRefManager< Creature > CreatureMapType
GridRefManager< Player > PlayerMapType
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
TypeMapContainer< AllWorldObjectTypes > WorldTypeMapContainer
TypeMapContainer< AllGridObjectTypes > GridTypeMapContainer
#define CENTER_GRID_CELL_OFFSET
#define MAX_NUMBER_OF_GRIDS
#define CENTER_GRID_CELL_ID
#define SIZE_OF_GRID_CELL
CoordPair< TOTAL_NUMBER_OF_CELLS_PER_MAP > CellCoord
#define CENTER_GRID_OFFSET
@ GRID_MAP_TYPE_MASK_PLAYER
@ GRID_MAP_TYPE_MASK_CREATURE
@ GRID_MAP_TYPE_MASK_GAMEOBJECT
@ GRID_MAP_TYPE_MASK_DYNAMICOBJECT
@ GRID_MAP_TYPE_MASK_CORPSE
GridRefManager< GameObject > GameObjectMapType
NGrid< MAX_NUMBER_OF_CELLS, Player, AllWorldObjectTypes, AllGridObjectTypes > NGridType
Grid< Player, AllWorldObjectTypes, AllGridObjectTypes > GridType
#define TYPELIST_4(T1, T2, T3, T4)
#define TYPELIST_5(T1, T2, T3, T4, T5)
GridCoord ComputeGridCoordSimple(float x, float y)
bool IsValidMapCoord(float c)
RET_TYPE Compute(float x, float y, float center_offset, float size)
void NormalizeMapCoord(float &c)
GridCoord ComputeGridCoord(float x, float y)
CellCoord ComputeCellCoord(float x, float y)
bool IsCoordValid() const
CoordPair< LIMIT > & operator=(const CoordPair< LIMIT > &obj)
CoordPair(uint32 x=0, uint32 y=0)
CoordPair(const CoordPair< LIMIT > &obj)
friend bool operator==(CoordPair const &p1, CoordPair const &p2)=default