Skip to content

Commit 720a726

Browse files
committed
Replicate in Generals
1 parent 01991cc commit 720a726

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
#include "W3DDevice/GameClient/W3DFileSystem.h"
5151

5252
#include <io.h>
53-
#include <Utility/stdio_adapter.h>
5453

5554
// DEFINES ////////////////////////////////////////////////////////////////////////////////////////
5655

@@ -410,7 +409,7 @@ W3DFileSystem::W3DFileSystem(void)
410409
{
411410
_TheFileFactory = this; // override the w3d file factory.
412411

413-
#if PRIORITIZE_TEXTURES_BY_SIZE
412+
#if RTS_ZEROHOUR && PRIORITIZE_TEXTURES_BY_SIZE
414413
reprioritizeTexturesBySize();
415414
#endif
416415
}
@@ -444,18 +443,10 @@ void W3DFileSystem::Return_File( FileClass *file )
444443
//-------------------------------------------------------------------------------------------------
445444
void W3DFileSystem::reprioritizeTexturesBySize()
446445
{
446+
ArchivedDirectoryInfo* dirInfo = TheArchiveFileSystem->friend_getArchivedDirectoryInfo(TGA_DIR_PATH);
447+
if (dirInfo != NULL)
447448
{
448-
ArchivedDirectoryInfo* dirInfo = TheArchiveFileSystem->friend_getArchivedDirectoryInfo(TGA_DIR_PATH);
449-
if (dirInfo != NULL)
450-
reprioritizeTexturesBySize(*dirInfo);
451-
}
452-
453-
{
454-
char path[_MAX_PATH];
455-
snprintf(path, ARRAY_SIZE(path), "Data/%s/Art/Textures/", GetRegistryLanguage().str());
456-
ArchivedDirectoryInfo* dirInfo = TheArchiveFileSystem->friend_getArchivedDirectoryInfo(path);
457-
if (dirInfo != NULL)
458-
reprioritizeTexturesBySize(*dirInfo);
449+
reprioritizeTexturesBySize(*dirInfo);
459450
}
460451
}
461452

@@ -465,9 +456,15 @@ void W3DFileSystem::reprioritizeTexturesBySize()
465456
// what we currently need:
466457
// Before: A(256kb) B(128kb) C(512kb)
467458
// After: C(512kb) B(128kb) A(256kb)
459+
//
460+
// Catered to specific game archives only. This ensures that non user created archives are not
461+
// affected by the re-prioritization.
468462
//-------------------------------------------------------------------------------------------------
469463
void W3DFileSystem::reprioritizeTexturesBySize(ArchivedDirectoryInfo& dirInfo)
470464
{
465+
const char* const superiorArchive = "Textures.big";
466+
const char* const inferiorArchive = "TexturesZH.big";
467+
471468
ArchivedFileLocationMap::iterator it0;
472469
ArchivedFileLocationMap::iterator it1 = dirInfo.m_files.begin();
473470
ArchivedFileLocationMap::iterator end = dirInfo.m_files.end();
@@ -497,7 +494,9 @@ void W3DFileSystem::reprioritizeTexturesBySize(ArchivedDirectoryInfo& dirInfo)
497494

498495
if (archive0->getFileInfo(filepath, &info0) && archive1->getFileInfo(filepath, &info1))
499496
{
500-
if (info0.size() < info1.size())
497+
if (info0.size() < info1.size()
498+
&& archive0->getName().endsWithNoCase(inferiorArchive)
499+
&& archive1->getName().endsWithNoCase(superiorArchive))
501500
{
502501
std::swap(it0->second, it1->second);
503502

0 commit comments

Comments
 (0)