Skip to content

Commit ad7f853

Browse files
committed
2 parents 5c467bc + 477be26 commit ad7f853

File tree

81 files changed

+1657
-504
lines changed

Some content is hidden

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

81 files changed

+1657
-504
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ jobs:
4848
uses: actions/cache@v4
4949
with:
5050
path: build\${{ inputs.preset }}\_deps
51-
key: cmake-deps-${{ inputs.preset }}-${{ hashFiles('cmake/**/*.cmake', '**/CMakeLists.txt') }}
52-
restore-keys: |
53-
cmake-deps-${{ inputs.preset }}-
51+
key: cmake-deps-${{ inputs.preset }}-${{ hashFiles('CMakePresets.json','cmake/**/*.cmake','**/CMakeLists.txt') }}
5452

5553
- name: Download VC6 Portable from Cloudflare R2
5654
if: ${{ startsWith(inputs.preset, 'vc6') && steps.cache-vc6.outputs.cache-hit != 'true' }}

CMakePresets.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
{
1010
"name": "vc6",
1111
"displayName": "Windows 32bit VC6 Release",
12-
"generator": "NMake Makefiles",
12+
"generator": "Ninja",
1313
"hidden": false,
1414
"binaryDir": "${sourceDir}/build/${presetName}",
1515
"cacheVariables": {
1616
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
1717
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL",
18-
"CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "$<$<CONFIG:Release,Debug,RelWithDebInfo>:ProgramDatabase>",
18+
"CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "",
1919
"CMAKE_BUILD_TYPE": "Release",
2020
"RTS_FLAGS": "/W3"
2121
},

CONTRIBUTING.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# How to contribute as a developer
2+
3+
To contribute, fork this repository to create your own copy that you can clone locally and push back to. You can use your fork to create pull requests for your code to be merged into this repository.
4+
5+
## Code guidelines
6+
7+
### Scope of code changes
8+
9+
Code edits only touch the lines of code that serve the intended goal of the change. Big refactors should not be combined with logical changes, because these can become very difficult to review. If a change requires a refactor, create a commit for the refactor before (or after) creating a commit for the change. A Pull Request can contain multiple commits and can be merged with **Rebase and Merge** if these commits are meant to be preserved on the main branch. Otherwise, method of merging will be **Squash and Merge**.
10+
11+
### Style of code changes
12+
13+
Code edits should fit the nearby code in ways that the code style reads consistent, unless the original code style is bad. The original game code uses c++98, or a deviation thereof, and is simple to read. Prefer not to use newer language features unless required to implement the desired change. Prefer to use newer language features when they are considerably more robust or make the code easier to understand or maintain.
14+
15+
### Language style guide
16+
17+
*Work in progress. Needs a maintainer. Can be built upon existing Code guidelines, such as the "Google C++ Style Guide".*
18+
19+
### Precedence of code changes
20+
21+
Changes to Zero Hour take precedence over Generals, if applicable. When the changed code is not shared by both titles, then the change needs to be created for Zero Hour first, and then recreated for Generals. The implementation of a change for both titles needs to be identical or as close as possible. Preferably the Generals replica of a change comes with the same Pull Request. The Generals replica can be created after the Zero Hour code review has finished.
22+
23+
24+
## Change documentation
25+
26+
User facing changes need to be documented in code, Pull Requests and change logs. All documentation ideally is written in the present tense, and not the past.
27+
28+
Good:
29+
30+
> Fixes particle effect of USA Missile Defender
31+
32+
Bad:
33+
34+
> Fixed particle effect of USA Missile Defender
35+
36+
When a text refers to a faction unit, structure, upgrade or similar, then the unit should be worded without any abbrevations and should be prefixed with the faction name. Valid faction names are USA, China, GLA, Boss, Civilian. Subfaction names can be appended too, for example GLA Stealth.
37+
38+
Good:
39+
40+
> Fixes particle effect of USA Missile Defender
41+
42+
Bad:
43+
44+
> Fixes particle effect of MD
45+
46+
47+
### Code documentation
48+
49+
User facing changes need to be accompanied by comment(s) where the change is made. Maintenance related changes, such as compilation fixes, typically do not need commenting, unless the next reader can benefit from a special explanation. The comment can be put at the begin of the changed file, class, function or block. It must be clear from the change description what has changed.
50+
51+
The expected comment format is
52+
53+
```
54+
// TheSuperHackers @keyword author DD/MM/YYYY A meaningful description for this change.
55+
```
56+
57+
The `TheSuperHackers` word and `@keyword` are mandatory. `author` and date can be omitted when preferred.
58+
59+
| Keyword | Use-case |
60+
|------------------|-------------------------------------------------------------|
61+
| @bugfix | Fixes a bug |
62+
| @fix | Fixes something, but is not a user facing bug |
63+
| @compile | Addresses a compile warning or error |
64+
| @feature | Adds something new |
65+
| @performance | Improves performance |
66+
| @refactor | Moves or rewrites code, but does not change the behaviour |
67+
| @tweak | Changes values or settings |
68+
| @info | Writes useful information for the next reader |
69+
| @todo | Adds a note for something left to do if really necessary |
70+
71+
Block comment sample
72+
73+
```
74+
// TheSuperHackers @bugfix JAJames 17/03/2025 Fix uninitialized memory access and add more Windows versions.
75+
memset(&os_info,0,sizeof(os_info));
76+
```
77+
78+
Optionally, the pull request number can be appended to the comment. This can only be done after the pull request has been created.
79+
80+
```
81+
// TheSuperHackers @bugfix JAJames 17/03/2025 Fix uninitialized memory access and add more Windows versions. (#123)
82+
```
83+
84+
### Pull request documentation
85+
86+
The title of a new Pull Request, and/or commit(s) within, begin with a **[GEN]** and/or **[ZH]** tag, depending on the game(s) it targets. If a change does not target a game, then a tag is not necessary. Furthermore, the title consists of a concise and descriptive sentence about the change and/or commit, beginning with an uppercase letter and ending without a dot. The title ideally begins with a word that describes the action that the change takes, for example `Fix *this*`, `Change *that*`, `Add *those*`, `Refactor *thing*`.
87+
88+
Good:
89+
```
90+
[GEN][ZH] Fix uninitialized memory access in Get_OS_Info
91+
```
92+
93+
Bad:
94+
```
95+
Minimal changes for successful build.
96+
```
97+
98+
Currently established commit title tags are
99+
100+
* [GEN]
101+
* [ZH]
102+
* [CORE]
103+
* [CMAKE]
104+
* [GITHUB]
105+
* [LINUX]
106+
107+
If the Pull Request is meant to be merged with rebase, then a note for **Merge with Rebase** should be added to the top of the text body, to help identify the correct merge action when it is ready for merge. All commits of the Pull Request need to be properly named and need the number of the Pull Request added as a suffix in parentheses. Example: **(#333)**. All commits need to be able to compile on their own without dependencies in newer commits of the same Pull Request. Prefer to create changes for **Squash and Merge**, as this will simplify things.
108+
109+
The text body begins with links to related issue report(s) and/or Pull Request(s) if applicable.
110+
111+
To write a link use the following format:
112+
113+
```
114+
* Fixes #222
115+
* Closes #333
116+
* Relates to #555
117+
* Follow up for #666
118+
```
119+
120+
Links are commonly used for
121+
122+
* closing a related issue report or task when this pull request is merged
123+
* closing another pull request when this pull request is merged
124+
125+
Some keywords are interpreted by GitHub. Read about it [here](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue).
126+
127+
The text body continues with a description of the change in appropriate detail. This serves to educate reviewers and visitors to get a good understanding of the change without the need to study and understand the associated changed files. If the change is controversial or affects gameplay in a considerable way, then a rationale text needs to be appended. The rationale explains why the given change makes sense.
128+
129+
130+
### Pull request merging rules
131+
132+
Please be mindful when merging changes. There are pitfalls in regards to the commit title consistency.
133+
134+
When attempting to **Squash and Merge** a Pull Request that contains a single commit, then GitHub will default generate a commit title from that single commit. Typically this is undesired, when the new commit title is meant to be kept in sync with the Pull Request title rather than the Pull Request commit title. The generated commit title may need to be adjusted before merging the Pull Request.
135+
136+
When attempting to **Squash and Merge** a Pull Request that contains multiple commits, the GitHub will default generate a commit title from the Pull Request title. Additionally it will generate a commit description from the multiple commits that are part of the Pull Request. The generated commit description generally needs to be cleared before merging the Pull Request to keep the commit title clean.
137+
138+
When attempting to **Rebase and Merge** a Pull Request, then all commits will transfer with the same names to the main branch. Verify that all commit titles are properly crafted, with tags where applicable, trailing Pull Request numbers in parentheses and no unnecessary commit descriptions (texts below the commit title).
139+
140+
141+
### Change log documentation
142+
143+
*Work in progress.*

Core/GameEngine/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ set(GAMEENGINE_SRC
112112
# Include/Common/StateMachine.h
113113
# Include/Common/StatsCollector.h
114114
# Include/Common/STLTypedefs.h
115+
Include/Common/STLUtils.h
115116
# Include/Common/StreamingArchiveFile.h
116117
# Include/Common/SubsystemInterface.h
117118
# Include/Common/SystemInfo.h

Core/GameEngine/Include/Common/GameDefines.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
#define RETAIL_COMPATIBLE_XFER_SAVE (1) // Game is expected to be Xfer Save compatible with retail Generals 1.08, Zero Hour 1.04
3030
#endif
3131

32+
// This is essentially synonymous for RETAIL_COMPATIBLE_CRC. There is a lot wrong with AIGroup, such as use-after-free, double-free, leaks,
33+
// but we cannot touch it much without breaking retail compatibility. Do not shy away from using massive hacks when fixing issues with AIGroup,
34+
// but put them behind this macro.
35+
36+
#ifndef RETAIL_COMPATIBLE_AIGROUP
37+
#define RETAIL_COMPATIBLE_AIGROUP (1) // AIGroup logic is expected to be CRC compatible with retail Generals 1.08, Zero Hour 1.04
38+
#endif
39+
3240
#ifndef ENABLE_GAMETEXT_SUBSTITUTES
3341
#define ENABLE_GAMETEXT_SUBSTITUTES (1) // The code can provide substitute texts when labels and strings are missing in the STR or CSF translation file
3442
#endif
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
** Command & Conquer Generals Zero Hour(tm)
3+
** Copyright 2025 TheSuperHackers
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+
#pragma once
20+
21+
#include <Utility/CppMacros.h>
22+
#include <utility>
23+
24+
namespace stl
25+
{
26+
27+
// Finds first matching element in vector-like container and erases it.
28+
template <typename Container>
29+
bool find_and_erase(Container& container, const typename Container::value_type& value)
30+
{
31+
typename Container::const_iterator it = container.begin();
32+
for (; it != container.end(); ++it)
33+
{
34+
if (*it == value)
35+
{
36+
container.erase(it);
37+
return true;
38+
}
39+
}
40+
return false;
41+
}
42+
43+
// Finds first matching element in vector-like container and removes it by swapping it with the last element.
44+
// This is generally faster than erasing from a vector, but will change the element sorting.
45+
template <typename Container>
46+
bool find_and_erase_unordered(Container& container, const typename Container::value_type& value)
47+
{
48+
typename Container::iterator it = container.begin();
49+
for (; it != container.end(); ++it)
50+
{
51+
if (*it == value)
52+
{
53+
*it = CPP_11(std::move)(container.back());
54+
container.pop_back();
55+
return true;
56+
}
57+
}
58+
return false;
59+
}
60+
61+
} // namespace stl

Core/Tools/W3DView/W3DView.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ CAboutDlg::OnInitDialog (void)
472472
version_minor = pversion_info->dwFileVersionLS;
473473
}
474474
}
475-
SAFE_DELETE (pblock);
475+
SAFE_DELETE_ARRAY(pblock);
476476
}
477477

478478
// Put the version string into the dialog

Generals/Code/GameEngine/Include/Common/GameEngine.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ class GameEngine : public SubsystemInterface
8585

8686
protected:
8787

88+
virtual void resetSubsystems( void );
89+
8890
virtual FileSystem *createFileSystem( void ); ///< Factory for FileSystem classes
8991
virtual LocalFileSystem *createLocalFileSystem( void ) = 0; ///< Factory for LocalFileSystem classes
9092
virtual ArchiveFileSystem *createArchiveFileSystem( void ) = 0; ///< Factory for ArchiveFileSystem classes

Generals/Code/GameEngine/Include/Common/Player.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ class Player : public Snapshot
608608
// add to the player's current selection this hotkey team.
609609
void processAddTeamGameMessage(Int hotkeyNum, GameMessage *msg);
610610

611-
// returns an AIGroup object that is the currently selected group.
611+
// fills an AIGroup object that is the currently selected group.
612612
void getCurrentSelectionAsAIGroup(AIGroup *group);
613613

614614
// sets the currently selected group to be the given AIGroup

Generals/Code/GameEngine/Include/Common/Radar.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,8 @@ class Radar : public Snapshot,
190190
Bool tryEvent( RadarEventType event, const Coord3D *pos ); ///< try to make a "stealth" event
191191

192192
// adding and removing objects from the radar
193-
void addObject( Object *obj ); ///< add object to radar
194-
void removeObject( Object *obj ); ///< remove object from radar
195-
void examineObject( Object *obj ); ///< re-examine object and resort if needed
193+
virtual bool addObject( Object *obj ); ///< add object to radar
194+
virtual bool removeObject( Object *obj ); ///< remove object from radar
196195

197196
// radar options
198197
void hide( Bool hide ) { m_radarHidden = hide; } ///< hide/unhide the radar

0 commit comments

Comments
 (0)