Code cleanup (#188)

This commit is contained in:
Kamron Batman 2020-08-01 08:40:06 -07:00 committed by GitHub
parent df53c16620
commit 010fd9402a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
185 changed files with 1052 additions and 1271 deletions

View file

@ -655,34 +655,14 @@ namespace Server
public void Bound(int x, int y, out int newX, out int newY)
{
if (x < 0)
newX = 0;
else if (x >= Width)
newX = Width - 1;
else
newX = x;
if (y < 0)
newY = 0;
else if (y >= Height)
newY = Height - 1;
else
newY = y;
newX = Math.Clamp(x, 0, Width - 1);
newY = Math.Clamp(y, 0, Height - 1);
}
public Point2D Bound(Point2D p)
{
int x = p.m_X, y = p.m_Y;
if (x < 0)
x = 0;
else if (x >= Width)
x = Width - 1;
if (y < 0)
y = 0;
else if (y >= Height)
y = Height - 1;
int x = Math.Clamp(p.m_X, 0, Width - 1);
int y = Math.Clamp(p.m_Y, 0, Height - 1);
return new Point2D(x, y);
}