From 94199c49dca11651a54af1e7e48df318befcb865 Mon Sep 17 00:00:00 2001 From: TTimo Date: Tue, 18 Mar 2008 17:47:38 +0000 Subject: [PATCH] fix windows compile, it's possible the linux build broke and will need misc tweaks. you need a new GtkR-1.6-deps.zip git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/branches/ZeroRadiant@227 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- libs/missing.h | 52 +- plugins/image/bmp.h | 5 +- plugins/image/image.vcproj | 272 ++- plugins/image/jpeg.cpp | 4 +- radiant/missing.cpp | 159 +- radiant/preferences.cpp | 24 +- radiant/radiant.vcproj | 2843 ++++++++++++++++++++++------- tools/quake3/common/imagelib.h | 10 +- tools/quake3/q3map2/q3map2.vcproj | 3 + 9 files changed, 2540 insertions(+), 832 deletions(-) diff --git a/libs/missing.h b/libs/missing.h index 298ef605..f4fc6ee5 100644 --- a/libs/missing.h +++ b/libs/missing.h @@ -34,40 +34,31 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // NOTE TTimo // this goes along with str.h and provides various utility classes // and portability defines -// the filename is a legecy issue, it would be better to clean that up +// the file name (missing.h) is a legacy issue, it would be better to clean that up // in a central 'portability' lib #include #include #ifdef _WIN32 + +#include #include #include +#include +#include -#define MyCopyFile(a,b) CopyFile(a,b,FALSE) - -#define S_ISDIR(mode) (mode & _S_IFDIR) #define R_OK 04 -#define mymkdir(a,b) _mkdir(a) - -#else - -#define MyCopyFile CopyFile -#define mymkdir(a,b) mkdir(a,b) -#endif - -#ifndef _WIN32 +#else // !_WIN32 // LZ: very ugly hacks -inline int GetLastError () { return 0; }; +inline int GetLastError() { return 0; }; // temp stuff inline int GetPrivateProfileInt(char* a, char* b, int i, char* c) { return i; }; #define VERIFY(a) a; int GetFullPathName(const char *lpFileName, int nBufferLength, char *lpBuffer, char **lpFilePart); -bool CopyFile(const char *lpExistingFileName, const char *lpNewFileName); -bool CopyTree( const char* source, const char* dest ); #ifndef APIENTRY #define APIENTRY @@ -210,4 +201,33 @@ protected: }; }; +class FindFiles { +public: + FindFiles( const char *directory ); + ~FindFiles(); + + const char* NextFile(); +private: +#ifdef _WIN32 + Str directory; + HANDLE findHandle; + WIN32_FIND_DATA findFileData; +#else +#endif +}; + +bool CopyTree( const char* source, const char* dest ); + +typedef enum { + PATH_FAIL, // stat call failed (does not exist is likely) + PATH_DIRECTORY, + PATH_FILE +} EPathCheck; + +// check a path for existence, return directory / file +EPathCheck CheckFile( const char *path ); + +bool radCreateDirectory( const char *directory ); +bool radCopyFile( const char *lpExistingFileName, const char *lpNewFileName ); + #endif // _MISSING_H_ diff --git a/plugins/image/bmp.h b/plugins/image/bmp.h index 63667ea5..ea93165c 100644 --- a/plugins/image/bmp.h +++ b/plugins/image/bmp.h @@ -29,10 +29,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define BMP_SIGNATURE_WORD 0x4d42 +#pragma pack(push) #pragma pack(1) - - typedef struct { unsigned short bfType; // signature - 'BM' unsigned long bfSize; // file size in bytes @@ -96,6 +95,6 @@ void FreeBMP(bitmap_t *bitmap); void WriteBMP(char *filename, bitmap_t *bit); void NewBMP(int width, int height, int bpp, bitmap_t *bit); - +#pragma pack(pop) #endif diff --git a/plugins/image/image.vcproj b/plugins/image/image.vcproj index f0721169..08bc1617 100644 --- a/plugins/image/image.vcproj +++ b/plugins/image/image.vcproj @@ -1,79 +1,245 @@ - + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + - + - + - + + + + + + + - + - - + + - + - + - + - + - \ No newline at end of file + diff --git a/plugins/image/jpeg.cpp b/plugins/image/jpeg.cpp index 29b0f63f..66df32ff 100644 --- a/plugins/image/jpeg.cpp +++ b/plugins/image/jpeg.cpp @@ -34,14 +34,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Leonardo Zide (leo@lokigames.com) // +#include #include #include -#include #include #include +extern "C" { #include #include +} #include "image.h" diff --git a/radiant/missing.cpp b/radiant/missing.cpp index f9779908..5f37538d 100644 --- a/radiant/missing.cpp +++ b/radiant/missing.cpp @@ -34,7 +34,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Leonardo Zide (leo@lokigames.com) // -// FIXME: compile on Windows as well +#include "missing.h" +#include "qsysprintf.h" + #if defined (__linux__) || defined (__APPLE__) #include @@ -44,10 +46,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include "missing.h" -#include "qsysprintf.h" -bool CopyFile(const char *lpExistingFileName, const char *lpNewFileName) +bool radCopyFile(const char *lpExistingFileName, const char *lpNewFileName) { FILE *src, *dst; void* buf; @@ -85,7 +85,7 @@ bool CopyFile(const char *lpExistingFileName, const char *lpNewFileName) return ret; } -bool CreateDirectory( const char *directory ) { +bool radCreateDirectory( const char *directory ) { if ( mkdir( directory, 0777 ) == -1 ) { Sys_Printf( "mkdir %s failed\n", directory ); return false; @@ -93,53 +93,6 @@ bool CreateDirectory( const char *directory ) { return true; } -bool CopyTree( const char *source, const char *dest ) { - DIR *dir; - struct dirent *dirlist; - struct stat sbuf; - Str srcEntry; - Str dstEntry; - - dir = opendir( source ); - if ( dir != NULL ) { - while ( ( dirlist = readdir( dir ) ) != NULL ) { - if ( strcmp( dirlist->d_name, "." ) == 0 || strcmp( dirlist->d_name, ".." ) == 0 ) { - continue; - } - if ( strcmp( dirlist->d_name, ".svn" ) == 0 ) { - continue; - } - srcEntry = source; - srcEntry += "/"; - srcEntry += dirlist->d_name; - dstEntry = dest; - dstEntry += "/"; - dstEntry += dirlist->d_name; - if ( stat( srcEntry.GetBuffer(), &sbuf ) == -1 ) { - Sys_Printf( "stat %s failed\n", srcEntry.GetBuffer() ); - } - if ( S_ISDIR( sbuf.st_mode ) ) { - bool ret; - if ( stat( dstEntry.GetBuffer(), &sbuf ) == -1 ) { - ret = CreateDirectory( dstEntry.GetBuffer() ); - } - ret = CopyTree( srcEntry.GetBuffer(), dstEntry.GetBuffer() ); - if ( !ret ) { - return false; - } - } else { - Sys_Printf( "copy %s -> %s\n", srcEntry.GetBuffer(), dstEntry.GetBuffer() ); - bool ret = CopyFile( srcEntry.GetBuffer(), dstEntry.GetBuffer() ); - if ( !ret ) { - return false; - } - } - } - closedir( dir ); - } - return true; -} - int GetFullPathName(const char *lpFileName, int nBufferLength, char *lpBuffer, char **lpFilePart) { if (lpFileName[0] == '/') @@ -178,4 +131,106 @@ int GetFullPathName(const char *lpFileName, int nBufferLength, char *lpBuffer, c return strlen (lpBuffer); } +EPathCheck CheckFile( const char *path ) { + struct stat sbuf; + if ( stat( path, &sbuf ) == -1 ) { + return PATH_FAIL; + } + if ( S_ISDIR( sbuf.st_mode ) ) { + return PATH_DIRECTORY; + } + return PATH_FILE; +} + +#else + +FindFiles::FindFiles( const char *_directory ) { + directory = _directory; + findHandle = INVALID_HANDLE_VALUE; +} + +FindFiles::~FindFiles() { + if ( findHandle != NULL ) { + FindClose( findHandle ); + } +} + +const char* FindFiles::NextFile() { + if ( findHandle == INVALID_HANDLE_VALUE ) { + findHandle = FindFirstFile( directory.GetBuffer(), &findFileData ); + if ( findHandle == INVALID_HANDLE_VALUE ) { + return NULL; + } + return findFileData.cFileName; + } + if ( FindNextFile( findHandle, &findFileData ) == 0 ) { + FindClose( findHandle ); + return NULL; + } + return findFileData.cFileName; +} + +EPathCheck CheckFile( const char *path ) { + struct _stat sbuf; + if ( _stat( path, &sbuf ) == -1 ) { + return PATH_FAIL; + } + if ( ( sbuf.st_mode & _S_IFDIR ) != 0 ) { + return PATH_DIRECTORY; + } + return PATH_FILE; +} + +bool radCreateDirectory( const char *directory ) { + return CreateDirectory( directory, NULL ); +} + +bool radCopyFile( const char *lpExistingFileName, const char *lpNewFileName ) { + return CopyFile( lpExistingFileName, lpNewFileName, FALSE ); +} + #endif + +bool CopyTree( const char *source, const char *dest ) { + Str srcEntry; + Str dstEntry; + const char *dirname; + FindFiles fileScan( source ); + + while ( ( dirname = fileScan.NextFile() ) != NULL ) { + if ( strcmp( dirname, "." ) == 0 || strcmp( dirname, ".." ) == 0 ) { + continue; + } + if ( strcmp( dirname, ".svn" ) == 0 ) { + continue; + } + srcEntry = source; + srcEntry += "/"; + srcEntry += dirname; + dstEntry = dest; + dstEntry += "/"; + dstEntry += dirname; + switch ( CheckFile( srcEntry.GetBuffer() ) ) { + case PATH_DIRECTORY: { + if ( CheckFile( dstEntry.GetBuffer() ) == PATH_FAIL ) { + radCreateDirectory( dstEntry.GetBuffer() ); + } + bool ret; + ret = CopyTree( srcEntry.GetBuffer(), dstEntry.GetBuffer() ); + if ( !ret ) { + return false; + } + break; + } + case PATH_FILE: { + Sys_Printf( "copy %s -> %s\n", srcEntry.GetBuffer(), dstEntry.GetBuffer() ); + bool ret = radCopyFile( srcEntry.GetBuffer(), dstEntry.GetBuffer() ); + if ( !ret ) { + return false; + } + break; + } + } + } + return true; +} diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 2f6a45c4..cd51e660 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -3282,24 +3282,18 @@ scan for active games that can be installed, based on the presence */ void CGameInstall::ScanGames() { Str pakPaths = g_strAppPath.GetBuffer(); - DIR *dir; - struct dirent *dirlist; int iGame = 0; + const char *dirname; pakPaths += "installs/"; - dir = opendir( pakPaths.GetBuffer() ); - if ( dir != NULL ) { - while ( ( dirlist = readdir( dir ) ) != NULL ) { - if ( stricmp( dirlist->d_name, Q3_PACK ) == 0 ) { - m_availGames[ iGame++ ] = GAME_Q3; - } - if ( stricmp( dirlist->d_name, URT_PACK ) == 0 ) { - m_availGames[ iGame++ ] = GAME_URT; - } - if ( stricmp( dirlist->d_name, UFOAI_PACK ) == 0 ) { - m_availGames[ iGame++ ] = GAME_UFOAI; - } + FindFiles fileScan( pakPaths.GetBuffer() ); + while ( ( dirname = fileScan.NextFile() ) != NULL ) { + if ( stricmp( dirname, Q3_PACK ) == 0 ) { + m_availGames[ iGame++ ] = GAME_Q3; } - closedir( dir ); + if ( stricmp( dirname, URT_PACK ) == 0 ) { + m_availGames[ iGame++ ] = GAME_URT; + } } } + diff --git a/radiant/radiant.vcproj b/radiant/radiant.vcproj index d81e08f9..95286f65 100644 --- a/radiant/radiant.vcproj +++ b/radiant/radiant.vcproj @@ -1,989 +1,2458 @@ - + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + + + - - + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - + + - + - + - + - + - + - + - + - + - + diff --git a/tools/quake3/common/imagelib.h b/tools/quake3/common/imagelib.h index e3d64e96..9a99d6af 100644 --- a/tools/quake3/common/imagelib.h +++ b/tools/quake3/common/imagelib.h @@ -36,9 +36,9 @@ void Save256Image (const char *name, byte *pixels, byte *palette, int width, int height); -void LoadTGA (const char *filename, byte **pixels, int *width, int *height); -void LoadTGABuffer ( byte *buffer, byte **pic, int *width, int *height); -void WriteTGA (const char *filename, byte *data, int width, int height); - -void Load32BitImage (const char *name, unsigned **pixels, int *width, int *height); +void LoadTGA( const char *filename, byte **pixels, int *width, int *height ); +void LoadTGABuffer( byte *buffer, byte **pic, int *width, int *height ); +void WriteTGA( const char *filename, byte *data, int width, int height ); +int LoadJPGBuff( void *src_buffer, int src_size, unsigned char **pic, int *width, int *height ); +void Load32BitImage( const char *name, unsigned **pixels, int *width, int *height ); diff --git a/tools/quake3/q3map2/q3map2.vcproj b/tools/quake3/q3map2/q3map2.vcproj index c27c3209..97597b05 100644 --- a/tools/quake3/q3map2/q3map2.vcproj +++ b/tools/quake3/q3map2/q3map2.vcproj @@ -19,6 +19,7 @@ OutputDirectory="$(SolutionDir)$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" ConfigurationType="1" + UseOfMFC="0" CharacterSet="2" > -- 2.39.2