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,203 @@
/*
** 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: versionUpdate.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_BUILDNUM "VERSION_LOCALBUILDNUM"
#define VERSION_STRING "LOCAL_BUILD_STRING"
#define VERSION_BUILDUSER "VERSION_BUILDUSER"
#define VERSION_BUILDLOC "VERSION_BUILDLOC"
#define FORMAT "#define " VERSION_STRING " \"%d\"\n"
#define COMMENTS "// Do not modify this file by hand. Auto-created and\n// Updated by versionUpdate.\n"
#define NUMFMT "#define %s %d\n"
#define STRFMT "#define %s \"%s\"\n"
static void writeVersion(char *file, int build)
{
FILE *filePtr = fopen(file, "w");
// Clobber the file. Hey, this is a simple program.
if (file)
{
if (filePtr)
{
unsigned long bufSize = UNLEN + 1;
char userName[UNLEN + 1];
if (!GetUserName(userName, &bufSize))
{
strcpy(userName, "unknown");
}
bufSize = MAX_COMPUTERNAME_LENGTH + 1;
char computerName[MAX_COMPUTERNAME_LENGTH + 1];
if (!GetComputerName(computerName, &bufSize))
{
strcpy(computerName, "unknown");
}
printf("Build is by %s at %s\n", userName, computerName);
fprintf(filePtr, COMMENTS);
fprintf(filePtr, FORMAT, build);
fprintf(filePtr, NUMFMT, VERSION_BUILDNUM, build);
fprintf(filePtr, STRFMT, VERSION_BUILDUSER, userName);
fprintf(filePtr, STRFMT, VERSION_BUILDLOC, computerName);
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 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 "
build = atoi(ptr);
fclose(filePtr);
build++;
printf ("Local build is %d\n", build);
writeVersion(target, build);
break;
} else
{
printf ("Local build is 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
printf ("Local build is %d\n", build);
writeVersion(target, build);
}
}
}
return 0;
}

View file

@ -0,0 +1,111 @@
# Microsoft Developer Studio Project File - Name="versionUpdate" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=versionUpdate - 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 "versionUpdate.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 "versionUpdate.mak" CFG="versionUpdate - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "versionUpdate - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "versionUpdate - 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)" == "versionUpdate - 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/versionUpdate.pdb" /map:"../../../Run/versionUpdate.map" /debug /machine:I386 /out:"../../../Run/versionUpdate.exe"
!ELSEIF "$(CFG)" == "versionUpdate - 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/versionUpdateD.pdb" /map:"../../../Run/versionUpdateD.map" /debug /machine:I386 /out:"../../../Run/versionUpdateD.exe"
!ENDIF
# Begin Target
# Name "versionUpdate - Win32 Release"
# Name "versionUpdate - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\versionUpdate.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
# Begin Source File
SOURCE=.\ReadMe.txt
# End Source File
# End Target
# End Project