Use method IsCoordValid() to replace explicit checks.

This commit is contained in:
megamage
2011-10-18 11:05:32 -04:00
parent c29ff41001
commit e0d933fed8
4 changed files with 19 additions and 15 deletions
+2 -2
View File
@@ -39,7 +39,7 @@ template<class T, class CONTAINER>
inline void
Cell::Visit(const CellCoord& standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m) const
{
if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
if (!standing_cell.IsCoordValid())
return;
uint16 district = (District)this->data.Part.reserved;
@@ -170,7 +170,7 @@ template<class T, class CONTAINER>
inline void
Cell::Visit(const CellCoord& standing_cell, TypeContainerVisitor<T, CONTAINER> &visitor, Map &m, float radius, float x_off, float y_off) const
{
if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
if (!standing_cell.IsCoordValid())
return;
//no jokes here... Actually placing ASSERT() here was good idea, but
+8 -3
View File
@@ -71,7 +71,7 @@ typedef NGrid<MAX_NUMBER_OF_CELLS, Player, AllWorldObjectTypes, AllGridObjectTyp
typedef TypeMapContainer<AllGridObjectTypes> GridTypeMapContainer;
typedef TypeMapContainer<AllWorldObjectTypes> WorldTypeMapContainer;
template<const unsigned int LIMIT>
template<uint32 LIMIT>
struct CoordPair
{
CoordPair(uint32 x=0, uint32 y=0)
@@ -123,17 +123,22 @@ struct CoordPair
y_coord = LIMIT - 1;
}
bool IsCoordValid() const
{
return x_coord < LIMIT && y_coord < LIMIT;
}
uint32 x_coord;
uint32 y_coord;
};
template<const unsigned int LIMIT>
template<uint32 LIMIT>
bool operator==(const CoordPair<LIMIT> &p1, const CoordPair<LIMIT> &p2)
{
return (p1.x_coord == p2.x_coord && p1.y_coord == p2.y_coord);
}
template<const unsigned int LIMIT>
template<uint32 LIMIT>
bool operator!=(const CoordPair<LIMIT> &p1, const CoordPair<LIMIT> &p2)
{
return !(p1 == p2);