Skip to content

Commit 3d0ee53

Browse files
committed
Initial commit of Command & Conquer Generals and Command & Conquer Generals Zero Hour source code.
1 parent 2e338c0 commit 3d0ee53

File tree

6,072 files changed

+2283311
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

6,072 files changed

+2283311
-0
lines changed

Generals/Code/GameEngine/GameEngine.dsp

Lines changed: 4747 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
** Command & Conquer Generals(tm)
3+
** Copyright 2025 Electronic Arts Inc.
4+
**
5+
** This program is free software: you can redistribute it and/or modify
6+
** it under the terms of the GNU General Public License as published by
7+
** the Free Software Foundation, either version 3 of the License, or
8+
** (at your option) any later version.
9+
**
10+
** This program is distributed in the hope that it will be useful,
11+
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
** GNU General Public License for more details.
14+
**
15+
** You should have received a copy of the GNU General Public License
16+
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
////////////////////////////////////////////////////////////////////////////////
20+
// //
21+
// (c) 2001-2003 Electronic Arts Inc. //
22+
// //
23+
////////////////////////////////////////////////////////////////////////////////
24+
25+
// FILE: ActionManager.h //////////////////////////////////////////////////////////////////////////
26+
// Author: Colin Day
27+
// Desc: TheActionManager is a convenient place for us to wrap up all sorts of logical
28+
// queries about what objects can do in the world and to other objects. The purpose
29+
// of having a central place for this logic assists us in making these logical kind
30+
// of queries in the user interface and allows us to use the same code to validate
31+
// commands as they come in over the network interface in order to do the
32+
// real action.
33+
///////////////////////////////////////////////////////////////////////////////////////////////////
34+
35+
#pragma once
36+
37+
#ifndef __ACTIONMANAGER_H_
38+
#define __ACTIONMANAGER_H_
39+
40+
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
41+
#include "Common/SubsystemInterface.h"
42+
43+
// FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
44+
class Object;
45+
class Player;
46+
class SpecialPowerTemplate;
47+
enum SpecialPowerType;
48+
enum WeaponSlotType;
49+
enum CommandSourceType;
50+
enum CanAttackResult;
51+
52+
enum CanEnterType
53+
{
54+
CHECK_CAPACITY,
55+
DONT_CHECK_CAPACITY,
56+
COMBATDROP_INTO
57+
};
58+
59+
// ------------------------------------------------------------------------------------------------
60+
// ------------------------------------------------------------------------------------------------
61+
class ActionManager : public SubsystemInterface
62+
{
63+
64+
public:
65+
66+
ActionManager( void );
67+
virtual ~ActionManager( void );
68+
69+
virtual void init( void ) { }; ///< subsystem interface
70+
virtual void reset( void ) { }; ///< subsystem interface
71+
virtual void update( void ) { }; ///< subsystem interface
72+
73+
//Single unit to unit check
74+
Bool canGetRepairedAt( const Object *obj, const Object *repairDest, CommandSourceType commandSource );
75+
Bool canTransferSuppliesAt( const Object *obj, const Object *transferDest );
76+
Bool canDockAt( const Object *obj, const Object *dockDest, CommandSourceType commandSource );
77+
Bool canGetHealedAt( const Object *obj, const Object *healDest, CommandSourceType commandSource );
78+
Bool canRepairObject( const Object *obj, const Object *objectToRepair, CommandSourceType commandSource );
79+
Bool canResumeConstructionOf( const Object *obj, const Object *objectBeingConstructed, CommandSourceType commandSource );
80+
Bool canEnterObject( const Object *obj, const Object *objectToEnter, CommandSourceType commandSource, CanEnterType mode );
81+
CanAttackResult getCanAttackObject( const Object *obj, const Object *objectToAttack, CommandSourceType commandSource, AbleToAttackType attackType );
82+
Bool canConvertObjectToCarBomb( const Object *obj, const Object *objectToConvert, CommandSourceType commandSource );
83+
Bool canHijackVehicle( const Object *obj, const Object *ObjectToHijack, CommandSourceType commandSource ); // LORENZEN
84+
Bool canCaptureBuilding( const Object *obj, const Object *objectToCapture, CommandSourceType commandSource );
85+
Bool canDisableVehicleViaHacking( const Object *obj, const Object *objectToHack, CommandSourceType commandSource, Bool checkSourceRequirements = true );
86+
#ifdef ALLOW_SURRENDER
87+
Bool canPickUpPrisoner( const Object *obj, const Object *prisoner, CommandSourceType commandSource );
88+
#endif
89+
Bool canStealCashViaHacking( const Object *obj, const Object *objectToHack, CommandSourceType commandSource );
90+
Bool canSnipeVehicle( const Object *obj, const Object *objectToSnipe, CommandSourceType commandSource );
91+
Bool canBribeUnit( const Object *obj, const Object *objectToBribe, CommandSourceType commandSource );
92+
Bool canCutBuildingPower( const Object *obj, const Object *building, CommandSourceType commandSource );
93+
Bool canDisableBuildingViaHacking( const Object *obj, const Object *objectToHack, CommandSourceType commandSource );
94+
Bool canDoSpecialPowerAtLocation( const Object *obj, const Coord3D *loc, CommandSourceType commandSource, const SpecialPowerTemplate *spTemplate, const Object *objectInWay, UnsignedInt commandOptions, Bool checkSourceRequirements = true );
95+
Bool canDoSpecialPowerAtObject( const Object *obj, const Object *target, CommandSourceType commandSource, const SpecialPowerTemplate *spTemplate, UnsignedInt commandOptions, Bool checkSourceRequirements = true);
96+
Bool canDoSpecialPower( const Object *obj, const SpecialPowerTemplate *spTemplate, CommandSourceType commandSource, UnsignedInt commandOptions, Bool checkSourceRequirements = true );
97+
Bool canMakeObjectDefector( const Object *obj, const Object *objectToMakeDefector, CommandSourceType commandSource );
98+
Bool canFireWeaponAtLocation( const Object *obj, const Coord3D *loc, CommandSourceType commandSource, const WeaponSlotType slot, const Object *objectInWay );
99+
Bool canFireWeaponAtObject( const Object *obj, const Object *target, CommandSourceType commandSource, const WeaponSlotType slot );
100+
Bool canFireWeapon( const Object *obj, const WeaponSlotType slot, CommandSourceType commandSource );
101+
Bool canGarrison( const Object *obj, const Object *target, CommandSourceType commandSource );
102+
Bool canOverrideSpecialPowerDestination( const Object *obj, const Coord3D *loc, SpecialPowerType spType, CommandSourceType commandSource );
103+
104+
//Player to unit check
105+
Bool canPlayerGarrison( const Player *player, const Object *target, CommandSourceType commandSource );
106+
107+
protected:
108+
109+
};
110+
111+
// EXTERNALS //////////////////////////////////////////////////////////////////////////////////////
112+
extern ActionManager *TheActionManager;
113+
114+
#endif // end __ACTIONMANAGER_H_
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
** Command & Conquer Generals(tm)
3+
** Copyright 2025 Electronic Arts Inc.
4+
**
5+
** This program is free software: you can redistribute it and/or modify
6+
** it under the terms of the GNU General Public License as published by
7+
** the Free Software Foundation, either version 3 of the License, or
8+
** (at your option) any later version.
9+
**
10+
** This program is distributed in the hope that it will be useful,
11+
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
** GNU General Public License for more details.
14+
**
15+
** You should have received a copy of the GNU General Public License
16+
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
////////////////////////////////////////////////////////////////////////////////
20+
// //
21+
// (c) 2001-2003 Electronic Arts Inc. //
22+
// //
23+
////////////////////////////////////////////////////////////////////////////////
24+
25+
/////// ArchiveFile.h ////////////////////
26+
// Bryan Cleveland, August 2002
27+
//////////////////////////////////////////
28+
29+
#pragma once
30+
31+
#ifndef __ARCHIVEFILE_H
32+
#define __ARCHIVEFILE_H
33+
34+
#include "Lib/BaseType.h"
35+
#include "Common/AsciiString.h"
36+
#include "Common/ArchiveFileSystem.h"
37+
38+
class File;
39+
40+
/**
41+
* An archive file is itself a collection of sub files. Each file inside the archive file
42+
* has a unique name by which it can be accessed. The ArchiveFile object class is the
43+
* runtime interface to the mix file and the sub files. Each file inside the mix
44+
* file can be accessed by the openFile().
45+
*
46+
* ArchiveFile interfaces can be created by the TheArchiveFileSystem object.
47+
*/
48+
//===============================
49+
50+
class ArchiveFile
51+
{
52+
public:
53+
ArchiveFile();
54+
virtual ~ArchiveFile();
55+
56+
virtual Bool getFileInfo( const AsciiString& filename, FileInfo *fileInfo) const = 0; ///< fill in the fileInfo struct with info about the file requested.
57+
virtual File* openFile( const Char *filename, Int access = 0) = 0; ///< Open the specified file within the archive file
58+
virtual void closeAllFiles( void ) = 0; ///< Close all file opened in this archive file
59+
virtual AsciiString getName( void ) = 0; ///< Returns the name of the archive file
60+
virtual AsciiString getPath( void ) = 0; ///< Returns full path and name of archive file
61+
virtual void setSearchPriority( Int new_priority ) = 0; ///< Set this archive file's search priority
62+
virtual void close( void ) = 0; ///< Close this archive file
63+
void attachFile(File *file);
64+
65+
void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const;
66+
void getFileListInDirectory(const DetailedArchivedDirectoryInfo *dirInfo, const AsciiString& currentDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const;
67+
68+
void addFile(const AsciiString& path, const ArchivedFileInfo *fileInfo); ///< add this file to our directory tree.
69+
70+
protected:
71+
const ArchivedFileInfo * getArchivedFileInfo(const AsciiString& filename) const; ///< return the ArchivedFileInfo from the directory tree.
72+
73+
File *m_file; ///< file pointer to the archive file on disk. Kept open so we don't have to continuously open and close the file all the time.
74+
DetailedArchivedDirectoryInfo m_rootDirectory;
75+
};
76+
77+
#endif // __ARCHIVEFILE_H
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
/*
2+
** Command & Conquer Generals(tm)
3+
** Copyright 2025 Electronic Arts Inc.
4+
**
5+
** This program is free software: you can redistribute it and/or modify
6+
** it under the terms of the GNU General Public License as published by
7+
** the Free Software Foundation, either version 3 of the License, or
8+
** (at your option) any later version.
9+
**
10+
** This program is distributed in the hope that it will be useful,
11+
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
** GNU General Public License for more details.
14+
**
15+
** You should have received a copy of the GNU General Public License
16+
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
////////////////////////////////////////////////////////////////////////////////
20+
// //
21+
// (c) 2001-2003 Electronic Arts Inc. //
22+
// //
23+
////////////////////////////////////////////////////////////////////////////////
24+
25+
//----------------------------------------------------------------------------
26+
//
27+
// Westwood Studios Pacific.
28+
//
29+
// Confidential Information
30+
// Copyright (C) 2001 - All Rights Reserved
31+
//
32+
//----------------------------------------------------------------------------
33+
//
34+
// Project: Generals
35+
//
36+
// Module: Archive files
37+
//
38+
// File name: Common/ArchiveFileSystem.h
39+
//
40+
// Created: 11/26/01 TR
41+
//
42+
//----------------------------------------------------------------------------
43+
44+
#pragma once
45+
46+
#ifndef __ARCHIVEFILESYSTEM_H_
47+
#define __ARCHIVEFILESYSTEM_H_
48+
49+
#define MUSIC_BIG "Music.big"
50+
51+
//----------------------------------------------------------------------------
52+
// Includes
53+
//----------------------------------------------------------------------------
54+
55+
#include "Common/SubsystemInterface.h"
56+
#include "Common/AsciiString.h"
57+
#include "Common/FileSystem.h" // for typedefs, etc.
58+
#include "Common/STLTypedefs.h"
59+
60+
//----------------------------------------------------------------------------
61+
// Forward References
62+
//----------------------------------------------------------------------------
63+
64+
class File;
65+
class ArchiveFile;
66+
67+
//----------------------------------------------------------------------------
68+
// Type Defines
69+
//----------------------------------------------------------------------------
70+
71+
72+
//===============================
73+
// ArchiveFileSystem
74+
//===============================
75+
/**
76+
* Creates and manages ArchiveFile interfaces. ArchiveFiles can be accessed
77+
* by calling the openArchiveFile() member. ArchiveFiles can be accessed by
78+
* name or by File interface.
79+
*
80+
* openFile() member searches all Archive files for the specified sub file.
81+
*/
82+
//===============================
83+
class ArchivedDirectoryInfo;
84+
class DetailedArchivedDirectoryInfo;
85+
class ArchivedFileInfo;
86+
87+
typedef std::map<AsciiString, DetailedArchivedDirectoryInfo> DetailedArchivedDirectoryInfoMap;
88+
typedef std::map<AsciiString, ArchivedDirectoryInfo> ArchivedDirectoryInfoMap;
89+
typedef std::map<AsciiString, ArchivedFileInfo> ArchivedFileInfoMap;
90+
typedef std::map<AsciiString, ArchiveFile *> ArchiveFileMap;
91+
typedef std::map<AsciiString, AsciiString> ArchivedFileLocationMap; // first string is the file name, second one is the archive filename.
92+
93+
class ArchivedDirectoryInfo
94+
{
95+
public:
96+
AsciiString m_directoryName;
97+
ArchivedDirectoryInfoMap m_directories;
98+
ArchivedFileLocationMap m_files;
99+
100+
void clear()
101+
{
102+
m_directoryName.clear();
103+
m_directories.clear();
104+
m_files.clear();
105+
}
106+
107+
};
108+
109+
class DetailedArchivedDirectoryInfo
110+
{
111+
public:
112+
AsciiString m_directoryName;
113+
DetailedArchivedDirectoryInfoMap m_directories;
114+
ArchivedFileInfoMap m_files;
115+
116+
void clear()
117+
{
118+
m_directoryName.clear();
119+
m_directories.clear();
120+
m_files.clear();
121+
}
122+
};
123+
124+
class ArchivedFileInfo
125+
{
126+
public:
127+
AsciiString m_filename;
128+
AsciiString m_archiveFilename;
129+
UnsignedInt m_offset;
130+
UnsignedInt m_size;
131+
132+
ArchivedFileInfo()
133+
{
134+
clear();
135+
}
136+
137+
void clear()
138+
{
139+
m_filename.clear();
140+
m_archiveFilename.clear();
141+
m_offset = 0;
142+
m_size = 0;
143+
}
144+
};
145+
146+
147+
class ArchiveFileSystem : public SubsystemInterface
148+
{
149+
public:
150+
ArchiveFileSystem();
151+
virtual ~ArchiveFileSystem();
152+
153+
virtual void init( void ) = 0;
154+
virtual void update( void ) = 0;
155+
virtual void reset( void ) = 0;
156+
virtual void postProcessLoad( void ) = 0;
157+
158+
// ArchiveFile operations
159+
virtual ArchiveFile* openArchiveFile( const Char *filename ) = 0; ///< Create new or return existing Archive file from file name
160+
virtual void closeArchiveFile( const Char *filename ) = 0; ///< Close the one specified big file.
161+
virtual void closeAllArchiveFiles( void ) = 0; ///< Close all Archivefiles currently open
162+
163+
// File operations
164+
virtual File* openFile( const Char *filename, Int access = 0); ///< Search Archive files for specified file name and open it if found
165+
virtual void closeAllFiles( void ) = 0; ///< Close all files associated with ArchiveFiles
166+
virtual Bool doesFileExist(const Char *filename) const; ///< return true if that file exists in an archive file somewhere.
167+
168+
void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const; ///< search the given directory for files matching the searchName (egs. *.ini, *.rep). Possibly search subdirectories. Scans each Archive file.
169+
Bool getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const; ///< see FileSystem.h
170+
171+
virtual Bool loadBigFilesFromDirectory(AsciiString dir, AsciiString fileMask, Bool overwrite = FALSE) = 0;
172+
173+
// Unprotected this for copy-protection routines
174+
AsciiString getArchiveFilenameForFile(const AsciiString& filename) const;
175+
176+
void loadMods( void );
177+
178+
protected:
179+
virtual void loadIntoDirectoryTree(const ArchiveFile *archiveFile, const AsciiString& archiveFilename, Bool overwrite = FALSE); ///< load the archive file's header information and apply it to the global archive directory tree.
180+
181+
ArchiveFileMap m_archiveFileMap;
182+
ArchivedDirectoryInfo m_rootDirectory;
183+
};
184+
185+
186+
extern ArchiveFileSystem *TheArchiveFileSystem;
187+
188+
//----------------------------------------------------------------------------
189+
// Inlining
190+
//----------------------------------------------------------------------------
191+
192+
#endif // __ARCHIVEFILESYSTEM_H_

0 commit comments

Comments
 (0)