AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
CoordPair< LIMIT > Struct Template Reference

#include "GridDefines.h"

Public Member Functions

 CoordPair (uint32 x=0, uint32 y=0)
 
 CoordPair (const CoordPair< LIMIT > &obj)
 
CoordPair< LIMIT > & operator= (const CoordPair< LIMIT > &obj)
 
void dec_x (uint32 val)
 
void inc_x (uint32 val)
 
void dec_y (uint32 val)
 
void inc_y (uint32 val)
 
bool IsCoordValid () const
 
CoordPairnormalize ()
 
uint32 GetId () const
 

Public Attributes

uint32 x_coord
 
uint32 y_coord
 

Detailed Description

template<uint32 LIMIT>
struct CoordPair< LIMIT >

Constructor & Destructor Documentation

◆ CoordPair() [1/2]

template<uint32 LIMIT>
CoordPair< LIMIT >::CoordPair ( uint32  x = 0,
uint32  y = 0 
)
inline
87 : x_coord(x)
88 , y_coord(y)
89 {}
uint32 x_coord
Definition: GridDefines.h:152
uint32 y_coord
Definition: GridDefines.h:153

◆ CoordPair() [2/2]

template<uint32 LIMIT>
CoordPair< LIMIT >::CoordPair ( const CoordPair< LIMIT > &  obj)
inline
92 : x_coord(obj.x_coord)
93 , y_coord(obj.y_coord)
94 {}

Member Function Documentation

◆ dec_x()

template<uint32 LIMIT>
void CoordPair< LIMIT >::dec_x ( uint32  val)
inline
104 {
105 if (x_coord > val)
106 x_coord -= val;
107 else
108 x_coord = 0;
109 }

References CoordPair< LIMIT >::x_coord.

◆ dec_y()

template<uint32 LIMIT>
void CoordPair< LIMIT >::dec_y ( uint32  val)
inline
120 {
121 if (y_coord > val)
122 y_coord -= val;
123 else
124 y_coord = 0;
125 }

References CoordPair< LIMIT >::y_coord.

◆ GetId()

◆ inc_x()

template<uint32 LIMIT>
void CoordPair< LIMIT >::inc_x ( uint32  val)
inline
112 {
113 if (x_coord + val < LIMIT)
114 x_coord += val;
115 else
116 x_coord = LIMIT - 1;
117 }

References CoordPair< LIMIT >::x_coord.

◆ inc_y()

template<uint32 LIMIT>
void CoordPair< LIMIT >::inc_y ( uint32  val)
inline
128 {
129 if (y_coord + val < LIMIT)
130 y_coord += val;
131 else
132 y_coord = LIMIT - 1;
133 }

References CoordPair< LIMIT >::y_coord.

◆ IsCoordValid()

template<uint32 LIMIT>
bool CoordPair< LIMIT >::IsCoordValid ( ) const
inline

◆ normalize()

template<uint32 LIMIT>
CoordPair & CoordPair< LIMIT >::normalize ( )
inline
141 {
142 x_coord = std::min(x_coord, LIMIT - 1);
143 y_coord = std::min(y_coord, LIMIT - 1);
144 return *this;
145 }

References CoordPair< LIMIT >::x_coord, and CoordPair< LIMIT >::y_coord.

Referenced by Cell::CalculateCellArea().

◆ operator=()

template<uint32 LIMIT>
CoordPair< LIMIT > & CoordPair< LIMIT >::operator= ( const CoordPair< LIMIT > &  obj)
inline
97 {
98 x_coord = obj.x_coord;
99 y_coord = obj.y_coord;
100 return *this;
101 }

References CoordPair< LIMIT >::x_coord, and CoordPair< LIMIT >::y_coord.

Member Data Documentation

◆ x_coord

◆ y_coord