From e05f7bde23a632055e09f1ca7c1bca8c1a750e7c Mon Sep 17 00:00:00 2001 From: Zegeri Date: Thu, 27 Sep 2018 21:49:56 +0200 Subject: [PATCH] Avoid conflicting definitions with cximage and add include folder When DEBUG is on, ximajpg imports some xrCore headers. --- Externals/cximage/CMakeLists.txt | 1 + Externals/cximage/ximadef.h | 34 ++++----------------- Externals/cximage/ximage.cpp | 4 +-- Externals/cximage/ximaint.cpp | 8 ++--- Externals/cximage/ximaiter.h | 4 +-- Externals/cximage/ximapal.cpp | 14 ++++----- Externals/cximage/ximasel.cpp | 50 +++++++++++++++---------------- Externals/cximage/ximath.cpp | 8 ++--- src/xrGame/screenshot_manager.cpp | 3 -- src/xrGame/ui/UIServerInfo.cpp | 3 -- 10 files changed, 51 insertions(+), 78 deletions(-) diff --git a/Externals/cximage/CMakeLists.txt b/Externals/cximage/CMakeLists.txt index fd987cced87..5229f356c26 100644 --- a/Externals/cximage/CMakeLists.txt +++ b/Externals/cximage/CMakeLists.txt @@ -34,6 +34,7 @@ add_definitions(-DCXIMAGE_BUILD) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../../src ) add_library(cximage STATIC ${SOURCES} ${HEADERS}) diff --git a/Externals/cximage/ximadef.h b/Externals/cximage/ximadef.h index f372b940346..780f504edaa 100644 --- a/Externals/cximage/ximadef.h +++ b/Externals/cximage/ximadef.h @@ -2,6 +2,7 @@ #define __ximadefs_h #include "ximacfg.h" +#include "Common/Platform.hpp" #if defined(_AFXDLL)||defined(_USRDLL) #define DLL_EXP __declspec(dllexport) @@ -53,11 +54,11 @@ #define CXIMAGE_SUPPORT_WINDOWS 0 #endif -#ifndef min -#define min(a,b) (((a)<(b))?(a):(b)) +#ifndef MIN +#define MIN(a,b) (((a)<(b))?(a):(b)) #endif -#ifndef max -#define max(a,b) (((a)>(b))?(a):(b)) +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) #endif #ifndef PI @@ -94,14 +95,6 @@ typedef struct tagcomplex { #include #include -#ifndef CXIMAGE_NO_WIN32_DEFINES -typedef unsigned char BYTE; -typedef unsigned short WORD; -typedef unsigned long DWORD; -typedef unsigned int UINT; -typedef const char* LPCTSTR; -typedef unsigned int HANDLE; -#endif typedef DWORD COLORREF; typedef void* HRGN; typedef void* HDC; @@ -126,21 +119,7 @@ typedef int boolean; #define TCHAR char #define _T #endif -#ifndef CXIMAGE_NO_WIN32_DEFINES -typedef struct tagRECT -{ - long left; - long top; - long right; - long bottom; -} RECT; - -typedef struct tagPOINT -{ - long x; - long y; -} POINT; -#endif + typedef struct tagRGBQUAD { BYTE rgbBlue; BYTE rgbGreen; @@ -196,7 +175,6 @@ typedef struct tagRGBTRIPLE { #define GetRValue(rgb) ((BYTE)(rgb)) #define GetGValue(rgb) ((BYTE)(((WORD)(rgb)) >> 8)) #define GetBValue(rgb) ((BYTE)((rgb)>>16)) -#define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16))) #ifndef _COMPLEX_DEFINED diff --git a/Externals/cximage/ximage.cpp b/Externals/cximage/ximage.cpp index 91c1fd52972..44b52a874f1 100644 --- a/Externals/cximage/ximage.cpp +++ b/Externals/cximage/ximage.cpp @@ -460,7 +460,7 @@ bool CxImage::CreateFromArray(BYTE* pArray,DWORD dwWidth,DWORD dwHeight,DWORD dw src+=4; } } else { - memcpy(dst,src,min(info.dwEffWidth,dwBytesperline)); + memcpy(dst,src,MIN(info.dwEffWidth,dwBytesperline)); } } return true; @@ -500,7 +500,7 @@ bool CxImage::CreateFromMatrix(BYTE** ppMatrix,DWORD dwWidth,DWORD dwHeight,DWOR src+=4; } } else { - memcpy(dst,src,min(info.dwEffWidth,dwBytesperline)); + memcpy(dst,src,MIN(info.dwEffWidth,dwBytesperline)); } } } diff --git a/Externals/cximage/ximaint.cpp b/Externals/cximage/ximaint.cpp index 989d76cf71e..0cccb0b0373 100644 --- a/Externals/cximage/ximaint.cpp +++ b/Externals/cximage/ximaint.cpp @@ -26,8 +26,8 @@ void CxImage::OverflowCoordinates(long &x, long &y, OverflowMethod const ofMetho switch (ofMethod) { case OM_REPEAT: //clip coordinates - x=max(x,0); x=min(x, head.biWidth-1); - y=max(y,0); y=min(y, head.biHeight-1); + x=MAX(x,0); x=MIN(x, head.biWidth-1); + y=MAX(y,0); y=MIN(y, head.biHeight-1); break; case OM_WRAP: //wrap coordinates @@ -59,8 +59,8 @@ void CxImage::OverflowCoordinates(float &x, float &y, OverflowMethod const ofMet switch (ofMethod) { case OM_REPEAT: //clip coordinates - x=max(x,0); x=min(x, head.biWidth-1); - y=max(y,0); y=min(y, head.biHeight-1); + x=MAX(x,0); x=MIN(x, head.biWidth-1); + y=MAX(y,0); y=MIN(y, head.biHeight-1); break; case OM_WRAP: //wrap coordinates diff --git a/Externals/cximage/ximaiter.h b/Externals/cximage/ximaiter.h index 9788919b8f6..d69b1f8398a 100644 --- a/Externals/cximage/ximaiter.h +++ b/Externals/cximage/ximaiter.h @@ -140,7 +140,7 @@ inline void CImageIterator::SetY(int y) inline void CImageIterator::SetRow(BYTE *buf, int n) { if (n<0) n = (int)ima->GetEffWidth(); - else n = min(n,(int)ima->GetEffWidth()); + else n = MIN(n,(int)ima->GetEffWidth()); if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0)) memcpy(IterImage,buf,n); } @@ -148,7 +148,7 @@ inline void CImageIterator::SetRow(BYTE *buf, int n) inline void CImageIterator::GetRow(BYTE *buf, int n) { if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0)) - memcpy(buf,IterImage,min(n,(int)ima->GetEffWidth())); + memcpy(buf,IterImage,MIN(n,(int)ima->GetEffWidth())); } ///////////////////////////////////////////////////////////////////// inline BYTE* CImageIterator::GetRow() diff --git a/Externals/cximage/ximapal.cpp b/Externals/cximage/ximapal.cpp index b3bd3da39a5..97f0d9aeaa0 100644 --- a/Externals/cximage/ximapal.cpp +++ b/Externals/cximage/ximapal.cpp @@ -398,8 +398,8 @@ void CxImage::RGBtoBGR(BYTE *buffer, int length) { if (buffer && (head.biClrUsed==0)){ BYTE temp; - length = min(length,(int)info.dwEffWidth); - length = min(length,(int)(3*head.biWidth)); + length = MIN(length,(int)info.dwEffWidth); + length = MIN(length,(int)(3*head.biWidth)); for (int i=0;i r2.left) info.rSelectionBox.left = max(0L,min(head.biWidth,r2.left)); - if (info.rSelectionBox.right <= r2.right) info.rSelectionBox.right = max(0L,min(head.biWidth,r2.right+1)); - if (info.rSelectionBox.bottom > r2.bottom) info.rSelectionBox.bottom = max(0L,min(head.biHeight,r2.bottom)); + if (info.rSelectionBox.top <= r2.top) info.rSelectionBox.top = MAX(0L,MIN(head.biHeight,r2.top+1)); + if (info.rSelectionBox.left > r2.left) info.rSelectionBox.left = MAX(0L,MIN(head.biWidth,r2.left)); + if (info.rSelectionBox.right <= r2.right) info.rSelectionBox.right = MAX(0L,MIN(head.biWidth,r2.right+1)); + if (info.rSelectionBox.bottom > r2.bottom) info.rSelectionBox.bottom = MAX(0L,MIN(head.biHeight,r2.bottom)); - long ymin = max(0L,min(head.biHeight,r2.bottom)); - long ymax = max(0L,min(head.biHeight,r2.top+1)); - long xmin = max(0L,min(head.biWidth,r2.left)); - long xmax = max(0L,min(head.biWidth,r2.right+1)); + long ymin = MAX(0L,MIN(head.biHeight,r2.bottom)); + long ymax = MAX(0L,MIN(head.biHeight,r2.top+1)); + long xmin = MAX(0L,MIN(head.biWidth,r2.left)); + long xmax = MAX(0L,MIN(head.biWidth,r2.right+1)); for (long y=ymin; y (xcenter - xradius)) info.rSelectionBox.left = max(0L,min(head.biWidth,(xcenter - xradius))); - if (info.rSelectionBox.right <= (xcenter + xradius)) info.rSelectionBox.right = max(0L,min(head.biWidth,(xcenter + xradius + 1))); - if (info.rSelectionBox.bottom > (ycenter - yradius)) info.rSelectionBox.bottom = max(0L,min(head.biHeight,(ycenter - yradius))); - if (info.rSelectionBox.top <= (ycenter + yradius)) info.rSelectionBox.top = max(0L,min(head.biHeight,(ycenter + yradius + 1))); + if (info.rSelectionBox.left > (xcenter - xradius)) info.rSelectionBox.left = MAX(0L,MIN(head.biWidth,(xcenter - xradius))); + if (info.rSelectionBox.right <= (xcenter + xradius)) info.rSelectionBox.right = MAX(0L,MIN(head.biWidth,(xcenter + xradius + 1))); + if (info.rSelectionBox.bottom > (ycenter - yradius)) info.rSelectionBox.bottom = MAX(0L,MIN(head.biHeight,(ycenter - yradius))); + if (info.rSelectionBox.top <= (ycenter + yradius)) info.rSelectionBox.top = MAX(0L,MIN(head.biHeight,(ycenter + yradius + 1))); - long xmin = max(0L,min(head.biWidth,xcenter - xradius)); - long xmax = max(0L,min(head.biWidth,xcenter + xradius + 1)); - long ymin = max(0L,min(head.biHeight,ycenter - yradius)); - long ymax = max(0L,min(head.biHeight,ycenter + yradius + 1)); + long xmin = MAX(0L,MIN(head.biWidth,xcenter - xradius)); + long xmax = MAX(0L,MIN(head.biWidth,xcenter + xradius + 1)); + long ymin = MAX(0L,MIN(head.biHeight,ycenter - yradius)); + long ymax = MAX(0L,MIN(head.biHeight,ycenter + yradius + 1)); long y,yo; - for (y=ymin; yx < next->x) {r2.left=current->x; r2.right=next->x; } else {r2.left=next->x ; r2.right=current->x; } if (current->y < next->y) {r2.bottom=current->y; r2.top=next->y; } else {r2.bottom=next->y ; r2.top=current->y; } - if (localbox.top < r2.top) localbox.top = max(0L,min(head.biHeight-1,r2.top+1)); - if (localbox.left > r2.left) localbox.left = max(0L,min(head.biWidth-1,r2.left-1)); - if (localbox.right < r2.right) localbox.right = max(0L,min(head.biWidth-1,r2.right+1)); - if (localbox.bottom > r2.bottom) localbox.bottom = max(0L,min(head.biHeight-1,r2.bottom-1)); + if (localbox.top < r2.top) localbox.top = MAX(0L,MIN(head.biHeight-1,r2.top+1)); + if (localbox.left > r2.left) localbox.left = MAX(0L,MIN(head.biWidth-1,r2.left-1)); + if (localbox.right < r2.right) localbox.right = MAX(0L,MIN(head.biWidth-1,r2.right+1)); + if (localbox.bottom > r2.bottom) localbox.bottom = MAX(0L,MIN(head.biHeight-1,r2.bottom-1)); i++; } @@ -385,10 +385,10 @@ bool CxImage::SelectionAddPolygon(POINT *points, long npoints, BYTE level) for (x=localbox.left; x<=localbox.right; x++) if (plocal[x + yoffset]!=1) pSelection[x + yoffset]=level; } - if (info.rSelectionBox.top <= localbox.top) info.rSelectionBox.top = min(head.biHeight,localbox.top + 1); - if (info.rSelectionBox.left > localbox.left) info.rSelectionBox.left = min(head.biWidth,localbox.left); - if (info.rSelectionBox.right <= localbox.right) info.rSelectionBox.right = min(head.biWidth,localbox.right + 1); - if (info.rSelectionBox.bottom > localbox.bottom) info.rSelectionBox.bottom = min(head.biHeight,localbox.bottom); + if (info.rSelectionBox.top <= localbox.top) info.rSelectionBox.top = MIN(head.biHeight,localbox.top + 1); + if (info.rSelectionBox.left > localbox.left) info.rSelectionBox.left = MIN(head.biWidth,localbox.left); + if (info.rSelectionBox.right <= localbox.right) info.rSelectionBox.right = MIN(head.biWidth,localbox.right + 1); + if (info.rSelectionBox.bottom > localbox.bottom) info.rSelectionBox.bottom = MIN(head.biHeight,localbox.bottom); cxfree(plocal);//free(plocal); cxfree(pix);//free(pix); diff --git a/Externals/cximage/ximath.cpp b/Externals/cximage/ximath.cpp index 37533e2280c..3e2e26d2e66 100644 --- a/Externals/cximage/ximath.cpp +++ b/Externals/cximage/ximath.cpp @@ -64,10 +64,10 @@ CxRect2 CxRect2::CrossSection(CxRect2 const &r2) const */ { CxRect2 cs; - cs.botLeft.x=max(botLeft.x, r2.botLeft.x); - cs.botLeft.y=max(botLeft.y, r2.botLeft.y); - cs.topRight.x=min(topRight.x, r2.topRight.x); - cs.topRight.y=min(topRight.y, r2.topRight.y); + cs.botLeft.x=MAX(botLeft.x, r2.botLeft.x); + cs.botLeft.y=MAX(botLeft.y, r2.botLeft.y); + cs.topRight.x=MIN(topRight.x, r2.topRight.x); + cs.topRight.y=MIN(topRight.y, r2.topRight.y); if (cs.botLeft.x<=cs.topRight.x && cs.botLeft.y<=cs.topRight.y) { return cs; } else { diff --git a/src/xrGame/screenshot_manager.cpp b/src/xrGame/screenshot_manager.cpp index 53a1c72b007..bcd94b887ea 100644 --- a/src/xrGame/screenshot_manager.cpp +++ b/src/xrGame/screenshot_manager.cpp @@ -13,9 +13,6 @@ #include #endif -#ifdef LINUX // Avoid conflicting macros -#define CXIMAGE_NO_WIN32_DEFINES -#endif #include "ximage.h" #include "xmemfile.h" diff --git a/src/xrGame/ui/UIServerInfo.cpp b/src/xrGame/ui/UIServerInfo.cpp index 254a33b579d..9192ed1ba5a 100644 --- a/src/xrGame/ui/UIServerInfo.cpp +++ b/src/xrGame/ui/UIServerInfo.cpp @@ -8,9 +8,6 @@ #include "UIGameCustom.h" #include "Level.h" #include "game_cl_mp.h" -#ifdef LINUX // Avoid conflicting macros -#define CXIMAGE_NO_WIN32_DEFINES -#endif #include "ximage.h" #include "xmemfile.h"