Skip to content

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.

fix(gameengine): probe the language archive in a temp dir in its test

Olcay Seygan5f5397eae26b
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp
index 39bd0a4f6..089eb4478 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp
@@ -710,7 +710,7 @@ 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()))
+ if (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.cpp
index 5fa4e0065..ea205fc69 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -578,12 +578,23 @@ TEST(installed_language_falls_back_to_english_when_its_data_is_missing)
TEST(zero_hour_language_is_the_one_its_language_archive_names)
{
CHECK( bootOnce() );
+
+ // an empty folder of its own: the cwd may be Run, whose EnglishZH.big a case-blind Windows
+ // answers to, and a polishZH.big left there would be a real archive to the game
+ const std::filesystem::path home = std::filesystem::current_path();
+ const std::filesystem::path dir = std::filesystem::temp_directory_path() / "zh_zerohour_language";
+ std::filesystem::remove_all( dir );
+ std::filesystem::create_directory( dir );
+ std::filesystem::current_path( dir );
+
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" );
+
+ std::filesystem::current_path( home );
+ std::filesystem::remove_all( dir );
}
/* An unknown block name aborts the whole file - INI::load throws