Initial commit of Command & Conquer Generals and Command & Conquer Generals Zero Hour source code.

This commit is contained in:
LFeenanEA 2025-02-27 17:34:39 +00:00
parent 2e338c00cb
commit 3d0ee53a05
No known key found for this signature in database
GPG key ID: C6EBE8C2EA08F7E0
6072 changed files with 2283311 additions and 0 deletions

View file

@ -0,0 +1,154 @@
/*
** Command & Conquer Generals(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/>.
*/
#include <string>
#include <cstdio>
#include "Lib/BaseType.h"
#include "Compression/Compression.h"
#include "../CRCDiff/Debug.h"
#ifndef DEBUG
#include <cstdarg>
void ReleaseLog(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 );
printf( "%s", buffer );
}
#undef DEBUG_LOG
#define DEBUG_LOG(x) ReleaseLog x
#endif
void dumpHelp(const char *exe)
{
DEBUG_LOG(("Usage:\n To print the compression type of an existing file: %s -in infile\n", exe));
DEBUG_LOG((" To compress a file: %s -in infile -out outfile <-type compressionmode>\n\n", exe));
DEBUG_LOG(("Compression modes:\n"));
for (int i=COMPRESSION_MIN; i<=COMPRESSION_MAX; ++i)
{
DEBUG_LOG((" %s\n", CompressionManager::getCompressionNameByType((CompressionType)i)));
}
}
void main(int argc, char **argv)
{
std::string inFile = "";
std::string outFile = "";
CompressionType compressType = CompressionManager::getPreferredCompression();
for (int i=1; i<argc; ++i)
{
if ( !stricmp(argv[i], "-help") )
{
dumpHelp(argv[0]);
exit(0);
}
if ( !strcmp(argv[i], "-in") )
{
++i;
if (i<argc)
{
inFile = argv[i];
}
}
if ( !strcmp(argv[i], "-out") )
{
++i;
if (i<argc)
{
outFile = argv[i];
}
}
if ( !strcmp(argv[i], "-type") )
{
++i;
if (i<argc)
{
for (int j=COMPRESSION_MIN; j<=COMPRESSION_MAX; ++j)
{
if ( !stricmp(CompressionManager::getCompressionNameByType((CompressionType)j), argv[i]) )
{
compressType = (CompressionType)j;
break;
}
}
}
}
}
if (inFile.empty())
{
dumpHelp(argv[0]);
exit(0);
}
DEBUG_LOG(("IN:'%s' OUT:'%s' Compression:'%s'\n",
inFile.c_str(), outFile.c_str(), CompressionManager::getCompressionNameByType(compressType)));
if (outFile.empty())
{
// just check compression
FILE *fp = fopen(inFile.c_str(), "rb");
if (!fp)
{
DEBUG_LOG(("Cannot open '%s'\n", inFile.c_str()));
return;
}
fseek(fp, 0, SEEK_END);
int size = ftell(fp);
fseek(fp, 0, SEEK_SET);
char data[8];
int numRead = fread(data, 1, 8, fp);
if (numRead != 8)
{
DEBUG_LOG(("Cannot read header from '%s'\n", inFile.c_str()));
return;
}
CompressionType usedType = CompressionManager::getCompressionType(data, 8);
if (usedType == COMPRESSION_NONE)
{
DEBUG_LOG(("No compression on '%s'\n", inFile.c_str()));
return;
}
int uncompressedSize = CompressionManager::getUncompressedSize(data, 8);
DEBUG_LOG(("'%s' is compressed using %s, from %d to %d bytes, %g%% of its original size\n",
inFile.c_str(), CompressionManager::getCompressionNameByType(usedType),
uncompressedSize, size, size/(double)(uncompressedSize+0.1)*100.0));
return;
}
// compress file
}

View file

@ -0,0 +1,99 @@
# Microsoft Developer Studio Project File - Name="Compress" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=Compress - 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 "Compress.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 "Compress.mak" CFG="Compress - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Compress - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "Compress - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "Compress"
# PROP Scc_LocalPath "."
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "Compress - 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 0
# 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 "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "../../Libraries/Source" /I "../../Libraries/Include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "Z_PREFIX" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
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:console /machine:I386
# ADD 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:console /pdb:"../../../Run/Compress.pdb" /map:"../../../Run/Compress.map" /debug /machine:I386 /out:"../../../Run/Compress.exe"
!ELSEIF "$(CFG)" == "Compress - 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 "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../Libraries/Source" /I "../../Libraries/Include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "Z_PREFIX" /D "DEBUG" /YX /FD /GZ /c
# 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:console /debug /machine:I386
# ADD 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:console /pdb:"../../../Run/CompressD.pdb" /map:"../../../Run/CompressD.map" /debug /machine:I386 /out:"../../../Run/CompressD.exe"
# SUBTRACT LINK32
!ENDIF
# Begin Target
# Name "Compress - Win32 Release"
# Name "Compress - Win32 Debug"
# Begin Source File
SOURCE=.\Compress.cpp
# End Source File
# Begin Source File
SOURCE=..\CRCDiff\debug.cpp
# End Source File
# Begin Source File
SOURCE=..\CRCDiff\debug.h
# End Source File
# End Target
# End Project