From 554774506d24908c6c467f858cbfc271c6b2d760 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 12 Nov 2016 12:03:29 +0200 Subject: [PATCH] - fix compilation error with non-MSVC toolchains --- convert.cpp | 19 ++++++++----------- fileformat.cpp | 5 ++--- fileformat.h | 8 ++++---- main.cpp | 2 -- wadext.cpp | 41 +++++++++++++++++++++++++++++++++++++---- wadfile.cpp | 2 +- wadman.h | 2 +- 7 files changed, 53 insertions(+), 26 deletions(-) diff --git a/convert.cpp b/convert.cpp index ec601a3..306dbd4 100644 --- a/convert.cpp +++ b/convert.cpp @@ -55,13 +55,10 @@ */ -#include -#include -#include #include #include "zlib/zlib.h" #include "wadext.h" -#include "ResourceFile.h" +#include "resourcefile.h" #include "fileformat.h" #include "tarray.h" @@ -602,12 +599,12 @@ bool IsHack(const uint8_t *data, int length) { for (x = 0; x < x2; ++x) { - const column_t *col = (column_t*)((BYTE*)realpatch + cofs[x]); + const column_t *col = (column_t*)((uint8_t *)realpatch + cofs[x]); if (col->topdelta != 0 || col->length != 0) { return false; // It's not bad! } - col = (column_t *)((BYTE *)col + 256 + 4); + col = (column_t *)((uint8_t *)col + 256 + 4); if (col->topdelta != 0xFF) { return false; // More than one post in a column! @@ -635,7 +632,7 @@ bool PatchToPng(int options, const uint8_t *ldata, int length, const char *pngpa uint8_t *image = new uint8_t[width * height * 4]; memset(image, 0, width*height * 4); - maxcol = (const column_t *)((const BYTE *)patch + length - 3); + maxcol = (const column_t *)((const uint8_t *)patch + length - 3); // detect broken patches if (IsHack(ldata, length)) @@ -643,7 +640,7 @@ bool PatchToPng(int options, const uint8_t *ldata, int length, const char *pngpa // Draw the image to the buffer for (x = 0; x < width; ++x) { - const BYTE *in = (const BYTE *)patch + patch->columnofs[x] + 3; + const uint8_t *in = (const uint8_t *)patch + patch->columnofs[x] + 3; for (int y = height; y > 0; --y) { @@ -662,7 +659,7 @@ bool PatchToPng(int options, const uint8_t *ldata, int length, const char *pngpa // Draw the image to the buffer for (x = 0; x < width; ++x) { - const column_t *column = (const column_t *)((const BYTE *)patch + patch->columnofs[x]); + const column_t *column = (const column_t *)((const uint8_t *)patch + patch->columnofs[x]); int top = -1; while (column < maxcol && column->topdelta != 0xFF) @@ -686,7 +683,7 @@ bool PatchToPng(int options, const uint8_t *ldata, int length, const char *pngpa } if (len > 0) { - const BYTE *in = (const BYTE *)column + 3; + const uint8_t *in = (const uint8_t *)column + 3; for (int i = 0; i < len; ++i) { unsigned char *ddata = &image[(x + (top+i)*width) * 4]; @@ -697,7 +694,7 @@ bool PatchToPng(int options, const uint8_t *ldata, int length, const char *pngpa } } } - column = (const column_t *)((const BYTE *)column + column->length + 4); + column = (const column_t *)((const uint8_t *)column + column->length + 4); } } } diff --git a/fileformat.cpp b/fileformat.cpp index d390502..fe480a5 100644 --- a/fileformat.cpp +++ b/fileformat.cpp @@ -20,10 +20,9 @@ //-------------------------------------------------------------------------- // -#include -#include -#include #include +#include +#include #include "wadext.h" #include "fileformat.h" diff --git a/fileformat.h b/fileformat.h index 07db194..cc4f39a 100644 --- a/fileformat.h +++ b/fileformat.h @@ -70,8 +70,8 @@ struct FileType // posts are runs of non masked source pixels struct column_t { - BYTE topdelta; // -1 is the last post in a column - BYTE length; // length data bytes follows + uint8_t topdelta; // -1 is the last post in a column + uint8_t length; // length data bytes follows }; struct patch_t @@ -127,9 +127,9 @@ struct PCXHeader }; #ifndef __BIG_ENDIAN__ -#define MAKE_ID(a,b,c,d) ((DWORD)((a)|((b)<<8)|((c)<<16)|((d)<<24))) +#define MAKE_ID(a,b,c,d) ((uint32_t)((a)|((b)<<8)|((c)<<16)|((d)<<24))) #else -#define MAKE_ID(a,b,c,d) ((DWORD)((d)|((c)<<8)|((b)<<16)|((a)<<24))) +#define MAKE_ID(a,b,c,d) ((uint32_t)((d)|((c)<<8)|((b)<<16)|((a)<<24))) #endif #pragma pack() diff --git a/main.cpp b/main.cpp index da0367d..e86bb72 100644 --- a/main.cpp +++ b/main.cpp @@ -20,8 +20,6 @@ //-------------------------------------------------------------------------- // -#include -#include #include #include #include diff --git a/wadext.cpp b/wadext.cpp index 2a14182..305029c 100644 --- a/wadext.cpp +++ b/wadext.cpp @@ -20,13 +20,17 @@ //-------------------------------------------------------------------------- // -#include +#ifdef _MSC_VER #include -#include +#else // !_MSC_VER +#include +#include +#endif // _MSC_VER +#include #include #include #include "wadext.h" -#include "ResourceFile.h" +#include "resourcefile.h" #include "fileformat.h" #pragma warning(disable:4996) @@ -38,6 +42,34 @@ char maindir[128]; bool pstartfound=false; WadItemList PNames(-1); +#ifndef _MSC_VER + +static char* strlwr(char* str) +{ + for (char* ch = str; '\0' != *ch; ++ch) + { + *ch = tolower(*ch); + } + + return str; +} + +static char* strupr(char* str) +{ + for (char* ch = str; '\0' != *ch; ++ch) + { + *ch = tolower(*ch); + } + + return str; +} + +static int mkdir(const char *path) +{ + return mkdir(path, 0755); +} + +#endif // !_MSC_VER char * getdir(const char * lump) { @@ -133,7 +165,8 @@ void Extract(WadItemList *w,char * dir,const char * ext, int options, bool isfla // Flats are easy to misidentify so if we are in the flat namespace and the size is exactly 4096 bytes, let it pass as flat if (isflat && (ft.type & FG_MASK) != FG_GFX && (ft.type == FT_DOOMSND || ft.type == FT_MP3 || w->Length() == 4096)) { - ft = { FT_BINARY, ".LMP"}; + ft.type = FT_BINARY; + ft.extension = ".LMP"; } if (dir != NULL) diff --git a/wadfile.cpp b/wadfile.cpp index 4b235da..c02463a 100644 --- a/wadfile.cpp +++ b/wadfile.cpp @@ -22,7 +22,7 @@ #include #include -#include "ResourceFile.h" +#include "resourcefile.h" //========================================================================== // diff --git a/wadman.h b/wadman.h index c56ddee..125b182 100644 --- a/wadman.h +++ b/wadman.h @@ -2,7 +2,7 @@ #pragma pack(1) #pragma warning(disable:4200) -#include "ResourceFile.h" +#include "resourcefile.h" extern CWADFile *mainwad;