Skip to content

Commit e05f7bd

Browse files
Zegeriq4a
authored andcommitted
Avoid conflicting definitions with cximage and add include folder
When DEBUG is on, ximajpg imports some xrCore headers.
1 parent cc46ec3 commit e05f7bd

File tree

10 files changed

+51
-78
lines changed

10 files changed

+51
-78
lines changed

Externals/cximage/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ add_definitions(-DCXIMAGE_BUILD)
3434

3535
include_directories(
3636
${CMAKE_CURRENT_SOURCE_DIR}
37+
${CMAKE_CURRENT_SOURCE_DIR}/../../src
3738
)
3839

3940
add_library(cximage STATIC ${SOURCES} ${HEADERS})

Externals/cximage/ximadef.h

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define __ximadefs_h
33

44
#include "ximacfg.h"
5+
#include "Common/Platform.hpp"
56

67
#if defined(_AFXDLL)||defined(_USRDLL)
78
#define DLL_EXP __declspec(dllexport)
@@ -53,11 +54,11 @@
5354
#define CXIMAGE_SUPPORT_WINDOWS 0
5455
#endif
5556

56-
#ifndef min
57-
#define min(a,b) (((a)<(b))?(a):(b))
57+
#ifndef MIN
58+
#define MIN(a,b) (((a)<(b))?(a):(b))
5859
#endif
59-
#ifndef max
60-
#define max(a,b) (((a)>(b))?(a):(b))
60+
#ifndef MAX
61+
#define MAX(a,b) (((a)>(b))?(a):(b))
6162
#endif
6263

6364
#ifndef PI
@@ -94,14 +95,6 @@ typedef struct tagcomplex {
9495
#include <string.h>
9596
#include <ctype.h>
9697

97-
#ifndef CXIMAGE_NO_WIN32_DEFINES
98-
typedef unsigned char BYTE;
99-
typedef unsigned short WORD;
100-
typedef unsigned long DWORD;
101-
typedef unsigned int UINT;
102-
typedef const char* LPCTSTR;
103-
typedef unsigned int HANDLE;
104-
#endif
10598
typedef DWORD COLORREF;
10699
typedef void* HRGN;
107100
typedef void* HDC;
@@ -126,21 +119,7 @@ typedef int boolean;
126119
#define TCHAR char
127120
#define _T
128121
#endif
129-
#ifndef CXIMAGE_NO_WIN32_DEFINES
130-
typedef struct tagRECT
131-
{
132-
long left;
133-
long top;
134-
long right;
135-
long bottom;
136-
} RECT;
137-
138-
typedef struct tagPOINT
139-
{
140-
long x;
141-
long y;
142-
} POINT;
143-
#endif
122+
144123
typedef struct tagRGBQUAD {
145124
BYTE rgbBlue;
146125
BYTE rgbGreen;
@@ -196,7 +175,6 @@ typedef struct tagRGBTRIPLE {
196175
#define GetRValue(rgb) ((BYTE)(rgb))
197176
#define GetGValue(rgb) ((BYTE)(((WORD)(rgb)) >> 8))
198177
#define GetBValue(rgb) ((BYTE)((rgb)>>16))
199-
#define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
200178

201179
#ifndef _COMPLEX_DEFINED
202180

Externals/cximage/ximage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ bool CxImage::CreateFromArray(BYTE* pArray,DWORD dwWidth,DWORD dwHeight,DWORD dw
460460
src+=4;
461461
}
462462
} else {
463-
memcpy(dst,src,min(info.dwEffWidth,dwBytesperline));
463+
memcpy(dst,src,MIN(info.dwEffWidth,dwBytesperline));
464464
}
465465
}
466466
return true;
@@ -500,7 +500,7 @@ bool CxImage::CreateFromMatrix(BYTE** ppMatrix,DWORD dwWidth,DWORD dwHeight,DWOR
500500
src+=4;
501501
}
502502
} else {
503-
memcpy(dst,src,min(info.dwEffWidth,dwBytesperline));
503+
memcpy(dst,src,MIN(info.dwEffWidth,dwBytesperline));
504504
}
505505
}
506506
}

Externals/cximage/ximaint.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ void CxImage::OverflowCoordinates(long &x, long &y, OverflowMethod const ofMetho
2626
switch (ofMethod) {
2727
case OM_REPEAT:
2828
//clip coordinates
29-
x=max(x,0); x=min(x, head.biWidth-1);
30-
y=max(y,0); y=min(y, head.biHeight-1);
29+
x=MAX(x,0); x=MIN(x, head.biWidth-1);
30+
y=MAX(y,0); y=MIN(y, head.biHeight-1);
3131
break;
3232
case OM_WRAP:
3333
//wrap coordinates
@@ -59,8 +59,8 @@ void CxImage::OverflowCoordinates(float &x, float &y, OverflowMethod const ofMet
5959
switch (ofMethod) {
6060
case OM_REPEAT:
6161
//clip coordinates
62-
x=max(x,0); x=min(x, head.biWidth-1);
63-
y=max(y,0); y=min(y, head.biHeight-1);
62+
x=MAX(x,0); x=MIN(x, head.biWidth-1);
63+
y=MAX(y,0); y=MIN(y, head.biHeight-1);
6464
break;
6565
case OM_WRAP:
6666
//wrap coordinates

Externals/cximage/ximaiter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,15 @@ inline void CImageIterator::SetY(int y)
140140
inline void CImageIterator::SetRow(BYTE *buf, int n)
141141
{
142142
if (n<0) n = (int)ima->GetEffWidth();
143-
else n = min(n,(int)ima->GetEffWidth());
143+
else n = MIN(n,(int)ima->GetEffWidth());
144144

145145
if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0)) memcpy(IterImage,buf,n);
146146
}
147147
/////////////////////////////////////////////////////////////////////
148148
inline void CImageIterator::GetRow(BYTE *buf, int n)
149149
{
150150
if ((IterImage!=NULL)&&(buf!=NULL)&&(n>0))
151-
memcpy(buf,IterImage,min(n,(int)ima->GetEffWidth()));
151+
memcpy(buf,IterImage,MIN(n,(int)ima->GetEffWidth()));
152152
}
153153
/////////////////////////////////////////////////////////////////////
154154
inline BYTE* CImageIterator::GetRow()

Externals/cximage/ximapal.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,8 @@ void CxImage::RGBtoBGR(BYTE *buffer, int length)
398398
{
399399
if (buffer && (head.biClrUsed==0)){
400400
BYTE temp;
401-
length = min(length,(int)info.dwEffWidth);
402-
length = min(length,(int)(3*head.biWidth));
401+
length = MIN(length,(int)info.dwEffWidth);
402+
length = MIN(length,(int)(3*head.biWidth));
403403
for (int i=0;i<length;i+=3){
404404
temp = buffer[i]; buffer[i] = buffer[i+2]; buffer[i+2] = temp;
405405
}
@@ -444,7 +444,7 @@ void CxImage::SetPalette(DWORD n, BYTE *r, BYTE *g, BYTE *b)
444444
if (!g) g = r;
445445
if (!b) b = g;
446446
RGBQUAD* ppal=GetPalette();
447-
DWORD m=min(n,head.biClrUsed);
447+
DWORD m=MIN(n,head.biClrUsed);
448448
for (DWORD i=0; i<m;i++){
449449
ppal[i].rgbRed=r[i];
450450
ppal[i].rgbGreen=g[i];
@@ -457,7 +457,7 @@ void CxImage::SetPalette(rgb_color *rgb,DWORD nColors)
457457
{
458458
if ((!rgb)||(pDib==NULL)||(head.biClrUsed==0)) return;
459459
RGBQUAD* ppal=GetPalette();
460-
DWORD m=min(nColors,head.biClrUsed);
460+
DWORD m=MIN(nColors,head.biClrUsed);
461461
for (DWORD i=0; i<m;i++){
462462
ppal[i].rgbRed=rgb[i].r;
463463
ppal[i].rgbGreen=rgb[i].g;
@@ -469,7 +469,7 @@ void CxImage::SetPalette(rgb_color *rgb,DWORD nColors)
469469
void CxImage::SetPalette(RGBQUAD* pPal,DWORD nColors)
470470
{
471471
if ((pPal==NULL)||(pDib==NULL)||(head.biClrUsed==0)) return;
472-
memcpy(GetPalette(),pPal,min(GetPaletteSize(),nColors*sizeof(RGBQUAD)));
472+
memcpy(GetPalette(),pPal,MIN(GetPaletteSize(),nColors*sizeof(RGBQUAD)));
473473
info.last_c_isvalid = false;
474474
}
475475
////////////////////////////////////////////////////////////////////////////////
@@ -654,10 +654,10 @@ void CxImage::SetClrImportant(DWORD ncolors)
654654

655655
switch(head.biBitCount){
656656
case 1:
657-
head.biClrImportant = min(ncolors,2);
657+
head.biClrImportant = MIN(ncolors,2);
658658
break;
659659
case 4:
660-
head.biClrImportant = min(ncolors,16);
660+
head.biClrImportant = MIN(ncolors,16);
661661
break;
662662
case 8:
663663
head.biClrImportant = ncolors;

Externals/cximage/ximasel.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ bool CxImage::SelectionAddRect(RECT r, BYTE level)
113113
if (r.left<r.right) {r2.left=r.left; r2.right=r.right; } else {r2.left=r.right ; r2.right=r.left; }
114114
if (r.bottom<r.top) {r2.bottom=r.bottom; r2.top=r.top; } else {r2.bottom=r.top ; r2.top=r.bottom; }
115115

116-
if (info.rSelectionBox.top <= r2.top) info.rSelectionBox.top = max(0L,min(head.biHeight,r2.top+1));
117-
if (info.rSelectionBox.left > r2.left) info.rSelectionBox.left = max(0L,min(head.biWidth,r2.left));
118-
if (info.rSelectionBox.right <= r2.right) info.rSelectionBox.right = max(0L,min(head.biWidth,r2.right+1));
119-
if (info.rSelectionBox.bottom > r2.bottom) info.rSelectionBox.bottom = max(0L,min(head.biHeight,r2.bottom));
116+
if (info.rSelectionBox.top <= r2.top) info.rSelectionBox.top = MAX(0L,MIN(head.biHeight,r2.top+1));
117+
if (info.rSelectionBox.left > r2.left) info.rSelectionBox.left = MAX(0L,MIN(head.biWidth,r2.left));
118+
if (info.rSelectionBox.right <= r2.right) info.rSelectionBox.right = MAX(0L,MIN(head.biWidth,r2.right+1));
119+
if (info.rSelectionBox.bottom > r2.bottom) info.rSelectionBox.bottom = MAX(0L,MIN(head.biHeight,r2.bottom));
120120

121-
long ymin = max(0L,min(head.biHeight,r2.bottom));
122-
long ymax = max(0L,min(head.biHeight,r2.top+1));
123-
long xmin = max(0L,min(head.biWidth,r2.left));
124-
long xmax = max(0L,min(head.biWidth,r2.right+1));
121+
long ymin = MAX(0L,MIN(head.biHeight,r2.bottom));
122+
long ymax = MAX(0L,MIN(head.biHeight,r2.top+1));
123+
long xmin = MAX(0L,MIN(head.biWidth,r2.left));
124+
long xmax = MAX(0L,MIN(head.biWidth,r2.right+1));
125125

126126
for (long y=ymin; y<ymax; y++)
127127
memset(pSelection + xmin + y * head.biWidth, level, xmax-xmin);
@@ -144,18 +144,18 @@ bool CxImage::SelectionAddEllipse(RECT r, BYTE level)
144144
long xcenter = (r.right + r.left)/2;
145145
long ycenter = (r.top + r.bottom)/2;
146146

147-
if (info.rSelectionBox.left > (xcenter - xradius)) info.rSelectionBox.left = max(0L,min(head.biWidth,(xcenter - xradius)));
148-
if (info.rSelectionBox.right <= (xcenter + xradius)) info.rSelectionBox.right = max(0L,min(head.biWidth,(xcenter + xradius + 1)));
149-
if (info.rSelectionBox.bottom > (ycenter - yradius)) info.rSelectionBox.bottom = max(0L,min(head.biHeight,(ycenter - yradius)));
150-
if (info.rSelectionBox.top <= (ycenter + yradius)) info.rSelectionBox.top = max(0L,min(head.biHeight,(ycenter + yradius + 1)));
147+
if (info.rSelectionBox.left > (xcenter - xradius)) info.rSelectionBox.left = MAX(0L,MIN(head.biWidth,(xcenter - xradius)));
148+
if (info.rSelectionBox.right <= (xcenter + xradius)) info.rSelectionBox.right = MAX(0L,MIN(head.biWidth,(xcenter + xradius + 1)));
149+
if (info.rSelectionBox.bottom > (ycenter - yradius)) info.rSelectionBox.bottom = MAX(0L,MIN(head.biHeight,(ycenter - yradius)));
150+
if (info.rSelectionBox.top <= (ycenter + yradius)) info.rSelectionBox.top = MAX(0L,MIN(head.biHeight,(ycenter + yradius + 1)));
151151

152-
long xmin = max(0L,min(head.biWidth,xcenter - xradius));
153-
long xmax = max(0L,min(head.biWidth,xcenter + xradius + 1));
154-
long ymin = max(0L,min(head.biHeight,ycenter - yradius));
155-
long ymax = max(0L,min(head.biHeight,ycenter + yradius + 1));
152+
long xmin = MAX(0L,MIN(head.biWidth,xcenter - xradius));
153+
long xmax = MAX(0L,MIN(head.biWidth,xcenter + xradius + 1));
154+
long ymin = MAX(0L,MIN(head.biHeight,ycenter - yradius));
155+
long ymax = MAX(0L,MIN(head.biHeight,ycenter + yradius + 1));
156156

157157
long y,yo;
158-
for (y=ymin; y<min(ycenter,ymax); y++){
158+
for (y=ymin; y<MIN(ycenter,ymax); y++){
159159
for (long x=xmin; x<xmax; x++){
160160
yo = (long)(ycenter - yradius * sqrt(1-pow((float)(x - xcenter)/(float)xradius,2)));
161161
if (yo<y) pSelection[x + y * head.biWidth] = level;
@@ -268,10 +268,10 @@ bool CxImage::SelectionAddPolygon(POINT *points, long npoints, BYTE level)
268268
RECT r2;
269269
if (current->x < next->x) {r2.left=current->x; r2.right=next->x; } else {r2.left=next->x ; r2.right=current->x; }
270270
if (current->y < next->y) {r2.bottom=current->y; r2.top=next->y; } else {r2.bottom=next->y ; r2.top=current->y; }
271-
if (localbox.top < r2.top) localbox.top = max(0L,min(head.biHeight-1,r2.top+1));
272-
if (localbox.left > r2.left) localbox.left = max(0L,min(head.biWidth-1,r2.left-1));
273-
if (localbox.right < r2.right) localbox.right = max(0L,min(head.biWidth-1,r2.right+1));
274-
if (localbox.bottom > r2.bottom) localbox.bottom = max(0L,min(head.biHeight-1,r2.bottom-1));
271+
if (localbox.top < r2.top) localbox.top = MAX(0L,MIN(head.biHeight-1,r2.top+1));
272+
if (localbox.left > r2.left) localbox.left = MAX(0L,MIN(head.biWidth-1,r2.left-1));
273+
if (localbox.right < r2.right) localbox.right = MAX(0L,MIN(head.biWidth-1,r2.right+1));
274+
if (localbox.bottom > r2.bottom) localbox.bottom = MAX(0L,MIN(head.biHeight-1,r2.bottom-1));
275275

276276
i++;
277277
}
@@ -385,10 +385,10 @@ bool CxImage::SelectionAddPolygon(POINT *points, long npoints, BYTE level)
385385
for (x=localbox.left; x<=localbox.right; x++)
386386
if (plocal[x + yoffset]!=1) pSelection[x + yoffset]=level;
387387
}
388-
if (info.rSelectionBox.top <= localbox.top) info.rSelectionBox.top = min(head.biHeight,localbox.top + 1);
389-
if (info.rSelectionBox.left > localbox.left) info.rSelectionBox.left = min(head.biWidth,localbox.left);
390-
if (info.rSelectionBox.right <= localbox.right) info.rSelectionBox.right = min(head.biWidth,localbox.right + 1);
391-
if (info.rSelectionBox.bottom > localbox.bottom) info.rSelectionBox.bottom = min(head.biHeight,localbox.bottom);
388+
if (info.rSelectionBox.top <= localbox.top) info.rSelectionBox.top = MIN(head.biHeight,localbox.top + 1);
389+
if (info.rSelectionBox.left > localbox.left) info.rSelectionBox.left = MIN(head.biWidth,localbox.left);
390+
if (info.rSelectionBox.right <= localbox.right) info.rSelectionBox.right = MIN(head.biWidth,localbox.right + 1);
391+
if (info.rSelectionBox.bottom > localbox.bottom) info.rSelectionBox.bottom = MIN(head.biHeight,localbox.bottom);
392392

393393
cxfree(plocal);//free(plocal);
394394
cxfree(pix);//free(pix);

Externals/cximage/ximath.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ CxRect2 CxRect2::CrossSection(CxRect2 const &r2) const
6464
*/
6565
{
6666
CxRect2 cs;
67-
cs.botLeft.x=max(botLeft.x, r2.botLeft.x);
68-
cs.botLeft.y=max(botLeft.y, r2.botLeft.y);
69-
cs.topRight.x=min(topRight.x, r2.topRight.x);
70-
cs.topRight.y=min(topRight.y, r2.topRight.y);
67+
cs.botLeft.x=MAX(botLeft.x, r2.botLeft.x);
68+
cs.botLeft.y=MAX(botLeft.y, r2.botLeft.y);
69+
cs.topRight.x=MIN(topRight.x, r2.topRight.x);
70+
cs.topRight.y=MIN(topRight.y, r2.topRight.y);
7171
if (cs.botLeft.x<=cs.topRight.x && cs.botLeft.y<=cs.topRight.y) {
7272
return cs;
7373
} else {

src/xrGame/screenshot_manager.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
#include <ddraw.h>
1414
#endif
1515

16-
#ifdef LINUX // Avoid conflicting macros
17-
#define CXIMAGE_NO_WIN32_DEFINES
18-
#endif
1916
#include "ximage.h"
2017
#include "xmemfile.h"
2118

src/xrGame/ui/UIServerInfo.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
#include "UIGameCustom.h"
99
#include "Level.h"
1010
#include "game_cl_mp.h"
11-
#ifdef LINUX // Avoid conflicting macros
12-
#define CXIMAGE_NO_WIN32_DEFINES
13-
#endif
1411
#include "ximage.h"
1512
#include "xmemfile.h"
1613

0 commit comments

Comments
 (0)