Initial commit of Command & Conquer Generals and Command & Conquer Generals Zero Hour source code.
This commit is contained in:
parent
2e338c00cb
commit
3d0ee53a05
6072 changed files with 2283311 additions and 0 deletions
34
GeneralsMD/Code/Tools/textureCompress/resource.h
Normal file
34
GeneralsMD/Code/Tools/textureCompress/resource.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
** Command & Conquer Generals Zero Hour(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by Script1.rc
|
||||
//
|
||||
#define IDC_FILENAME 1058
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 112
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1006
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
679
GeneralsMD/Code/Tools/textureCompress/textureCompress.cpp
Normal file
679
GeneralsMD/Code/Tools/textureCompress/textureCompress.cpp
Normal file
|
@ -0,0 +1,679 @@
|
|||
/*
|
||||
** Command & Conquer Generals Zero Hour(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// FILE: textureCompress.cpp //////////////////////////////////////////////////////
|
||||
// Author: Matthew D. Campbell, Dec 2002
|
||||
|
||||
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
|
||||
#define WIN32_LEAN_AND_MEAN // only bare bones windows stuff wanted
|
||||
//#include <afxwin.h>
|
||||
#include <windows.h>
|
||||
#include <lmcons.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "resource.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <cstdarg>
|
||||
#include <io.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/utime.h>
|
||||
|
||||
static const char *nodxtPrefix[] = {
|
||||
"zhca",
|
||||
"caust",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const char *nodxtAnywhere[] = {
|
||||
"userinterface",
|
||||
"controlbar",
|
||||
"commandbar",
|
||||
NULL,
|
||||
};
|
||||
|
||||
#define LOG(x) logStuff x
|
||||
static void logStuff(const char *fmt, ...)
|
||||
{
|
||||
static char buffer[1024];
|
||||
va_list va;
|
||||
va_start( va, fmt );
|
||||
_vsnprintf(buffer, 1024, fmt, va );
|
||||
buffer[1023] = 0;
|
||||
va_end( va );
|
||||
|
||||
puts(buffer);
|
||||
::MessageBox(NULL, buffer, "textureCompress", MB_OK);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
class DebugMunkee
|
||||
{
|
||||
public:
|
||||
DebugMunkee(const char *fname = "debugLog.txt") { m_fp = fopen(fname, "w"); }
|
||||
~DebugMunkee() { if (m_fp) fclose(m_fp); m_fp = NULL; }
|
||||
|
||||
FILE *m_fp;
|
||||
};
|
||||
|
||||
static DebugMunkee *theDebugMunkee = NULL;
|
||||
|
||||
#define DEBUG_LOG(x) debugLog x
|
||||
static void debugLog(const char *fmt, ...)
|
||||
{
|
||||
static char buffer[1024];
|
||||
va_list va;
|
||||
va_start( va, fmt );
|
||||
_vsnprintf(buffer, 1024, fmt, va );
|
||||
buffer[1023] = 0;
|
||||
va_end( va );
|
||||
|
||||
OutputDebugString( buffer );
|
||||
puts(buffer);
|
||||
if (theDebugMunkee)
|
||||
fputs(buffer, theDebugMunkee->m_fp);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define DEBUG_LOG(x) {}
|
||||
|
||||
#endif // NDEBUG
|
||||
|
||||
|
||||
static void usage(const char *progname)
|
||||
{
|
||||
if (!progname)
|
||||
progname = "textureCompress";
|
||||
LOG (("Usage: %s sourceDir destDir cacheDir outFile dxtOutFile\n", progname));
|
||||
}
|
||||
|
||||
class FileInfo
|
||||
{
|
||||
public:
|
||||
FileInfo() {}
|
||||
~FileInfo() {}
|
||||
|
||||
void set( const WIN32_FIND_DATA& info );
|
||||
|
||||
std::string filename;
|
||||
time_t creationTime;
|
||||
time_t accessTime;
|
||||
time_t modTime;
|
||||
DWORD attributes;
|
||||
DWORD filesize; // only care about 32 bits for our purposes
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
struct FileInfoComparator
|
||||
{
|
||||
bool operator()(const FileInfo& a, const FileInfo& b) const
|
||||
{
|
||||
return a.filename < b.filename;
|
||||
}
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
typedef std::set<FileInfo, FileInfoComparator> FileInfoSet;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
class Directory
|
||||
{
|
||||
public:
|
||||
Directory(const std::string& dirPath);
|
||||
~Directory() {}
|
||||
|
||||
FileInfoSet* getFiles( void );
|
||||
FileInfoSet* getSubdirs( void );
|
||||
|
||||
protected:
|
||||
std::string m_dirPath;
|
||||
|
||||
FileInfoSet m_files;
|
||||
FileInfoSet m_subdirs;
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
static void TimetToFileTime( time_t t, FILETIME& ft )
|
||||
{
|
||||
LONGLONG ll = Int32x32To64(t, 10000000) + 116444736000000000;
|
||||
ft.dwLowDateTime = (DWORD) ll;
|
||||
ft.dwHighDateTime = ll >>32;
|
||||
}
|
||||
|
||||
static time_t FileTimeToTimet( const FILETIME& ft )
|
||||
{
|
||||
LONGLONG ll = (ft.dwHighDateTime << 32) + ft.dwLowDateTime - 116444736000000000;
|
||||
ll /= 10000000;
|
||||
return (time_t)ll;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
void FileInfo::set( const WIN32_FIND_DATA& info )
|
||||
{
|
||||
filename = info.cFileName;
|
||||
for (int i=0; i<filename.size(); ++i)
|
||||
{
|
||||
char c[2] = { tolower(info.cFileName[i]), 0 };
|
||||
filename.replace(i, 1, c, 1);
|
||||
}
|
||||
creationTime = FileTimeToTimet(info.ftCreationTime);
|
||||
accessTime = FileTimeToTimet(info.ftLastAccessTime);
|
||||
modTime = FileTimeToTimet(info.ftLastWriteTime);
|
||||
attributes = info.dwFileAttributes;
|
||||
filesize = info.nFileSizeLow;
|
||||
|
||||
struct stat origStat;
|
||||
stat( filename.c_str(), &origStat);
|
||||
modTime = origStat.st_mtime; // use stat(), since the LONGLONG code is unpredictable
|
||||
|
||||
//DEBUG_LOG(("FileInfo::set(): fname=%s, size=%d, modTime=%d\n", filename.c_str(), filesize, modTime));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
Directory::Directory( const std::string& dirPath ) : m_dirPath(dirPath)
|
||||
{
|
||||
WIN32_FIND_DATA item; // search item
|
||||
HANDLE hFile; // handle for search resources
|
||||
char currDir[ MAX_PATH ];
|
||||
|
||||
// sanity
|
||||
if( !m_dirPath.length() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// save the current directory
|
||||
GetCurrentDirectory( MAX_PATH, currDir );
|
||||
|
||||
// switch into the directory provided
|
||||
if( SetCurrentDirectory( m_dirPath.c_str() ) == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// go through each item in the output directory
|
||||
bool done = false;
|
||||
hFile = FindFirstFile( "*", &item);
|
||||
if( hFile == INVALID_HANDLE_VALUE )
|
||||
{
|
||||
done = true;
|
||||
}
|
||||
|
||||
FileInfo info;
|
||||
|
||||
while (!done)
|
||||
{
|
||||
// if this is a subdirectory keep the name around till the end
|
||||
if( item.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
|
||||
{
|
||||
if ( strcmp( item.cFileName, "." ) && strcmp( item.cFileName, ".." ) )
|
||||
{
|
||||
info.set(item);
|
||||
m_subdirs.insert( info );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
info.set(item);
|
||||
m_files.insert( info );
|
||||
}
|
||||
|
||||
if ( FindNextFile( hFile, &item ) == 0 )
|
||||
{
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
// close search
|
||||
FindClose( hFile );
|
||||
|
||||
// restore the working directory to what it was when we started here
|
||||
SetCurrentDirectory( currDir );
|
||||
}
|
||||
|
||||
FileInfoSet* Directory::getFiles( void )
|
||||
{
|
||||
return &m_files;
|
||||
}
|
||||
|
||||
FileInfoSet* Directory::getSubdirs( void )
|
||||
{
|
||||
return &m_subdirs;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
// strtrim ====================================================================
|
||||
/** Trim leading and trailing whitespace from a character string (in place). */
|
||||
//=============================================================================
|
||||
static char* strtrim(char* buffer)
|
||||
{
|
||||
if (buffer != NULL) {
|
||||
// Strip leading white space from the string.
|
||||
char * source = buffer;
|
||||
while ((*source != 0) && ((unsigned char)*source <= 32))
|
||||
{
|
||||
source++;
|
||||
}
|
||||
|
||||
if (source != buffer)
|
||||
{
|
||||
strcpy(buffer, source);
|
||||
}
|
||||
|
||||
// Clip trailing white space from the string.
|
||||
for (int index = strlen(buffer)-1; index >= 0; index--)
|
||||
{
|
||||
if ((*source != 0) && ((unsigned char)buffer[index] <= 32))
|
||||
{
|
||||
buffer[index] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
typedef std::set<std::string> StringSet;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
void eraseCachedFiles(const std::string& sourceDirName, const std::string& targetDirName, const std::string& cacheDirName,
|
||||
StringSet& cachedFilesToErase)
|
||||
{
|
||||
StringSet::const_iterator sit;
|
||||
for (sit = cachedFilesToErase.begin(); sit != cachedFilesToErase.end(); ++sit)
|
||||
{
|
||||
std::string src = cacheDirName;
|
||||
src.append("\\");
|
||||
src.append(*sit);
|
||||
|
||||
DEBUG_LOG(("Erasing cached file: %s\n", src.c_str()));
|
||||
DeleteFile(src.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
void copyCachedFiles(const std::string& sourceDirName, const std::string& targetDirName, const std::string& cacheDirName,
|
||||
StringSet& cachedFilesToCopy)
|
||||
{
|
||||
StringSet::const_iterator sit;
|
||||
for (sit = cachedFilesToCopy.begin(); sit != cachedFilesToCopy.end(); ++sit)
|
||||
{
|
||||
std::string src = cacheDirName;
|
||||
src.append("\\");
|
||||
src.append(*sit);
|
||||
|
||||
std::string dest = targetDirName;
|
||||
dest.append("\\");
|
||||
dest.append(*sit);
|
||||
|
||||
DEBUG_LOG(("Copying cached file: %s\n", src.c_str()));
|
||||
if (_chmod(dest.c_str(), _S_IWRITE | _S_IREAD) == -1)
|
||||
{
|
||||
DEBUG_LOG(("Cannot chmod '%s'\n", dest.c_str()));
|
||||
}
|
||||
CopyFile(src.c_str(), dest.c_str(), FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
void compressOrigFiles(const std::string& sourceDirName, const std::string& targetDirName, const std::string& cacheDirName,
|
||||
StringSet& origFilesToCompress, const std::string& dxtOutFname)
|
||||
{
|
||||
char tmpPath[_MAX_PATH] = "C:\\temp\\";
|
||||
char tmpFname[_MAX_PATH] = "C:\\temp\\tmp.txt";
|
||||
GetTempPath(_MAX_PATH, tmpPath);
|
||||
GetTempFileName(tmpPath, "tex", 0, tmpFname);
|
||||
HANDLE h = CreateFile(tmpFname, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL);
|
||||
if (!h)
|
||||
{
|
||||
DEBUG_LOG(("Could not create temp file '%s'! Unable to compress textures!\n", tmpFname));
|
||||
}
|
||||
|
||||
StringSet::const_iterator sit;
|
||||
for (sit = origFilesToCompress.begin(); sit != origFilesToCompress.end(); ++sit)
|
||||
{
|
||||
std::string tmp = sourceDirName;
|
||||
tmp.append("\\");
|
||||
tmp.append(*sit);
|
||||
tmp.append("\n");
|
||||
DEBUG_LOG(("Compressing file: %s", tmp.c_str()));
|
||||
DWORD len;
|
||||
WriteFile(h, tmp.c_str(), tmp.length(), &len, NULL);
|
||||
}
|
||||
CloseHandle(h);
|
||||
|
||||
std::string commandLine;
|
||||
commandLine = "\\projects\\rts\\build\\nvdxt -list ";
|
||||
commandLine.append(tmpFname);
|
||||
commandLine.append(" -24 dxt1c -32 dxt5 -full -outdir ");
|
||||
commandLine.append(cacheDirName);
|
||||
commandLine.append(" > ");
|
||||
commandLine.append(dxtOutFname);
|
||||
|
||||
DEBUG_LOG(("Compressing textures with command line of '%s'\n", commandLine.c_str()));
|
||||
int ret = system(commandLine.c_str());
|
||||
DEBUG_LOG(("system(%s) returned %d\n", commandLine.c_str(), ret));
|
||||
DeleteFile(tmpFname);
|
||||
|
||||
// now copy compressed file to target dir
|
||||
for (sit = origFilesToCompress.begin(); sit != origFilesToCompress.end(); ++sit)
|
||||
{
|
||||
std::string orig = sourceDirName;
|
||||
orig.append("\\");
|
||||
orig.append(*sit);
|
||||
|
||||
struct stat origStat;
|
||||
stat( orig.c_str(), &origStat);
|
||||
|
||||
struct _utimbuf utb;
|
||||
utb.actime = origStat.st_atime;
|
||||
utb.modtime = origStat.st_mtime;
|
||||
|
||||
std::string src = cacheDirName;
|
||||
src.append("\\");
|
||||
src.append(*sit);
|
||||
src.replace(src.size()-4, 4, ".dds");
|
||||
|
||||
_utime(src.c_str(), &utb);
|
||||
|
||||
std::string dest = targetDirName;
|
||||
dest.append("\\");
|
||||
dest.append(*sit);
|
||||
dest.replace(dest.size()-4, 4, ".dds");
|
||||
|
||||
DEBUG_LOG(("Copying new file from %s to %s\n", src.c_str(), dest.c_str()));
|
||||
|
||||
if (_chmod(dest.c_str(), _S_IWRITE | _S_IREAD) == -1)
|
||||
{
|
||||
DEBUG_LOG(("Cannot chmod '%s'\n", dest.c_str()));
|
||||
}
|
||||
BOOL ret = CopyFile(src.c_str(), dest.c_str(), FALSE);
|
||||
if (!ret)
|
||||
{
|
||||
DEBUG_LOG(("Could not copy file!\n"));
|
||||
}
|
||||
|
||||
_utime(dest.c_str(), &utb);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
void copyOrigFiles(const std::string& sourceDirName, const std::string& targetDirName, const std::string& cacheDirName,
|
||||
StringSet& origFilesToCopy)
|
||||
{
|
||||
StringSet::const_iterator sit;
|
||||
for (sit = origFilesToCopy.begin(); sit != origFilesToCopy.end(); ++sit)
|
||||
{
|
||||
std::string src = sourceDirName;
|
||||
src.append("\\");
|
||||
src.append(*sit);
|
||||
|
||||
std::string dest = targetDirName;
|
||||
dest.append("\\");
|
||||
dest.append(*sit);
|
||||
|
||||
if (_chmod(dest.c_str(), _S_IWRITE | _S_IREAD) == -1)
|
||||
{
|
||||
DEBUG_LOG(("Cannot chmod '%s'\n", dest.c_str()));
|
||||
}
|
||||
BOOL res = CopyFile(src.c_str(), dest.c_str(), FALSE);
|
||||
DEBUG_LOG(("Copying file: %s returns %d\n", src.c_str(), res));
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
static void scanDir( const std::string& sourceDirName, const std::string& targetDirName, const std::string& cacheDirName, const std::string& dxtOutFname )
|
||||
{
|
||||
DEBUG_LOG(("Scanning '%s'\n", sourceDirName.c_str()));
|
||||
Directory sourceDir(sourceDirName);
|
||||
|
||||
DEBUG_LOG(("Scanning '%s'\n", targetDirName.c_str()));
|
||||
Directory targetDir(targetDirName);
|
||||
|
||||
DEBUG_LOG(("Scanning '%s'\n", cacheDirName.c_str()));
|
||||
Directory cacheDir(cacheDirName);
|
||||
|
||||
FileInfoSet *sourceFiles = sourceDir.getFiles();
|
||||
FileInfoSet *cacheFiles = cacheDir.getFiles();
|
||||
FileInfoSet *targetFiles = targetDir.getFiles();
|
||||
|
||||
StringSet cachedFilesToErase;
|
||||
StringSet cachedFilesToCopy;
|
||||
StringSet origFilesToCompress;
|
||||
StringSet origFilesToCopy;
|
||||
|
||||
DEBUG_LOG(("Emptying targetDir\n"));
|
||||
for (FileInfoSet::iterator targetIt = targetFiles->begin(); targetIt != targetFiles->end(); ++targetIt)
|
||||
{
|
||||
FileInfo f = *targetIt;
|
||||
std::string fname = f.filename;
|
||||
f.filename.replace(f.filename.size()-4, 4, ".tga");
|
||||
FileInfoSet::iterator fit = sourceFiles->find(f);
|
||||
if (fit == sourceFiles->end())
|
||||
{
|
||||
// look for pre-existing dds files too
|
||||
f.filename.replace(f.filename.size()-4, 4, ".dds");
|
||||
FileInfoSet::iterator ddsfit = sourceFiles->find(f);
|
||||
if (ddsfit == sourceFiles->end())
|
||||
{
|
||||
fname.insert(0, "\\");
|
||||
fname.insert(0, targetDirName);
|
||||
DEBUG_LOG(("Deleting now-removed file '%s'\n", fname.c_str()));
|
||||
DeleteFile(fname.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (FileInfoSet::iterator cacheIt = cacheFiles->begin(); cacheIt != cacheFiles->end(); ++cacheIt)
|
||||
{
|
||||
FileInfo f = *cacheIt;
|
||||
int len = f.filename.size();
|
||||
if (len < 5)
|
||||
{
|
||||
cachedFilesToErase.insert(f.filename);
|
||||
continue;
|
||||
}
|
||||
std::string fname = f.filename;
|
||||
f.filename.replace(len-4, 4, ".tga");
|
||||
FileInfoSet::iterator fit = sourceFiles->find(f);
|
||||
if (fit != sourceFiles->end())
|
||||
{
|
||||
FileInfo sf = *fit;
|
||||
if (f.modTime < sf.modTime)
|
||||
{
|
||||
/**
|
||||
std::string orig = sourceDirName;
|
||||
orig.append("\\");
|
||||
orig.append(sf.filename);
|
||||
|
||||
struct stat origStat;
|
||||
stat( orig.c_str(), &origStat);
|
||||
|
||||
struct _utimbuf utb;
|
||||
utb.actime = origStat.st_atime;
|
||||
utb.modtime = origStat.st_mtime;
|
||||
|
||||
std::string dest = cacheDirName;
|
||||
dest.append("\\");
|
||||
dest.append(f.filename);
|
||||
dest.replace(dest.size()-4, 4, ".dds");
|
||||
|
||||
_utime(dest.c_str(), &utb);
|
||||
|
||||
cachedFilesToCopy.insert(fname);
|
||||
/**/
|
||||
cachedFilesToErase.insert(fname);
|
||||
}
|
||||
else
|
||||
{
|
||||
f.filename = fname; // back to .dds
|
||||
FileInfoSet::iterator it = targetFiles->find(f);
|
||||
if (it == targetFiles->end())
|
||||
cachedFilesToCopy.insert(fname);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cachedFilesToErase.insert(fname);
|
||||
}
|
||||
}
|
||||
|
||||
for (FileInfoSet::iterator sourceIt = sourceFiles->begin(); sourceIt != sourceFiles->end(); ++sourceIt)
|
||||
{
|
||||
FileInfo f = *sourceIt;
|
||||
|
||||
std::string fname = f.filename;
|
||||
const char *s = fname.c_str();
|
||||
int index = 0;
|
||||
const char *check = nodxtPrefix[0];
|
||||
bool shouldSkip = false;
|
||||
while (check)
|
||||
{
|
||||
if (fname.find(check) == 0)
|
||||
{
|
||||
shouldSkip = true;
|
||||
break;
|
||||
}
|
||||
check = nodxtPrefix[++index];
|
||||
}
|
||||
|
||||
index = 0;
|
||||
check = nodxtAnywhere[0];
|
||||
while (check && !shouldSkip)
|
||||
{
|
||||
if (fname.find(check) != fname.npos)
|
||||
{
|
||||
shouldSkip = true;
|
||||
break;
|
||||
}
|
||||
check = nodxtAnywhere[++index];
|
||||
}
|
||||
|
||||
if (!shouldSkip)
|
||||
{
|
||||
// check for preexisting .dds files so we can just copy them
|
||||
if (fname.find(".dds") != fname.npos)
|
||||
{
|
||||
shouldSkip = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSkip)
|
||||
{
|
||||
origFilesToCopy.insert(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
int len = f.filename.size();
|
||||
f.filename.replace(len-4, 4, ".dds");
|
||||
FileInfoSet::iterator fit = cacheFiles->find(f);
|
||||
if (fit != cacheFiles->end())
|
||||
{
|
||||
FileInfo cf = *fit;
|
||||
if (cf.modTime < f.modTime)
|
||||
{
|
||||
origFilesToCompress.insert(fname);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
origFilesToCompress.insert(fname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// now dump our files
|
||||
eraseCachedFiles (sourceDirName, targetDirName, cacheDirName, cachedFilesToErase);
|
||||
copyCachedFiles (sourceDirName, targetDirName, cacheDirName, cachedFilesToCopy);
|
||||
copyOrigFiles (sourceDirName, targetDirName, cacheDirName, origFilesToCopy);
|
||||
compressOrigFiles(sourceDirName, targetDirName, cacheDirName, origFilesToCompress, dxtOutFname);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
#define USE_WINMAIN
|
||||
#ifdef USE_WINMAIN
|
||||
int APIENTRY WinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
/*
|
||||
** Convert WinMain arguments to simple main argc and argv
|
||||
*/
|
||||
int argc = 1;
|
||||
char * argv[20];
|
||||
argv[0] = NULL;
|
||||
|
||||
char * token = strtok(lpCmdLine, " ");
|
||||
while (argc < 20 && token != NULL)
|
||||
{
|
||||
argv[argc++] = strtrim(token);
|
||||
token = strtok(NULL, " ");
|
||||
}
|
||||
#else
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
#endif // USE_WINMAIN
|
||||
|
||||
if (argc != 6)
|
||||
{
|
||||
usage(argv[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *sourceDir = argv[1];
|
||||
const char *targetDir = argv[2];
|
||||
const char *cacheDir = argv[3];
|
||||
|
||||
#ifndef NDEBUG
|
||||
theDebugMunkee = new DebugMunkee(argv[4]);
|
||||
#endif
|
||||
|
||||
//setUpLoadWindow();
|
||||
scanDir(sourceDir, targetDir, cacheDir, argv[5]);
|
||||
//setLoadWindowText("Writing to file...");
|
||||
//printSet( noAlphaChannel, "No Alpha Channel" );
|
||||
//printSet( noAlpha, "Not Using Alpha Channel" );
|
||||
//printSet( hasAlpha, "Using Alpha Channel" );
|
||||
//tearDownLoadWindow();
|
||||
|
||||
#ifndef NDEBUG
|
||||
delete theDebugMunkee;
|
||||
theDebugMunkee = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
112
GeneralsMD/Code/Tools/textureCompress/textureCompress.dsp
Normal file
112
GeneralsMD/Code/Tools/textureCompress/textureCompress.dsp
Normal file
|
@ -0,0 +1,112 @@
|
|||
# Microsoft Developer Studio Project File - Name="textureCompress" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=textureCompress - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "textureCompress.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "textureCompress.mak" CFG="textureCompress - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "textureCompress - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "textureCompress - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "textureCompress"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "textureCompress - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 2
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_AFXDLL" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 user32.lib /nologo /subsystem:windows /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "textureCompress - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# ADD LINK32 user32.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# SUBTRACT LINK32 /verbose /incremental:no
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "textureCompress - Win32 Release"
|
||||
# Name "textureCompress - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\textureCompress.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\textureCompress.rc
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
37
GeneralsMD/Code/Tools/textureCompress/textureCompress.dsw
Normal file
37
GeneralsMD/Code/Tools/textureCompress/textureCompress.dsw
Normal file
|
@ -0,0 +1,37 @@
|
|||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "textureCompress"=.\textureCompress.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
begin source code control
|
||||
textureCompress
|
||||
.
|
||||
end source code control
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
begin source code control
|
||||
textureCompress
|
||||
.
|
||||
end source code control
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
96
GeneralsMD/Code/Tools/textureCompress/textureCompress.rc
Normal file
96
GeneralsMD/Code/Tools/textureCompress/textureCompress.rc
Normal file
|
@ -0,0 +1,96 @@
|
|||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_LOADING DIALOG DISCARDABLE 0, 0, 186, 59
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Scanning..."
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LTEXT "",IDC_FILENAME,7,20,172,16
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_LOADING, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 179
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 52
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
Reference in a new issue