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,191 @@
/*
** 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/>.
*/
// FILE: buildVersionUpdate.cpp //////////////////////////////////////////////////////
// Generals version number class updater
// Author: Matthew D. Campbell, November 2001
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#define WIN32_LEAN_AND_MEAN // only bare bones windows stuff wanted
#include <windows.h>
#include <lmcons.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
// Local defines
#define VERSION_MAJOR "VERSION_MAJOR"
#define VERSION_MINOR "VERSION_MINOR"
#define VERSION_BUILDNUM "VERSION_BUILDNUM"
#define VERSION_STRING "VERSION_STRING"
#define FORMAT "#define " VERSION_STRING " \"%d.%d.%d\"\n"
#define COMMENTS "// Do not modify this file by hand. Auto-created and\n// Updated by buildVersionUpdate.\n"
#define NUMFMT "#define %s %d\n"
#define NUMFMT_MINOR "#define %s %d ///< This effects the replay version number.\n"
static void writeVersion(char *file, int major, int minor, int build)
{
FILE *filePtr = fopen(file, "w");
// Clobber the file. Hey, this is a simple program.
if (file)
{
if (filePtr)
{
fprintf(filePtr, COMMENTS);
fprintf(filePtr, FORMAT, major, minor, build);
fprintf(filePtr, NUMFMT, VERSION_MAJOR, major);
fprintf(filePtr, NUMFMT_MINOR, VERSION_MINOR, minor);
fprintf(filePtr, NUMFMT, VERSION_BUILDNUM, build);
fclose(filePtr);
}
else
{
printf("Cannot write file\n");
}
}
else
{
printf("No file to write\n");
}
}
static void usage(char *progname)
{
if (progname)
{
printf ("Usage: %s versionfile.h", progname);
}
}
// 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;
}
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, " ");
}
int major = 1;
int minor = 0;
int build = 0;
if (argc != 2)
{
usage(argv[0]);
}
else
{
char *target = argv[argc-1];
FILE *filePtr;
if (target) {
filePtr = fopen(target, "r+");
if (filePtr)
{
char buffer[256];
char *stringPtr = NULL;
while (!feof(filePtr))
{
fread(buffer, 256, 1, filePtr);
if ((stringPtr = strstr(buffer, VERSION_STRING)) != NULL)
{
char *ptr;
// Looking for '#define VERSION "x.y.z"'
ptr = strtok(stringPtr, " "); // The VERSION
ptr = strtok(NULL, "\n"); // The remainder
if (*ptr == '\"')
{
ptr++; // Inc past the first "
ptr = strtok(ptr, "."); // The first number
major = atoi(ptr);
ptr = strtok(NULL, "."); // The second number
minor = atoi(ptr);
ptr = strtok(NULL, "\""); // The final number
build = atoi(ptr);
fclose(filePtr);
writeVersion(target, major, minor, ++build);
printf ("Build %d Version %d.%d.%d\n", build, major, minor, build);
break;
} else
{
printf ("Build 0. Oops, didn't find a string of the format: '#define VERSION \"x.y.z\"'");
}
} // End if if (strstr
} // End of while
} // End of if filePtr
else
{
// Didn't find the file, write a new one
writeVersion(target, major, minor, build);
}
}
}
return 0;
}

View file

@ -0,0 +1,109 @@
# Microsoft Developer Studio Project File - Name="buildVersionUpdate" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=buildVersionUpdate - 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 "buildVersionUpdate.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 "buildVersionUpdate.mak" CFG="buildVersionUpdate - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "buildVersionUpdate - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "buildVersionUpdate - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "buildVersionUpdate - 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 "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /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"
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 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 /pdb:"..\..\..\Run\buildVersionUpdate.pdb" /map:"..\..\..\Run\buildVersionUpdate.map" /debug /machine:I386 /out:"..\..\..\Run\buildVersionUpdate.exe"
# SUBTRACT LINK32
!ELSEIF "$(CFG)" == "buildVersionUpdate - 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" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /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 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 /pdb:"..\..\..\Run\buildVersionUpdateD.pdb" /map:"..\..\..\Run\buildVersionUpdateD.map" /debug /machine:I386 /out:"..\..\..\Run\buildVersionUpdateD.exe"
# SUBTRACT LINK32
!ENDIF
# Begin Target
# Name "buildVersionUpdate - Win32 Release"
# Name "buildVersionUpdate - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\buildVersionUpdate.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"
# End Group
# End Target
# End Project