Replace SWAP with std::swap

This commit is contained in:
GravisZro 2024-05-21 06:39:51 -04:00
parent 88d1dfa948
commit 582970d9ef
4 changed files with 20 additions and 21 deletions

View File

@ -104,6 +104,8 @@
* $NoKeywords: $ * $NoKeywords: $
*/ */
#include <algorithm>
#include "gr.h" #include "gr.h"
#include "lib2d.h" #include "lib2d.h"
#include "renderer.h" #include "renderer.h"
@ -377,9 +379,9 @@ int grViewport::clip_rect(int &l, int &t, int &r, int &b) {
int clipped = 0; int clipped = 0;
if (l > r) if (l > r)
SWAP(l, r); std::swap(l, r);
if (t > b) if (t > b)
SWAP(t, b); std::swap(t, b);
if (l > CLIP_RIGHT || t > CLIP_BOTTOM || r < CLIP_LEFT || b < CLIP_TOP) if (l > CLIP_RIGHT || t > CLIP_BOTTOM || r < CLIP_LEFT || b < CLIP_TOP)
return 2; return 2;

View File

@ -40,6 +40,9 @@
* *
* $NoKeywords: $ * $NoKeywords: $
*/ */
#include <algorithm>
#include "procedurals.h" #include "procedurals.h"
#include "bitmap.h" #include "bitmap.h"
#include "gr.h" #include "gr.h"
@ -55,7 +58,6 @@
#include <memory.h> #include <memory.h>
#include "psrand.h" #include "psrand.h"
#include <algorithm>
#define BRIGHT_COLOR 254 #define BRIGHT_COLOR 254
#define PROC_SIZE 128 #define PROC_SIZE 128
@ -283,8 +285,8 @@ void DrawProceduralLine(int x1, int y1, int x2, int y2, uint8_t color) {
// Check to see if our x coords are reversed // Check to see if our x coords are reversed
if (x1 > x2) { if (x1 > x2) {
SWAP(x1, x2); std::swap(x1, x2);
SWAP(y1, y2); std::swap(y1, y2);
} }
DX = x2 - x1; DX = x2 - x1;
DY = y2 - y1; DY = y2 - y1;

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <algorithm>
#ifdef NEWEDITOR #ifdef NEWEDITOR
#include "../neweditor/stdafx.h" #include "../neweditor/stdafx.h"
@ -62,8 +63,8 @@ void editorSelectorManager::StartSelection(CWnd *wnd, void (*func)(editorSelecto
m_OwnerWnd->GetClientRect(&client_rect); m_OwnerWnd->GetClientRect(&client_rect);
r_l = m_l; r_t = m_t; r_r = m_r; r_b = m_b; r_l = m_l; r_t = m_t; r_r = m_r; r_b = m_b;
if (r_r < r_l) SWAP(r_l, r_r); if (r_r < r_l) std::swap(r_l, r_r);
if (r_b < r_t) SWAP(r_t, r_b); if (r_b < r_t) std::swap(r_t, r_b);
if (r_l < client_rect.left) r_l = client_rect.left; if (r_l < client_rect.left) r_l = client_rect.left;
if (r_t < client_rect.top) r_t = client_rect.top; if (r_t < client_rect.top) r_t = client_rect.top;
if (r_r > client_rect.right) r_r = client_rect.right; if (r_r > client_rect.right) r_r = client_rect.right;
@ -98,8 +99,8 @@ void editorSelectorManager::GetSelectedRect(int *l, int *t, int *r, int *b)
// make sure selected rectangle is clipped to the owner window and normalized. // make sure selected rectangle is clipped to the owner window and normalized.
m_OwnerWnd->GetClientRect(&client_rect); m_OwnerWnd->GetClientRect(&client_rect);
if (m_r < m_l) SWAP(m_l, m_r); if (m_r < m_l) std::swap(m_l, m_r);
if (m_b < m_t) SWAP(m_t, m_b); if (m_b < m_t) std::swap(m_t, m_b);
if (m_l < client_rect.left) m_l = client_rect.left; if (m_l < client_rect.left) m_l = client_rect.left;
if (m_t < client_rect.top) m_t = client_rect.top; if (m_t < client_rect.top) m_t = client_rect.top;
if (m_r > client_rect.right) m_r = client_rect.right; if (m_r > client_rect.right) m_r = client_rect.right;
@ -154,8 +155,8 @@ void editorSelectorManager::Defer()
// get current selected rect, normalize rectangle if left,top is invalid for drawing. // get current selected rect, normalize rectangle if left,top is invalid for drawing.
r_l = m_l; r_t = m_t; r_r = m_r; r_b = m_b; r_l = m_l; r_t = m_t; r_r = m_r; r_b = m_b;
if (r_r < r_l) SWAP(r_l, r_r); if (r_r < r_l) std::swap(r_l, r_r);
if (r_b < r_t) SWAP(r_t, r_b); if (r_b < r_t) std::swap(r_t, r_b);
if (r_l < client_rect.left) r_l = client_rect.left; if (r_l < client_rect.left) r_l = client_rect.left;
if (r_t < client_rect.top) r_t = client_rect.top; if (r_t < client_rect.top) r_t = client_rect.top;
if (r_r > client_rect.right) r_r = client_rect.right; if (r_r > client_rect.right) r_r = client_rect.right;
@ -166,8 +167,8 @@ void editorSelectorManager::Defer()
m_b = m_b + mdy; m_b = m_b + mdy;
r_l = m_l; r_t = m_t; r_r = m_r; r_b = m_b; r_l = m_l; r_t = m_t; r_r = m_r; r_b = m_b;
if (r_r < r_l) SWAP(r_l, r_r); if (r_r < r_l) std::swap(r_l, r_r);
if (r_b < r_t) SWAP(r_t, r_b); if (r_b < r_t) std::swap(r_t, r_b);
if (r_l < client_rect.left) r_l = client_rect.left; if (r_l < client_rect.left) r_l = client_rect.left;
if (r_t < client_rect.top) r_t = client_rect.top; if (r_t < client_rect.top) r_t = client_rect.top;
if (r_r > client_rect.right) r_r = client_rect.right; if (r_r > client_rect.right) r_r = client_rect.right;
@ -203,8 +204,8 @@ void editorSelectorManager::EndSelection()
// clip drawing rectangle to owner window. // clip drawing rectangle to owner window.
m_OwnerWnd->GetClientRect(&client_rect); m_OwnerWnd->GetClientRect(&client_rect);
r_l = m_l; r_t = m_t; r_r = m_r; r_b = m_b; r_l = m_l; r_t = m_t; r_r = m_r; r_b = m_b;
if (r_r < r_l) SWAP(r_l, r_r); if (r_r < r_l) std::swap(r_l, r_r);
if (r_b < r_t) SWAP(r_t, r_b); if (r_b < r_t) std::swap(r_t, r_b);
if (r_l < client_rect.left) r_l = client_rect.left; if (r_l < client_rect.left) r_l = client_rect.left;
if (r_t < client_rect.top) r_t = client_rect.top; if (r_t < client_rect.top) r_t = client_rect.top;
if (r_r > client_rect.right) r_r = client_rect.right; if (r_r > client_rect.right) r_r = client_rect.right;

View File

@ -60,12 +60,6 @@
*/ */
#ifndef _MACROS_H #ifndef _MACROS_H
#define _MACROS_H #define _MACROS_H
#define SWAP(a, b) \
do { \
int _swap_var_ = (a); \
(a) = (b); \
(b) = _swap_var_; \
} while (0)
#define CHECK_FLAG(_var, _flag) ((_var) & (_flag)) #define CHECK_FLAG(_var, _flag) ((_var) & (_flag))
#define makeword(_h, _l) (((_h) << 16) + ((_l) & 0xffff)) #define makeword(_h, _l) (((_h) << 16) + ((_l) & 0xffff))
#define hiword(_v) ((_v) >> 16) #define hiword(_v) ((_v) >> 16)