Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Slight simplification to WrapPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
Causeless committed Nov 28, 2023
1 parent 267a44a commit 45be45b
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions Entities/SceneLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,33 +312,26 @@ namespace RTE {

template <bool TRACK_DRAWINGS>
bool SceneLayerImpl<TRACK_DRAWINGS>::WrapPosition(int &posX, int &posY) const {
bool wrapped = false;
int width = m_ScaledDimensions.GetFloorIntX();
int height = m_ScaledDimensions.GetFloorIntY();
int oldX = posX;
int oldY = posY;

if (m_WrapX) {
int width = m_ScaledDimensions.GetFloorIntX();
posX %= width;
if (posX < 0) {
while (posX < 0) {
posX += width;
}
wrapped = true;
} else if (posX >= width) {
posX %= width;
wrapped = true;
posX += width;
}
}

if (m_WrapY) {
int height = m_ScaledDimensions.GetFloorIntY();
posY %= height;
if (posY < 0) {
while (posY < 0) {
posY += height;
}
wrapped = true;
} else if (posY >= height) {
posY %= height;
wrapped = true;
posY += height;
}
}
return wrapped;

return oldX != posX || oldY != posY;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 45be45b

Please sign in to comment.