mirror of
https://git.do.srb2.org/STJr/ZenNode.git
synced 2024-11-26 22:21:16 +00:00
Get it to compile on win32/mingw
No idea if it actually works properly though, didn't test.
This commit is contained in:
parent
2e174e655d
commit
1d5d4ee39c
3 changed files with 39 additions and 26 deletions
36
DOOM/wad.cpp
36
DOOM/wad.cpp
|
@ -28,6 +28,8 @@
|
||||||
//
|
//
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -153,7 +155,7 @@ WAD::~WAD ()
|
||||||
|
|
||||||
free ( m_Name );
|
free ( m_Name );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WAD::EnlargeDirectory ( int holePos, int entries )
|
bool WAD::EnlargeDirectory ( int holePos, int entries )
|
||||||
{
|
{
|
||||||
int newSize = m_Header.dirSize + entries;
|
int newSize = m_Header.dirSize + entries;
|
||||||
|
@ -235,7 +237,7 @@ void WAD::FindMarkers ()
|
||||||
m_FlatStart = FindDir ( "F_START" );
|
m_FlatStart = FindDir ( "F_START" );
|
||||||
m_FlatEnd = FindDir ( "F_END", m_FlatStart );
|
m_FlatEnd = FindDir ( "F_END", m_FlatStart );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WAD::ReadHeader ( wadHeader *header )
|
bool WAD::ReadHeader ( wadHeader *header )
|
||||||
{
|
{
|
||||||
ReadBytes ( header, sizeof ( wadHeader ));
|
ReadBytes ( header, sizeof ( wadHeader ));
|
||||||
|
@ -333,7 +335,7 @@ UINT32 WAD::IndexOf ( const wadDirEntry *entry ) const
|
||||||
{
|
{
|
||||||
return (( entry < m_Directory ) || ( entry > m_Directory + m_Header.dirSize )) ? -1 : entry - m_Directory;
|
return (( entry < m_Directory ) || ( entry > m_Directory + m_Header.dirSize )) ? -1 : entry - m_Directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WAD::SetList ( wadList *_list )
|
void WAD::SetList ( wadList *_list )
|
||||||
{
|
{
|
||||||
m_List = _list;
|
m_List = _list;
|
||||||
|
@ -407,7 +409,7 @@ void WAD::Seek ( UINT32 offset )
|
||||||
m_Status = ws_SEEK_ERROR;
|
m_Status = ws_SEEK_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WAD::ReadBytes ( void *ptr , UINT32 size, UINT32 count )
|
void WAD::ReadBytes ( void *ptr , UINT32 size, UINT32 count )
|
||||||
{
|
{
|
||||||
m_Status = ws_OK;
|
m_Status = ws_OK;
|
||||||
|
@ -417,7 +419,7 @@ void WAD::ReadBytes ( void *ptr , UINT32 size, UINT32 count )
|
||||||
m_Status = ws_READ_ERROR;
|
m_Status = ws_READ_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *WAD::ReadEntry ( const char *name, UINT32 *size, const wadDirEntry *start, const wadDirEntry *end, bool cache )
|
void *WAD::ReadEntry ( const char *name, UINT32 *size, const wadDirEntry *start, const wadDirEntry *end, bool cache )
|
||||||
{
|
{
|
||||||
return ReadEntry ( FindDir ( name, start, end ), size, cache );
|
return ReadEntry ( FindDir ( name, start, end ), size, cache );
|
||||||
|
@ -486,7 +488,7 @@ bool WAD::WriteEntry ( const wadDirEntry *entry, UINT32 newSize, void *newStuff,
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WAD::OpenFile ()
|
void WAD::OpenFile ()
|
||||||
{
|
{
|
||||||
if ( m_File != NULL ) fclose ( m_File );
|
if ( m_File != NULL ) fclose ( m_File );
|
||||||
|
@ -538,7 +540,7 @@ void WAD::OpenFile ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WAD::CloseFile ()
|
void WAD::CloseFile ()
|
||||||
{
|
{
|
||||||
m_bValid = false;
|
m_bValid = false;
|
||||||
|
@ -567,7 +569,7 @@ void WAD::CloseFile ()
|
||||||
|
|
||||||
memset ( &m_Header, 0, sizeof ( m_Header ));
|
memset ( &m_Header, 0, sizeof ( m_Header ));
|
||||||
}
|
}
|
||||||
|
|
||||||
const wadDirEntry *WAD::GetDir ( UINT32 index ) const
|
const wadDirEntry *WAD::GetDir ( UINT32 index ) const
|
||||||
{
|
{
|
||||||
return ( index >= m_Header.dirSize ) ? ( const wadDirEntry * ) NULL : &m_Directory [index];
|
return ( index >= m_Header.dirSize ) ? ( const wadDirEntry * ) NULL : &m_Directory [index];
|
||||||
|
@ -604,7 +606,7 @@ bool WAD::HasChanged () const
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WAD::InsertBefore ( const wLumpName *name, UINT32 newSize, void *newStuff, bool owner, const wadDirEntry *entry )
|
bool WAD::InsertBefore ( const wLumpName *name, UINT32 newSize, void *newStuff, bool owner, const wadDirEntry *entry )
|
||||||
{
|
{
|
||||||
UINT32 index = IndexOf ( entry );
|
UINT32 index = IndexOf ( entry );
|
||||||
|
@ -642,7 +644,7 @@ bool WAD::InsertAfter ( const wLumpName *name, UINT32 newSize, void *newStuff, b
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WAD::Remove ( const wLumpName *lump, const wadDirEntry *start, const wadDirEntry *end )
|
bool WAD::Remove ( const wLumpName *lump, const wadDirEntry *start, const wadDirEntry *end )
|
||||||
{
|
{
|
||||||
const wadDirEntry *entry = FindDir ( *lump, start, end );
|
const wadDirEntry *entry = FindDir ( *lump, start, end );
|
||||||
|
@ -652,14 +654,14 @@ bool WAD::Remove ( const wLumpName *lump, const wadDirEntry *start, const wadDir
|
||||||
|
|
||||||
return ReduceDirectory ( index, 1 );
|
return ReduceDirectory ( index, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// TBD
|
// TBD
|
||||||
int InsertBefore ( const wLumpName *, UINT32, void *, bool, const wadDirEntry * = NULL );
|
int InsertBefore ( const wLumpName *, UINT32, void *, bool, const wadDirEntry * = NULL );
|
||||||
int InsertAfter ( const wLumpName *, UINT32, void *, bool, const wadDirEntry * = NULL );
|
int InsertAfter ( const wLumpName *, UINT32, void *, bool, const wadDirEntry * = NULL );
|
||||||
// TBD
|
// TBD
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool WAD::SaveFile ( const char *newName )
|
bool WAD::SaveFile ( const char *newName )
|
||||||
{
|
{
|
||||||
if ( newName == NULL ) newName = m_Name;
|
if ( newName == NULL ) newName = m_Name;
|
||||||
|
@ -770,7 +772,7 @@ bool WAD::SaveFile ( const char *newName )
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wadList::wadList () :
|
wadList::wadList () :
|
||||||
m_DirSize ( 0 ),
|
m_DirSize ( 0 ),
|
||||||
m_MaxSize ( 0 ),
|
m_MaxSize ( 0 ),
|
||||||
|
@ -853,7 +855,7 @@ void wadList::UpdateDirectory ()
|
||||||
ptr = ptr->Next;
|
ptr = ptr->Next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wadList::Add ( WAD *wad )
|
bool wadList::Add ( WAD *wad )
|
||||||
{
|
{
|
||||||
if (( m_Type == wt_UNKNOWN ) && ( m_Style == wst_UNKNOWN )) {
|
if (( m_Type == wt_UNKNOWN ) && ( m_Style == wst_UNKNOWN )) {
|
||||||
|
@ -942,7 +944,7 @@ bool wadList::Remove ( WAD *wad )
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT32 wadList::IndexOf ( const wadListDirEntry *entry ) const
|
UINT32 wadList::IndexOf ( const wadListDirEntry *entry ) const
|
||||||
{
|
{
|
||||||
return (( entry < m_Directory ) || ( entry > m_Directory + m_DirSize )) ? -1 : entry - m_Directory;
|
return (( entry < m_Directory ) || ( entry > m_Directory + m_DirSize )) ? -1 : entry - m_Directory;
|
||||||
|
@ -1024,7 +1026,7 @@ void wadList::AddDirectory ( WAD *wad, bool check )
|
||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const wadListDirEntry *wadList::GetDir ( UINT32 index ) const
|
const wadListDirEntry *wadList::GetDir ( UINT32 index ) const
|
||||||
{
|
{
|
||||||
return ( index >= m_DirSize ) ? ( const wadListDirEntry * ) NULL : &m_Directory [index];
|
return ( index >= m_DirSize ) ? ( const wadListDirEntry * ) NULL : &m_Directory [index];
|
||||||
|
@ -1066,7 +1068,7 @@ bool wadList::Contains ( WAD *wad ) const
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wadList::Save ( const char *newName )
|
bool wadList::Save ( const char *newName )
|
||||||
{
|
{
|
||||||
if ( IsEmpty ()) return false;
|
if ( IsEmpty ()) return false;
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
|
|
||||||
#define UNSUPPORTED_FEATURE -1
|
#define UNSUPPORTED_FEATURE -1
|
||||||
#define UNRECOGNIZED_PARAMETER -2
|
#define UNRECOGNIZED_PARAMETER -2
|
||||||
|
|
||||||
#if defined ( __GNUC__ )
|
#if defined ( __GNUC__ )
|
||||||
|
|
||||||
#define stricmp strcasecmp
|
#define stricmp strcasecmp
|
||||||
|
@ -66,10 +66,8 @@
|
||||||
|
|
||||||
extern char *strupr ( char *ptr );
|
extern char *strupr ( char *ptr );
|
||||||
extern int getch ();
|
extern int getch ();
|
||||||
extern bool kbhit ();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int GCD ( int A, int B )
|
int GCD ( int A, int B )
|
||||||
{
|
{
|
||||||
if ( A < 0 ) A = -A; else if ( A == 0 ) return 1;
|
if ( A < 0 ) A = -A; else if ( A == 0 ) return 1;
|
||||||
|
@ -111,7 +109,7 @@ void printHelp ()
|
||||||
fprintf ( stderr, " level - ExMy for DOOM / Heretic\n" );
|
fprintf ( stderr, " level - ExMy for DOOM / Heretic\n" );
|
||||||
fprintf ( stderr, " MAPxx for DOOM II / HEXEN\n" );
|
fprintf ( stderr, " MAPxx for DOOM II / HEXEN\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
int parseArgs ( int index, const char *argv[] )
|
int parseArgs ( int index, const char *argv[] )
|
||||||
{
|
{
|
||||||
bool errors = false;
|
bool errors = false;
|
||||||
|
@ -124,7 +122,7 @@ int parseArgs ( int index, const char *argv[] )
|
||||||
if ( errors ) fprintf ( stderr, "\n" );
|
if ( errors ) fprintf ( stderr, "\n" );
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getLevels ( int argIndex, const char *argv[], char names [][MAX_LUMP_NAME], wadList *list )
|
int getLevels ( int argIndex, const char *argv[], char names [][MAX_LUMP_NAME], wadList *list )
|
||||||
{
|
{
|
||||||
int index = 0, errors = 0;
|
int index = 0, errors = 0;
|
||||||
|
@ -168,7 +166,7 @@ int getLevels ( int argIndex, const char *argv[], char names [][MAX_LUMP_NAME],
|
||||||
if ( errors ) fprintf ( stderr, "\n" );
|
if ( errors ) fprintf ( stderr, "\n" );
|
||||||
return argIndex;
|
return argIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnsureExtension ( char *fileName, const char *ext )
|
void EnsureExtension ( char *fileName, const char *ext )
|
||||||
{
|
{
|
||||||
size_t length = strlen ( fileName );
|
size_t length = strlen ( fileName );
|
||||||
|
@ -245,7 +243,7 @@ wadList *getInputFiles ( const char *cmdLine, char *wadFileName )
|
||||||
|
|
||||||
return myList;
|
return myList;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> inline T sgn ( T val ) { return ( val > 0 ) ? 1 : ( val < 0 ) ? -1 : 0; }
|
template <class T> inline T sgn ( T val ) { return ( val > 0 ) ? 1 : ( val < 0 ) ? -1 : 0; }
|
||||||
|
|
||||||
void NormalizeNODES ( wNode *node, int noNodes )
|
void NormalizeNODES ( wNode *node, int noNodes )
|
||||||
|
@ -401,7 +399,7 @@ done:
|
||||||
|
|
||||||
return mismatches;
|
return mismatches;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main ( int argc, const char *argv[] )
|
int main ( int argc, const char *argv[] )
|
||||||
{
|
{
|
||||||
fprintf ( stderr, "Compare Version %s (c) 2003-2004 Marc Rousseau\n\n", VERSION );
|
fprintf ( stderr, "Compare Version %s (c) 2003-2004 Marc Rousseau\n\n", VERSION );
|
||||||
|
|
|
@ -11,12 +11,25 @@ WARNINGS = -Wall -Wno-format -Wstrict-prototypes -Wmissing-prototypes -Winline
|
||||||
INCLUDES = -I../DOOM -I../common
|
INCLUDES = -I../DOOM -I../common
|
||||||
TARGETS = ZenNode bspdiff bspinfo compare
|
TARGETS = ZenNode bspdiff bspinfo compare
|
||||||
|
|
||||||
|
ifdef LINUX
|
||||||
CFLAGS += -D__LINUX__
|
CFLAGS += -D__LINUX__
|
||||||
|
endif
|
||||||
|
|
||||||
ifdef WIN32
|
ifdef WIN32
|
||||||
CFLAGS += -D__WIN32__
|
CFLAGS += -D__WIN32__
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(OS),Windows_NT) # all windows are Windows_NT...
|
||||||
|
WIN32=1
|
||||||
|
else # if you on the *nix
|
||||||
|
|
||||||
|
system:=$(shell uname -s)
|
||||||
|
|
||||||
|
ifeq ($(system),Linux)
|
||||||
|
LINUX=1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
CFLAGS += -DDEBUG
|
CFLAGS += -DDEBUG
|
||||||
LOGGER = ../common/logger/logger.o ../common/logger/string.o
|
LOGGER = ../common/logger/logger.o ../common/logger/string.o
|
||||||
|
|
Loading…
Reference in a new issue