Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(gameengine): mods use the zero hour maps, not their own
Olcay Seygan70cc15027a2b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 649d52865..28ca20d1a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -33,6 +33,7 @@ found and fixed — EA's own, not port damage.**- A mod is a folder now. Start the game with `-mod` and the folder, and the archives in it replace Zero Hour's files, as before, and so do the plain files under its `Data` and `Art` folders, which the game used to ignore. A modder can drop in one changed file without packing an archive first.- Several mods run at once. Give `-mod` once for each, and where two of them change the same file, the one named later wins.- Reforged stays on top of every mod. This build's balance, its fixes to EA's data, its AI and its menus load after the mod and win where they touch the same unit, weapon or button, so a mod plays with Reforged's rules. A change that names something the mod renamed or removed is passed over instead of stopping the game, which is how ShockWave starts and plays. A mod's own copy of a file Reforged ships, the skirmish setup screen among them, is ignored, and so are any upscaled art archives it carries. The one exception is the skirmish AI's scripts: a mod's are written for its own generals, so they replace Reforged's, and Reforged's smarter AI plays them.+- The maps stay Zero Hour's under every mod. A mod that carries its own maps, Contra among them, used to fill the skirmish and LAN map lists with them, and its edited copies of the stock maps replaced ours under the same names: picking Twilight Flame started Contra's Twilight Flame. The map list and every map you start are Zero Hour's and Reforged's now, whatever mods are loaded, so everyone in a lobby plays the same map.- A `mod.json` in the folder names the mod and its version. The names stand beside the version number in the options menu, in the order the mods were given, and go into every replay you record, so a replay made with mods says which ones, and the replay list marks it as another version when the game is running without them.- Joining a LAN game that runs different mods used to end in a box about a mismatch and nothing else. It names the host's mods now, or tells you the host plays without any.- Two total conversions in one match. Add `-modfactions` to the mods you give, and each mod's armies join Zero Hour's own instead of replacing them: the faction list reads "ShockWave - USA" and "The End of Days - USA" under plain "USA", and a ShockWave army can fight an End of Days one. Each side builds from its own mod's units, weapons, upgrades and generals' powers, and each looks and sounds like its own mod: a ShockWave tank wears ShockWave's model and textures even where The End of Days replaces the same file, and speaks with ShockWave's voice. The End of Days' Russian command center, its Tor-M1 and some sixty other models used to come out bright pink; they wear the mod's own paint now. Playing a mod's faction, your buttons, build pictures, unit names and tooltips are that mod's, set in our command bar for that general's country: a mod's Chinese general gets the Chinese bar, a GLA one the GLA bar, and a nation Zero Hour never had, Russia among them, the American one. Every mod general used to get the American bar. The End of Days' Russia is in the list under its own name. Each mod general's promotion screen holds that mod's own powers, with the mod's pictures, and they unlock with your rank. They sit together with no holes between them, and each power's upgrades stand in the column under it, Paradrop 1 over 2 over 3, the way Zero Hour lays out its own. A mod's faction climbs that mod's own ranks: The End of Days' eight, with its own experience steps and points, where Zero Hour's five used to apply to everyone. ShockWave's and The End of Days' screens used to open empty, because a rank granted only Zero Hour's own rank marks and the mod's powers asked for the mod's. Menus, lobby and colours stay ours whatever mods you load. A computer player on a mod's faction plays that mod's own skirmish AI: the mod's base layout, base defences, harvester counts, generals' powers and the teams its scripts train, run by Reforged's AI. It used to lay out the base from the mod's buildings and then train the army it knew from Zero Hour, and a nation Zero Hour never had did nothing at all. A mod that ships no skirmish AI of its own still gets Zero Hour's, read with the mod's buildings.diff --git a/GeneralsMD/Code/GameEngine/Include/Common/FileSystem.h b/GeneralsMD/Code/GameEngine/Include/Common/FileSystem.hindex 6227395a1..8103dabde 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/FileSystem.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/FileSystem.h@@ -150,6 +150,10 @@ public:/// .wnd layouts ...); see the definition for how the set is decided.static Bool isForkOwnedPath(const AsciiString& filename);+ /// TRUE for a game path under "Maps\": the maps are always ours, a mod's own maps are never listed or+ /// loaded, so every machine in a match reads the same map whatever mods it runs+ static Bool isMapPath(const AsciiString& filename);+/// -modfactions: FILE_FOCUS_RETAIL or a -mod index makes every read see that set of files alone,/// so retail and each mod load their factions one after another; FILE_FOCUS_ALL is the merged view.void setFocus(Int focus);diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/ArchiveFileSystem.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/ArchiveFileSystem.cppindex 4e6667635..0660464f7 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/System/ArchiveFileSystem.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/ArchiveFileSystem.cpp@@ -140,9 +140,18 @@ void ArchiveFileSystem::addToTree(ArchivedDirectoryInfo &root, const ArchiveFilearchiveFile->getFileListInDirectory(AsciiString(""), AsciiString(""), AsciiString("*"), filenameList, TRUE);+ // a mod's maps never go in, merged or kept apart: the maps are ours (FileSystem::isMapPath)+ const Bool modArchive = modLayerOf(archiveFilename).isNotEmpty();+ Int mapsIgnored = 0;+FilenameListIter it = filenameList.begin();while (it != filenameList.end()) {+ if (modArchive && FileSystem::isMapPath(*it)) {+ ++mapsIgnored;+ it++;+ continue;+ }// add this filename to the directory tree.AsciiString path = *it;path.toLower();@@ -179,6 +188,8 @@ void ArchiveFileSystem::addToTree(ArchivedDirectoryInfo &root, const ArchiveFileit++;}+ if (mapsIgnored > 0)+ DEBUG_LOG(("ArchiveFileSystem - %d map files in %s are ignored, the maps are ours\n", mapsIgnored, archiveFilename.str()));}/// the fork's upscaled art goes by its file name, ReforgedTextures.big and the like@@ -508,8 +519,18 @@ void ArchiveFileSystem::getFileListInDirectory(const AsciiString& currentDirecto{ArchiveFileMap::const_iterator it = m_archiveFileMap.begin();while (it != m_archiveFileMap.end()) {- if (inFocus(it->first))+ if (inFocus(it->first) && modLayerOf(it->first).isEmpty())it->second->getFileListInDirectory(currentDirectory, originalDirectory, searchName, filenameList, searchSubdirectories);+ else if (inFocus(it->first))+ {+ FilenameList modded;+ it->second->getFileListInDirectory(currentDirectory, originalDirectory, searchName, modded, searchSubdirectories);+ for (FilenameListIter name = modded.begin(); name != modded.end(); ++name)+ {+ if (!FileSystem::isMapPath(*name))+ filenameList.insert(*name);+ }+ }it++;}}diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cppindex 2ff081682..44d9248ea 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp@@ -437,7 +437,9 @@ void FileSystem::getFileListInDirectory(const AsciiString& directory, const AsciTheLocalFileSystem->getFileListInDirectory(AsciiString(""), modDirectory, searchName, modded, searchSubdirectories);for (FilenameListIter it = modded.begin(); it != modded.end(); ++it){- filenameList.insert(AsciiString(it->str() + modDir.getLength()));+ AsciiString gamePath = it->str() + modDir.getLength();+ if (!isMapPath(gamePath))+ filenameList.insert(gamePath);}}}@@ -454,7 +456,7 @@ AsciiString FileSystem::modLooseFile(const AsciiString& filename, Bool *inModArc// a folder is not a file: "" or "Maps\" would otherwise find the mod folder itself, which exists// -modfactions reaches a mod's files only by its focus or its "M<n>~" names, so here only the// patches given before any -mod go over retail's- if (TheGlobalData == NULL || isAbsolutePath(filename) || filename.isEmpty() || filename.endsWith("\\") || filename.endsWith("/"))+ if (TheGlobalData == NULL || isAbsolutePath(filename) || filename.isEmpty() || filename.endsWith("\\") || filename.endsWith("/") || isMapPath(filename)){return AsciiString();}@@ -509,6 +511,16 @@ AsciiString FileSystem::modLooseFile(const AsciiString& filename, Bool *inModArcreturn loose;}+//============================================================================+// FileSystem::isMapPath+//============================================================================+Bool FileSystem::isMapPath(const AsciiString& filename)+{+ // A mod's Maps.big carries its own edits of the stock maps under the same names (Contra's Twilight+ // Flame is not ours), and a lobby has to agree on one file: retail's and the fork's maps win always.+ return strncasecmp(filename.str(), "maps", 4) == 0 && (filename.str()[4] == '\\' || filename.str()[4] == '/');+}+//============================================================================// FileSystem::isForkOwnedPath//============================================================================diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cppindex 32c19da14..ac1f49e33 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp@@ -33,6 +33,7 @@#include "Lib/WideCharFns.h"+#include "Common/ArchiveFileSystem.h"#include "Common/CRCDebug.h"#include "Common/file.h"#include "Common/FileSystem.h"@@ -604,6 +605,7 @@ void GameInfo::setMap( AsciiString mapName )const MapMetaData *mapData = TheMapCache->findMap( mapName );if (mapData){+ DEBUG_LOG(("GameInfo::setMap() - '%s' from '%s'\n", mapName.str(), TheArchiveFileSystem->getArchiveFilenameForFile(mapName).str()));m_mapMask = 1;AsciiString path = mapName;path.removeLastChar();