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
88 : x_coord(x)
89 , y_coord(y)
90 {}
uint32 x_coord
Definition: GridDefines.h:153
uint32 y_coord
Definition: GridDefines.h:154

◆ CoordPair() [2/2]

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

Member Function Documentation

◆ dec_x()

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

References CoordPair< LIMIT >::x_coord.

◆ dec_y()

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

References CoordPair< LIMIT >::y_coord.

◆ GetId()

◆ inc_x()

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

References CoordPair< LIMIT >::x_coord.

◆ inc_y()

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

References CoordPair< LIMIT >::y_coord.

◆ IsCoordValid()

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

◆ normalize()

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

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
98 {
99 x_coord = obj.x_coord;
100 y_coord = obj.y_coord;
101 return *this;
102 }

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

Member Data Documentation

◆ x_coord

◆ y_coord