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): take the language from zero hour's own archive
Andreas Bergerad375479c6cb
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 95ea7880c..0e897f10c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -24,6 +24,7 @@ found and fixed — EA's own, not port damage.**- The first start finds your game. It looks in your Steam libraries, `~/Games`, `/Applications`, and CrossOver and Whisky bottles, and asks for the folder only when it comes up empty.- One command builds it. `./build-macos.sh` leaves a Mac app ready to open and `./build-linux.sh` a folder ready to start, and each checks your machine first and names the package to install for anything missing. On Linux it can make an AppImage, a .deb, an .rpm, an Arch package and a Flatpak, none of them carrying EA's files, and the Flatpak has played a full check match on a Steam Deck.- One game on every machine. A replay recorded on a Mac plays back on Linux and on Windows to the same checksum, and the other way round, and a Mac and a Linux PC have played a LAN match together without once disagreeing. A Mac or Linux game could not join a Windows one: the check every machine runs before a network game failed, because the Mac and Linux copies of the game's data files ended each line differently from Windows'. They agree now. A match between Windows and a Mac has not been played yet.+- A German, French or other non-English Zero Hour on a Mac or Linux speaks its own language. Windows' installer writes the language into the registry, and nothing does that on a Mac or Linux, so the game took English and found it in the original Generals' files beside Zero Hour: the menus came up in Generals' English with Zero Hour's own lines missing, so it looked like plain Generals. With no language set it now takes the one your Zero Hour's own files are in. A language you set yourself still wins.- Text on the Linux menus is as wide as on Windows. Linux has no Arial, and the font standing in for it reports a wider average letter, so every menu font the game sets to a fixed width came out a quarter narrower than it should, the "Generals" lettering and the menu buttons among them. Each is measured against Arial's own figure now, and lands within one percent of Windows.- The game no longer crashes on some Linux PCs as its window opens. The game hands out memory its own way, and on Linux the graphics driver gets its memory from the game too. Some drivers, AMD's on Debian 12 among them, need every piece lined up on a 16-byte boundary, and the game's lined up on 4, so the start died or went through depending on where the pieces happened to fall. On Linux everything outside the game's own pools now comes from the system, which lines it up as the driver expects.- `./build-linux.sh` stopped on Linux Mint and Arch after the centred Classic interface went in: the new code compared layout names with a Windows-only spelling that GCC on Linux has never heard of. It uses the name every platform knows now, and so do the two debug-build spots with the same habit. Nobody has rebuilt on Linux since, so whether anything else stands in the way is not known yet.diff --git a/GeneralsMD/Code/GameEngine/Include/Common/FileSystem.h b/GeneralsMD/Code/GameEngine/Include/Common/FileSystem.hindex 4963899e1..7649d3392 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/FileSystem.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/FileSystem.h@@ -174,6 +174,8 @@ public:/// retail language that has one (english first), otherwise empty./// Only meaningful once the archives are mounted.AsciiString installedLanguage(const AsciiString &language) const;+ /// the retail language whose <language>ZH.big sits loose in the install folder, otherwise empty.+ AsciiString zeroHourLanguage() const;Bool areMusicFilesOnCD();void loadMusicFilesFromCD();diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cppindex ab9332187..5361f1378 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp@@ -1038,7 +1038,14 @@ void GameEngine::init( int argc, char *argv[] )// The first place the archives can answer it, and before anything builds a path under// Data\<language>: GlobalLanguage, GameText, the CommandMap, speech and localized art all ask after this.{- const AsciiString registryLanguage = GetRegistryLanguage();+ AsciiString registryLanguage = GetRegistryLanguage();+ AsciiString named;+ if (!GetStringFromRegistry( "", "Language", named ))+ {+ const AsciiString shipped = TheFileSystem->zeroHourLanguage();+ if (!shipped.isEmpty())+ registryLanguage = shipped;+ }const AsciiString language = TheFileSystem->installedLanguage( registryLanguage );if (language.isEmpty()){@@ -1048,11 +1055,10 @@ void GameEngine::init( int argc, char *argv[] )_exit(1);}if (language.compareNoCase( registryLanguage ) != 0)- {DEBUG_LOG(("GameEngine::init - Language=%s has no Data\\%s\\Language.ini, using %s\n",registryLanguage.str(), registryLanguage.str(), language.str()));+ if (language.compareNoCase( GetRegistryLanguage() ) != 0)SetRegistryLanguage( language );- }}initSubsystem(TheWritableGlobalData, "TheWritableGlobalData", MSGNEW("GameEngineSubsystem") GlobalData(), &xferCRC, "Data\\INI\\Default\\GameData.ini", "Data\\INI\\GameData.ini");diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cppindex fdfcd8550..39bd0a4f6 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp@@ -680,20 +680,38 @@ Bool FileSystem::createDirectory(AsciiString directory)then threw on Data\german\Language.ini before the first frame (player report #39). A German-onlyinstall has no english to fall back to either (issue #63), so every retail language is tried.Empty when no Language.ini is found at all. */+static const char *const RetailLanguages[] = { "english", "german", "french", "spanish", "italian",+ "korean", "chinese", "brazilian", "polish", "russian" };+AsciiString FileSystem::installedLanguage(const AsciiString &language) const{- static const char *const fallbacks[] = { "english", "german", "french", "spanish", "italian",- "korean", "chinese", "brazilian", "polish", "russian" };AsciiString probe;if (!language.isEmpty()) {probe.format("Data\\%s\\Language.ini", language.str());if (doesFileExist(probe.str()))return language;}- for (Int i = 0; i < (Int)(sizeof(fallbacks) / sizeof(fallbacks[0])); ++i) {- probe.format("Data\\%s\\Language.ini", fallbacks[i]);+ for (Int i = 0; i < (Int)ARRAY_SIZE(RetailLanguages); ++i) {+ probe.format("Data\\%s\\Language.ini", RetailLanguages[i]);if (doesFileExist(probe.str()))- return AsciiString(fallbacks[i]);+ return AsciiString(RetailLanguages[i]);+ }+ return AsciiString::TheEmptyString;+}++//============================================================================+// FileSystem::zeroHourLanguage+//============================================================================+/* With no Language in the registry (a Linux or Mac install never ran EA's installer, which writes it)+ the default english finds the base game's English.big in ZH_Generals, so a German Zero Hour showed+ Generals' text with Zero Hour's strings missing. Zero Hour's own language archive says which it is. */+AsciiString FileSystem::zeroHourLanguage() const+{+ AsciiString probe;+ for (Int i = 0; i < (Int)ARRAY_SIZE(RetailLanguages); ++i) {+ probe.format("%sZH.big", RetailLanguages[i]);+ if (TheLocalFileSystem != NULL && TheLocalFileSystem->doesFileExist(probe.str()))+ return AsciiString(RetailLanguages[i]);}return AsciiString::TheEmptyString;}diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 936d08782..2d3b1b30d 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -569,6 +569,19 @@ TEST(installed_language_falls_back_to_english_when_its_data_is_missing)std::filesystem::remove( "Data", ec ); // only if this test made it; a non-empty one stays}+/* A German Zero Hour on Linux has no Language in Registry.ini, and english found the base game's+ English.big: Generals' text, Zero Hour's strings missing. The loose <language>ZH.big names it. */+TEST(zero_hour_language_is_the_one_its_language_archive_names)+{+ CHECK( bootOnce() );+ CHECK_STR( TheFileSystem->zeroHourLanguage().str(), "" );++ // the probe's own spelling: this test's local file system is fopen's, not the game's case-blind one+ writeFile( "polishZH.big", "" );+ CHECK_STR( TheFileSystem->zeroHourLanguage().str(), "polish" );+ remove( "polishZH.big" );+}+/* An unknown block name aborts the whole file - INI::load throwsINI_UNKNOWN_TOKEN and the blocks after it never get read. Worth pinning:nothing in the loader skips unknown blocks, so an INI written for a newer