Skip to content

Commit

Permalink
Added operators overloads for MapOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
oscar139 committed Apr 15, 2024
1 parent 78fc44c commit dd6b1b5
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions OPHD/Map/MapOffset.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,36 @@ struct MapOffset
NAS2D::Vector<int> xy;
int z;
};

inline bool operator==(const MapOffset& offset1, const MapOffset& offset2)
{
return offset1.xy == offset2.xy && offset1.z == offset2.z;
}

inline bool operator!=(const MapOffset& offset1, const MapOffset& offset2)
{
return offset1.xy != offset2.xy || offset1.z != offset2.z;
}

inline MapOffset operator*(const MapOffset& offset, int scalar)
{
MapOffset result;
result.xy = offset.xy * scalar;
result.z = offset.z * scalar;
return result;
}

inline MapOffset operator*(int scalar, const MapOffset& offset)
{
MapOffset result;
result.xy = offset.xy * scalar;
result.z = offset.z * scalar;
return result;
}

inline MapOffset& operator*=(MapOffset& offset, int scalar)
{
offset.xy *= scalar;
offset.z *= scalar;
return offset;
}

0 comments on commit dd6b1b5

Please sign in to comment.