From b1d9bfdbf83b6fbd8c90d9eba67158ce4d39f041 Mon Sep 17 00:00:00 2001 From: BC Ko Date: Tue, 10 Aug 2021 15:36:40 -0700 Subject: [PATCH] cleanup manual value clamping: cursor.cpp CheckCursMove() (#2563) --- Source/cursor.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 2490bb342..e4d979911 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -360,18 +360,8 @@ void CheckCursMove() mx++; } - if (mx < 0) { - mx = 0; - } - if (mx >= MAXDUNX) { - mx = MAXDUNX - 1; - } - if (my < 0) { - my = 0; - } - if (my >= MAXDUNY) { - my = MAXDUNY - 1; - } + mx = clamp(mx, 0, MAXDUNX - 1); + my = clamp(my, 0, MAXDUNY - 1); // While holding the button down we should retain target (but potentially lose it if it dies, goes out of view, etc) if (sgbMouseDown != CLICK_NONE && pcursinvitem == -1) {