mirror of
https://github.com/ZDoom/wadext.git
synced 2024-11-21 11:21:19 +00:00
- fix compilation error with non-MSVC toolchains
This commit is contained in:
parent
97dd5ed070
commit
554774506d
7 changed files with 53 additions and 26 deletions
19
convert.cpp
19
convert.cpp
|
@ -55,13 +55,10 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,9 @@
|
|||
//--------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "wadext.h"
|
||||
#include "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()
|
||||
|
|
2
main.cpp
2
main.cpp
|
@ -20,8 +20,6 @@
|
|||
//--------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
|
41
wadext.cpp
41
wadext.cpp
|
@ -20,13 +20,17 @@
|
|||
//--------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include <windows.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#else // !_MSC_VER
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#endif // _MSC_VER
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#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)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "ResourceFile.h"
|
||||
#include "resourcefile.h"
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
2
wadman.h
2
wadman.h
|
@ -2,7 +2,7 @@
|
|||
#pragma pack(1)
|
||||
#pragma warning(disable:4200)
|
||||
|
||||
#include "ResourceFile.h"
|
||||
#include "resourcefile.h"
|
||||
|
||||
extern CWADFile *mainwad;
|
||||
|
||||
|
|
Loading…
Reference in a new issue